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

Side by Side 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: 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 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 #include "components/dom_distiller/core/distiller.h" 5 #include "components/dom_distiller/core/distiller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 base::Bind(&DistillerImpl::OnPageDistillationFinished, 128 base::Bind(&DistillerImpl::OnPageDistillationFinished,
129 weak_factory_.GetWeakPtr(), 129 weak_factory_.GetWeakPtr(),
130 page_num, 130 page_num,
131 url)); 131 url));
132 } 132 }
133 } 133 }
134 134
135 void DistillerImpl::OnPageDistillationFinished( 135 void DistillerImpl::OnPageDistillationFinished(
136 int page_num, 136 int page_num,
137 const GURL& page_url, 137 const GURL& page_url,
138 scoped_ptr<DistilledPageInfo> distilled_page, 138 scoped_ptr<proto::DomDistillerResult> distiller_result,
139 bool distillation_successful) { 139 bool distillation_successful) {
140 DCHECK(distilled_page.get()); 140 DCHECK(distiller_result.get());
141 DCHECK(started_pages_index_.find(page_num) != started_pages_index_.end()); 141 DCHECK(started_pages_index_.find(page_num) != started_pages_index_.end());
142 if (distillation_successful) { 142 if (distillation_successful) {
143 DistilledPageData* page_data = 143 DistilledPageData* page_data =
144 GetPageAtIndex(started_pages_index_[page_num]); 144 GetPageAtIndex(started_pages_index_[page_num]);
145 page_data->distilled_page_proto = 145 page_data->distilled_page_proto =
146 new base::RefCountedData<DistilledPageProto>(); 146 new base::RefCountedData<DistilledPageProto>();
147 page_data->page_num = page_num; 147 page_data->page_num = page_num;
148 page_data->distilled_page_proto->data.set_title(distilled_page->title); 148 if (distiller_result->has_title()) {
149 page_data->distilled_page_proto->data.set_title(
150 distiller_result->title());
151 }
149 page_data->distilled_page_proto->data.set_url(page_url.spec()); 152 page_data->distilled_page_proto->data.set_url(page_url.spec());
150 page_data->distilled_page_proto->data.set_html(distilled_page->html); 153 if (distiller_result->has_distilled_content() &&
151 154 distiller_result->distilled_content().has_html()) {
152 GURL next_page_url(distilled_page->next_page_url); 155 page_data->distilled_page_proto->data.set_html(
153 if (next_page_url.is_valid()) { 156 distiller_result->distilled_content().html());
154 // The pages should be in same origin.
155 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin());
156 AddToDistillationQueue(page_num + 1, next_page_url);
157 } 157 }
158 158
159 GURL prev_page_url(distilled_page->prev_page_url); 159 if (distiller_result->has_pagination_info()) {
160 if (prev_page_url.is_valid()) { 160 proto::PaginationInfo pagination_info =
161 DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin()); 161 distiller_result->pagination_info();
162 AddToDistillationQueue(page_num - 1, prev_page_url); 162 if (pagination_info.has_next_page()) {
163 GURL next_page_url(pagination_info.next_page());
164 if (next_page_url.is_valid()) {
165 // The pages should be in same origin.
166 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin());
167 AddToDistillationQueue(page_num + 1, next_page_url);
168 }
169 }
170
171 if (pagination_info.has_prev_page()) {
172 GURL prev_page_url(pagination_info.prev_page());
173 if (prev_page_url.is_valid()) {
174 DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin());
175 AddToDistillationQueue(page_num - 1, prev_page_url);
176 }
177 }
163 } 178 }
164 179
165 for (size_t img_num = 0; img_num < distilled_page->image_urls.size(); 180 for (int img_num = 0; img_num < distiller_result->image_urls_size();
166 ++img_num) { 181 ++img_num) {
167 std::string image_id = 182 std::string image_id =
168 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num); 183 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num);
169 FetchImage(page_num, image_id, distilled_page->image_urls[img_num]); 184 FetchImage(page_num, image_id, distiller_result->image_urls(img_num));
170 } 185 }
171 186
172 AddPageIfDone(page_num); 187 AddPageIfDone(page_num);
173 DistillNextPage(); 188 DistillNextPage();
174 } else { 189 } else {
175 started_pages_index_.erase(page_num); 190 started_pages_index_.erase(page_num);
176 RunDistillerCallbackIfDone(); 191 RunDistillerCallbackIfDone();
177 } 192 }
178 } 193 }
179 194
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 DCHECK(finished_pages_index_.empty()); 300 DCHECK(finished_pages_index_.empty());
286 301
287 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_, 302 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_,
288 false); 303 false);
289 finished_cb_.Run(article_proto.Pass()); 304 finished_cb_.Run(article_proto.Pass());
290 finished_cb_.Reset(); 305 finished_cb_.Reset();
291 } 306 }
292 } 307 }
293 308
294 } // namespace dom_distiller 309 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698