Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: components/dom_distiller/core/task_tracker.h

Issue 178303004: Add incremental updates for multipage distillation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_ 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_
6 #define COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_ 6 #define COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "components/dom_distiller/core/article_distillation_update.h"
14 #include "components/dom_distiller/core/article_entry.h" 15 #include "components/dom_distiller/core/article_entry.h"
15 #include "components/dom_distiller/core/distiller.h" 16 #include "components/dom_distiller/core/distiller.h"
16 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 17 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
17 18
18 class GURL; 19 class GURL;
19 20
20 namespace dom_distiller { 21 namespace dom_distiller {
21 22
22 class DistilledArticleProto; 23 class DistilledArticleProto;
23 24
(...skipping 13 matching lines...) Expand all
37 // Interface for a DOM distiller entry viewer. Implement this to make a view 38 // Interface for a DOM distiller entry viewer. Implement this to make a view
38 // request and receive the data for an entry when it becomes available. 39 // request and receive the data for an entry when it becomes available.
39 class ViewRequestDelegate { 40 class ViewRequestDelegate {
40 public: 41 public:
41 virtual ~ViewRequestDelegate() {} 42 virtual ~ViewRequestDelegate() {}
42 // Called when the distilled article contents are available. The 43 // Called when the distilled article contents are available. The
43 // DistilledArticleProto is owned by a TaskTracker instance and is invalidated 44 // DistilledArticleProto is owned by a TaskTracker instance and is invalidated
44 // when the corresponding ViewerHandle is destroyed (or when the 45 // when the corresponding ViewerHandle is destroyed (or when the
45 // DomDistillerService is destroyed). 46 // DomDistillerService is destroyed).
46 virtual void OnArticleReady(const DistilledArticleProto* article_proto) = 0; 47 virtual void OnArticleReady(const DistilledArticleProto* article_proto) = 0;
48
49 // Called when an article that is currently under distillation is updated.
50 virtual void OnArticleUpdated(ArticleDistillationUpdate article_update) = 0;
47 }; 51 };
48 52
49 // A TaskTracker manages the various tasks related to viewing, saving, 53 // A TaskTracker manages the various tasks related to viewing, saving,
50 // distilling, and fetching an article's distilled content. 54 // distilling, and fetching an article's distilled content.
51 // 55 //
52 // There are two sources of distilled content, a Distiller and the BlobFetcher. 56 // There are two sources of distilled content, a Distiller and the BlobFetcher.
53 // At any time, at most one of each of these will be in-progress (if one 57 // At any time, at most one of each of these will be in-progress (if one
54 // finishes, the other will be cancelled). 58 // finishes, the other will be cancelled).
55 // 59 //
56 // There are also two consumers of that content, a view request and a save 60 // There are also two consumers of that content, a view request and a save
(...skipping 26 matching lines...) Expand all
83 void CancelSaveCallbacks(); 87 void CancelSaveCallbacks();
84 88
85 // The ViewerHandle should be destroyed before the ViewRequestDelegate. 89 // The ViewerHandle should be destroyed before the ViewRequestDelegate.
86 scoped_ptr<ViewerHandle> AddViewer(ViewRequestDelegate* delegate); 90 scoped_ptr<ViewerHandle> AddViewer(ViewRequestDelegate* delegate);
87 91
88 const std::string& GetEntryId() const; 92 const std::string& GetEntryId() const;
89 bool HasEntryId(const std::string& entry_id) const; 93 bool HasEntryId(const std::string& entry_id) const;
90 bool HasUrl(const GURL& url) const; 94 bool HasUrl(const GURL& url) const;
91 95
92 private: 96 private:
93 void OnDistilledDataReady( 97 void OnDistilledArticleReady(
94 scoped_ptr<DistilledArticleProto> distilled_article); 98 scoped_ptr<DistilledArticleProto> distilled_article);
99 void OnArticleDistillationUpdated(
100 const ArticleDistillationUpdate& article_update);
95 // Posts a task to run DoSaveCallbacks with |distillation_succeeded|. 101 // Posts a task to run DoSaveCallbacks with |distillation_succeeded|.
96 void ScheduleSaveCallbacks(bool distillation_succeeded); 102 void ScheduleSaveCallbacks(bool distillation_succeeded);
97 103
98 // Runs all callbacks passing |distillation_succeeded| and clears them. Should 104 // Runs all callbacks passing |distillation_succeeded| and clears them. Should
99 // be called through ScheduleSaveCallbacks. 105 // be called through ScheduleSaveCallbacks.
100 void DoSaveCallbacks(bool distillation_succeeded); 106 void DoSaveCallbacks(bool distillation_succeeded);
101 107
102 void RemoveViewer(ViewRequestDelegate* delegate); 108 void RemoveViewer(ViewRequestDelegate* delegate);
103 void NotifyViewer(ViewRequestDelegate* delegate); 109 void NotifyViewer(ViewRequestDelegate* delegate);
104 110
(...skipping 15 matching lines...) Expand all
120 // Note: This should remain the last member so it'll be destroyed and 126 // Note: This should remain the last member so it'll be destroyed and
121 // invalidate its weak pointers before any other members are destroyed. 127 // invalidate its weak pointers before any other members are destroyed.
122 base::WeakPtrFactory<TaskTracker> weak_ptr_factory_; 128 base::WeakPtrFactory<TaskTracker> weak_ptr_factory_;
123 129
124 DISALLOW_COPY_AND_ASSIGN(TaskTracker); 130 DISALLOW_COPY_AND_ASSIGN(TaskTracker);
125 }; 131 };
126 132
127 } // namespace dom_distiller 133 } // namespace dom_distiller
128 134
129 #endif // COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_ 135 #endif // COMPONENTS_DOM_DISTILLER_CORE_TASK_TRACKER_H_
OLDNEW
« no previous file with comments | « components/dom_distiller/core/fake_distiller.cc ('k') | components/dom_distiller/core/task_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698