OLD | NEW |
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 if (distiller_result->has_title()) { | 150 if (distiller_result->has_title()) { |
151 page_data->distilled_page_proto->data.set_title( | 151 page_data->distilled_page_proto->data.set_title( |
152 distiller_result->title()); | 152 distiller_result->title()); |
153 } | 153 } |
154 page_data->distilled_page_proto->data.set_url(page_url.spec()); | 154 page_data->distilled_page_proto->data.set_url(page_url.spec()); |
155 if (distiller_result->has_distilled_content() && | 155 if (distiller_result->has_distilled_content() && |
156 distiller_result->distilled_content().has_html()) { | 156 distiller_result->distilled_content().has_html()) { |
157 page_data->distilled_page_proto->data.set_html( | 157 page_data->distilled_page_proto->data.set_html( |
158 distiller_result->distilled_content().html()); | 158 distiller_result->distilled_content().html()); |
159 } | 159 } |
| 160 |
| 161 if (distiller_result->has_timing_info()) { |
| 162 const proto::TimingInfo& distiller_timing_info = |
| 163 distiller_result->timing_info(); |
| 164 DistilledPageProto::TimingInfo timing_info; |
| 165 if (distiller_timing_info.has_markup_parsing_time()) { |
| 166 timing_info.set_name("markup_parsing"); |
| 167 timing_info.set_time(distiller_timing_info.markup_parsing_time()); |
| 168 *page_data->distilled_page_proto->data.add_timing_info() = timing_info; |
| 169 } |
| 170 |
| 171 if (distiller_timing_info.has_document_construction_time()) { |
| 172 timing_info.set_name("document_construction"); |
| 173 timing_info.set_time( |
| 174 distiller_timing_info.document_construction_time()); |
| 175 *page_data->distilled_page_proto->data.add_timing_info() = timing_info; |
| 176 } |
| 177 |
| 178 if (distiller_timing_info.has_article_processing_time()) { |
| 179 timing_info.set_name("article_processing"); |
| 180 timing_info.set_time( |
| 181 distiller_timing_info.article_processing_time()); |
| 182 *page_data->distilled_page_proto->data.add_timing_info() = timing_info; |
| 183 } |
| 184 |
| 185 if (distiller_timing_info.has_formatting_time()) { |
| 186 timing_info.set_name("formatting"); |
| 187 timing_info.set_time( |
| 188 distiller_timing_info.formatting_time()); |
| 189 *page_data->distilled_page_proto->data.add_timing_info() = timing_info; |
| 190 } |
| 191 |
| 192 if (distiller_timing_info.has_total_time()) { |
| 193 timing_info.set_name("total"); |
| 194 timing_info.set_time( |
| 195 distiller_timing_info.total_time()); |
| 196 *page_data->distilled_page_proto->data.add_timing_info() = timing_info; |
| 197 } |
| 198 |
| 199 for (int i = 0; i < distiller_timing_info.other_times_size(); i++) { |
| 200 timing_info.set_name(distiller_timing_info.other_times(i).name()); |
| 201 timing_info.set_time(distiller_timing_info.other_times(i).time()); |
| 202 *page_data->distilled_page_proto->data.add_timing_info() = timing_info; |
| 203 } |
| 204 } |
| 205 |
160 if (distiller_result->has_debug_info() && | 206 if (distiller_result->has_debug_info() && |
161 distiller_result->debug_info().has_log()) { | 207 distiller_result->debug_info().has_log()) { |
162 page_data->distilled_page_proto->data.mutable_debug_info()->set_log( | 208 page_data->distilled_page_proto->data.mutable_debug_info()->set_log( |
163 distiller_result->debug_info().log()); | 209 distiller_result->debug_info().log()); |
164 } | 210 } |
165 | 211 |
166 if (distiller_result->has_text_direction()) { | 212 if (distiller_result->has_text_direction()) { |
167 page_data->distilled_page_proto->data.set_text_direction( | 213 page_data->distilled_page_proto->data.set_text_direction( |
168 distiller_result->text_direction()); | 214 distiller_result->text_direction()); |
169 } else { | 215 } else { |
170 page_data->distilled_page_proto->data.set_text_direction("auto"); | 216 page_data->distilled_page_proto->data.set_text_direction("auto"); |
171 } | 217 } |
172 | 218 |
173 if (distiller_result->has_pagination_info()) { | 219 if (distiller_result->has_pagination_info()) { |
174 proto::PaginationInfo pagination_info = | 220 const proto::PaginationInfo& pagination_info = |
175 distiller_result->pagination_info(); | 221 distiller_result->pagination_info(); |
176 if (pagination_info.has_next_page()) { | 222 if (pagination_info.has_next_page()) { |
177 GURL next_page_url(pagination_info.next_page()); | 223 GURL next_page_url(pagination_info.next_page()); |
178 if (next_page_url.is_valid()) { | 224 if (next_page_url.is_valid()) { |
179 // The pages should be in same origin. | 225 // The pages should be in same origin. |
180 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin()); | 226 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin()); |
181 AddToDistillationQueue(page_num + 1, next_page_url); | 227 AddToDistillationQueue(page_num + 1, next_page_url); |
182 page_data->distilled_page_proto->data.mutable_pagination_info()-> | 228 page_data->distilled_page_proto->data.mutable_pagination_info()-> |
183 set_next_page(next_page_url.spec()); | 229 set_next_page(next_page_url.spec()); |
184 } | 230 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 DCHECK(finished_pages_index_.empty()); | 372 DCHECK(finished_pages_index_.empty()); |
327 | 373 |
328 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_, | 374 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_, |
329 false); | 375 false); |
330 finished_cb_.Run(article_proto.Pass()); | 376 finished_cb_.Run(article_proto.Pass()); |
331 finished_cb_.Reset(); | 377 finished_cb_.Reset(); |
332 } | 378 } |
333 } | 379 } |
334 | 380 |
335 } // namespace dom_distiller | 381 } // namespace dom_distiller |
OLD | NEW |