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

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

Issue 1575473002: Improve syncing between dom distiller and the print preview request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: expanded internal new api doc, some adjustments to the feature's internal mechanism Created 4 years, 10 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
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_DOM_DISTILLER_SERVICE_H_ 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ 6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 // Request to view an article by url. 86 // Request to view an article by url.
87 // Use CreateDefaultDistillerPage() to create a default |distiller_page|. 87 // Use CreateDefaultDistillerPage() to create a default |distiller_page|.
88 // The provided |distiller_page| is only used if there is not already a 88 // The provided |distiller_page| is only used if there is not already a
89 // distillation task in progress for the given |url|. 89 // distillation task in progress for the given |url|.
90 virtual scoped_ptr<ViewerHandle> ViewUrl( 90 virtual scoped_ptr<ViewerHandle> ViewUrl(
91 ViewRequestDelegate* delegate, 91 ViewRequestDelegate* delegate,
92 scoped_ptr<DistillerPage> distiller_page, 92 scoped_ptr<DistillerPage> distiller_page,
93 const GURL& url) = 0; 93 const GURL& url) = 0;
94 94
95 // Adds |delegate| to the provided |url| task tracker.
96 // If the given |url| has no task tracker (i.e. has no current
97 // distillation request underway), this will return nullptr - therefore
98 // this should only be called after previously requesting a distillation.
99
100 // If the inclusion of |delegate| on the |url| task tracker was
101 // successful, returns a |ViewerHandle| from the task tracker. This
102 // |ViewerHandle| can be held by client code as long as it wants to
103 // receive callbacks as a |ViewRequestDelegate|.
104
105 // Upon successful inclusion (i.e. a |ViewerHandle| was returned),
106 // the following holds:
107 //
108 // 1) client code will get all future OnArticleUpdated() callbacks for
109 // as long as the distillation process is running.
110 //
111 // 2) client code will get at least the OnArticleFinished()
112 // callback, considering:
113 // 2.a) If the article distillation is not finished yet, the
114 // callback will trigger at the same time as when the original
115 // distillation request gets it.
116 // 2.b) Client code will immediately get this callback after adding
117 // the viewer. If the original distillation request has already
118 // gotten this callback, it has also previously posted it
119 // to a valid standing task tracker.
120
121 // If the inclusion was not successful (i.e. this function
122 // returned nullptr), client code will not get any callbacks.
123 virtual scoped_ptr<ViewerHandle> AddViewRequestDelegate(
124 ViewRequestDelegate* delegate,
125 const GURL& url) = 0;
126
95 // Creates a default DistillerPage. 127 // Creates a default DistillerPage.
96 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage( 128 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage(
97 const gfx::Size& render_view_size) = 0; 129 const gfx::Size& render_view_size) = 0;
98 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( 130 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
99 scoped_ptr<SourcePageHandle> handle) = 0; 131 scoped_ptr<SourcePageHandle> handle) = 0;
100 132
101 virtual void AddObserver(DomDistillerObserver* observer) = 0; 133 virtual void AddObserver(DomDistillerObserver* observer) = 0;
102 virtual void RemoveObserver(DomDistillerObserver* observer) = 0; 134 virtual void RemoveObserver(DomDistillerObserver* observer) = 0;
103 135
104 // Returns the DistilledPagePrefs owned by the instance of 136 // Returns the DistilledPagePrefs owned by the instance of
(...skipping 25 matching lines...) Expand all
130 bool HasEntry(const std::string& entry_id) override; 162 bool HasEntry(const std::string& entry_id) override;
131 std::string GetUrlForEntry(const std::string& entry_id) override; 163 std::string GetUrlForEntry(const std::string& entry_id) override;
132 std::vector<ArticleEntry> GetEntries() const override; 164 std::vector<ArticleEntry> GetEntries() const override;
133 scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id) override; 165 scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id) override;
134 scoped_ptr<ViewerHandle> ViewEntry(ViewRequestDelegate* delegate, 166 scoped_ptr<ViewerHandle> ViewEntry(ViewRequestDelegate* delegate,
135 scoped_ptr<DistillerPage> distiller_page, 167 scoped_ptr<DistillerPage> distiller_page,
136 const std::string& entry_id) override; 168 const std::string& entry_id) override;
137 scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate, 169 scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate,
138 scoped_ptr<DistillerPage> distiller_page, 170 scoped_ptr<DistillerPage> distiller_page,
139 const GURL& url) override; 171 const GURL& url) override;
172 scoped_ptr<ViewerHandle> AddViewRequestDelegate(ViewRequestDelegate* delegate,
173 const GURL& url) override;
140 scoped_ptr<DistillerPage> CreateDefaultDistillerPage( 174 scoped_ptr<DistillerPage> CreateDefaultDistillerPage(
141 const gfx::Size& render_view_size) override; 175 const gfx::Size& render_view_size) override;
142 scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( 176 scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
143 scoped_ptr<SourcePageHandle> handle) override; 177 scoped_ptr<SourcePageHandle> handle) override;
144 void AddObserver(DomDistillerObserver* observer) override; 178 void AddObserver(DomDistillerObserver* observer) override;
145 void RemoveObserver(DomDistillerObserver* observer) override; 179 void RemoveObserver(DomDistillerObserver* observer) override;
146 DistilledPagePrefs* GetDistilledPagePrefs() override; 180 DistilledPagePrefs* GetDistilledPagePrefs() override;
147 181
148 private: 182 private:
149 void CancelTask(TaskTracker* task); 183 void CancelTask(TaskTracker* task);
(...skipping 24 matching lines...) Expand all
174 208
175 typedef ScopedVector<TaskTracker> TaskList; 209 typedef ScopedVector<TaskTracker> TaskList;
176 TaskList tasks_; 210 TaskList tasks_;
177 211
178 DISALLOW_COPY_AND_ASSIGN(DomDistillerService); 212 DISALLOW_COPY_AND_ASSIGN(DomDistillerService);
179 }; 213 };
180 214
181 } // namespace dom_distiller 215 } // namespace dom_distiller
182 216
183 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ 217 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698