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

Unified Diff: components/dom_distiller/core/distiller.cc

Issue 493853006: Remove DistilledPageInfo and related structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed bool-issue and changed from EXPECT_EQ to ASSERT_EQ for page size Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/core/distiller.cc
diff --git a/components/dom_distiller/core/distiller.cc b/components/dom_distiller/core/distiller.cc
index 472b45361881b29c2f25b66210d88d058de50f6c..c4c33bf5724ad26c04534c7e1f22053ad8a41733 100644
--- a/components/dom_distiller/core/distiller.cc
+++ b/components/dom_distiller/core/distiller.cc
@@ -135,9 +135,9 @@ void DistillerImpl::DistillNextPage() {
void DistillerImpl::OnPageDistillationFinished(
int page_num,
const GURL& page_url,
- scoped_ptr<DistilledPageInfo> distilled_page,
+ scoped_ptr<proto::DomDistillerResult> distiller_result,
bool distillation_successful) {
- DCHECK(distilled_page.get());
+ DCHECK(distiller_result.get());
DCHECK(started_pages_index_.find(page_num) != started_pages_index_.end());
if (distillation_successful) {
DistilledPageData* page_data =
@@ -145,28 +145,43 @@ void DistillerImpl::OnPageDistillationFinished(
page_data->distilled_page_proto =
new base::RefCountedData<DistilledPageProto>();
page_data->page_num = page_num;
- page_data->distilled_page_proto->data.set_title(distilled_page->title);
+ if (distiller_result->has_title()) {
+ page_data->distilled_page_proto->data.set_title(
+ distiller_result->title());
+ }
page_data->distilled_page_proto->data.set_url(page_url.spec());
- page_data->distilled_page_proto->data.set_html(distilled_page->html);
-
- GURL next_page_url(distilled_page->next_page_url);
- if (next_page_url.is_valid()) {
- // The pages should be in same origin.
- DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin());
- AddToDistillationQueue(page_num + 1, next_page_url);
+ if (distiller_result->has_distilled_content() &&
+ distiller_result->distilled_content().has_html()) {
+ page_data->distilled_page_proto->data.set_html(
+ distiller_result->distilled_content().html());
}
- GURL prev_page_url(distilled_page->prev_page_url);
- if (prev_page_url.is_valid()) {
- DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin());
- AddToDistillationQueue(page_num - 1, prev_page_url);
+ if (distiller_result->has_pagination_info()) {
+ proto::PaginationInfo pagination_info =
+ distiller_result->pagination_info();
+ if (pagination_info.has_next_page()) {
+ GURL next_page_url(pagination_info.next_page());
+ if (next_page_url.is_valid()) {
+ // The pages should be in same origin.
+ DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin());
+ AddToDistillationQueue(page_num + 1, next_page_url);
+ }
+ }
+
+ if (pagination_info.has_prev_page()) {
+ GURL prev_page_url(pagination_info.prev_page());
+ if (prev_page_url.is_valid()) {
+ DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin());
+ AddToDistillationQueue(page_num - 1, prev_page_url);
+ }
+ }
}
- for (size_t img_num = 0; img_num < distilled_page->image_urls.size();
+ for (int img_num = 0; img_num < distiller_result->image_urls_size();
++img_num) {
std::string image_id =
base::IntToString(page_num + 1) + "_" + base::IntToString(img_num);
- FetchImage(page_num, image_id, distilled_page->image_urls[img_num]);
+ FetchImage(page_num, image_id, distiller_result->image_urls(img_num));
}
AddPageIfDone(page_num);

Powered by Google App Engine
This is Rietveld 408576698