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

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: 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 page_data->title = distilled_page->title; 142 page_data->title = distilled_page->title;
143 143
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 } 151 }
152 GURL prev_page_url(distilled_page->prev_page_url);
153 if (prev_page_url.is_valid()) {
154 DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin());
155 }
152 156
153 for (size_t img_num = 0; img_num < distilled_page->image_urls.size(); 157 for (size_t img_num = 0; img_num < distilled_page->image_urls.size();
154 ++img_num) { 158 ++img_num) {
155 std::string image_id = 159 std::string image_id =
156 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num); 160 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num);
157 FetchImage(page_num, image_id, distilled_page->image_urls[img_num]); 161 FetchImage(page_num, image_id, distilled_page->image_urls[img_num]);
158 } 162 }
159 163
164 AddToDistillationQueue(page_num - 1, prev_page_url);
cjhopman 2014/02/15 02:45:53 nit: this could be done in the prev_page_url.is_va
shashi 2014/02/17 03:43:20 Done.
160 AddToDistillationQueue(page_num + 1, next_page_url); 165 AddToDistillationQueue(page_num + 1, next_page_url);
161 AddPageIfDone(page_num); 166 AddPageIfDone(page_num);
162 DistillNextPage(); 167 DistillNextPage();
163 } else { 168 } else {
164 started_pages_index_.erase(page_num); 169 started_pages_index_.erase(page_num);
165 RunDistillerCallbackIfDone(); 170 RunDistillerCallbackIfDone();
166 } 171 }
167 } 172 }
168 173
169 void DistillerImpl::FetchImage(int page_num, 174 void DistillerImpl::FetchImage(int page_num,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 max_pages_in_article_); 250 max_pages_in_article_);
246 251
247 DCHECK(pages_.empty()); 252 DCHECK(pages_.empty());
248 DCHECK(finished_pages_index_.empty()); 253 DCHECK(finished_pages_index_.empty());
249 distillation_cb_.Run(article_proto.Pass()); 254 distillation_cb_.Run(article_proto.Pass());
250 distillation_cb_.Reset(); 255 distillation_cb_.Reset();
251 } 256 }
252 } 257 }
253 258
254 } // namespace dom_distiller 259 } // 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