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

Side by Side Diff: components/dom_distiller/core/distiller.cc

Issue 167963003: Support for distilling prior pages in an article. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | components/dom_distiller/core/distiller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/dom_distiller/core/distiller.h" 5 #include "components/dom_distiller/core/distiller.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 current_page->set_url(page_url.spec()); 144 current_page->set_url(page_url.spec());
145 current_page->set_html(distilled_page->html); 145 current_page->set_html(distilled_page->html);
146 146
147 GURL next_page_url(distilled_page->next_page_url); 147 GURL next_page_url(distilled_page->next_page_url);
148 if (next_page_url.is_valid()) { 148 if (next_page_url.is_valid()) {
149 // The pages should be in same origin. 149 // The pages should be in same origin.
150 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin()); 150 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin());
151 AddToDistillationQueue(page_num + 1, next_page_url); 151 AddToDistillationQueue(page_num + 1, next_page_url);
152 } 152 }
153 153
154 GURL prev_page_url(distilled_page->prev_page_url);
155 if (prev_page_url.is_valid()) {
156 DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin());
157 AddToDistillationQueue(page_num - 1, prev_page_url);
158 }
159
154 for (size_t img_num = 0; img_num < distilled_page->image_urls.size(); 160 for (size_t img_num = 0; img_num < distilled_page->image_urls.size();
155 ++img_num) { 161 ++img_num) {
156 std::string image_id = 162 std::string image_id =
157 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num); 163 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num);
158 FetchImage(page_num, image_id, distilled_page->image_urls[img_num]); 164 FetchImage(page_num, image_id, distilled_page->image_urls[img_num]);
159 } 165 }
160 166
161 AddPageIfDone(page_num); 167 AddPageIfDone(page_num);
162 DistillNextPage(); 168 DistillNextPage();
163 } else { 169 } else {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 max_pages_in_article_); 251 max_pages_in_article_);
246 252
247 DCHECK(pages_.empty()); 253 DCHECK(pages_.empty());
248 DCHECK(finished_pages_index_.empty()); 254 DCHECK(finished_pages_index_.empty());
249 distillation_cb_.Run(article_proto.Pass()); 255 distillation_cb_.Run(article_proto.Pass());
250 distillation_cb_.Reset(); 256 distillation_cb_.Reset();
251 } 257 }
252 } 258 }
253 259
254 } // namespace dom_distiller 260 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « no previous file | components/dom_distiller/core/distiller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698