// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_ #define COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_ #include <string> #include <vector> #include "base/functional/bind.h" #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "components/dom_distiller/core/article_distillation_update.h" #include "components/dom_distiller/core/article_entry.h" #include "components/dom_distiller/core/distiller.h" #include "components/dom_distiller/core/proto/distilled_page.pb.h" class GURL; namespace dom_distiller { class DistilledArticleProto; class DistilledContentStore; // A handle to a request to view a DOM distiller entry or URL. The request will // be cancelled when the handle is destroyed. class ViewerHandle { … }; // Interface for a DOM distiller entry viewer. Implement this to make a view // request and receive the data for an entry when it becomes available. class ViewRequestDelegate : public base::CheckedObserver { … }; // A TaskTracker manages the various tasks related to viewing, saving, // distilling, and fetching an article's distilled content. // // There are two sources of distilled content, a Distiller and the BlobFetcher. // At any time, at most one of each of these will be in-progress (if one // finishes, the other will be cancelled). // // There are also two consumers of that content, a view request and a save // request. There is at most one save request (i.e. we are either adding this to // the reading list or we aren't), and may be multiple view requests. When // the distilled content is ready, each of these requests will be notified. // // A view request is cancelled by deleting the corresponding ViewerHandle. Once // all view requests are cancelled (and the save callback has been called if // appropriate) the cancel callback will be called. // // After creating a TaskTracker, a consumer of distilled content should be added // and at least one of the sources should be started. class TaskTracker { … }; } // namespace dom_distiller #endif // COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_