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_page.h" | 5 #include "components/dom_distiller/core/distiller_page.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/metrics/histogram.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/time/time.h" |
13 #include "grit/component_resources.h" | 15 #include "grit/component_resources.h" |
14 #include "third_party/dom_distiller_js/dom_distiller.pb.h" | 16 #include "third_party/dom_distiller_js/dom_distiller.pb.h" |
15 #include "third_party/dom_distiller_js/dom_distiller_json_converter.h" | 17 #include "third_party/dom_distiller_js/dom_distiller_json_converter.h" |
16 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
17 #include "url/gurl.h" | 19 #include "url/gurl.h" |
18 | 20 |
19 namespace dom_distiller { | 21 namespace dom_distiller { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 src_markup_info.images(i); | 132 src_markup_info.images(i); |
131 DistilledPageInfo::MarkupImage dst_image; | 133 DistilledPageInfo::MarkupImage dst_image; |
132 dst_image.url = src_image.url(); | 134 dst_image.url = src_image.url(); |
133 dst_image.secure_url = src_image.secure_url(); | 135 dst_image.secure_url = src_image.secure_url(); |
134 dst_image.type = src_image.type(); | 136 dst_image.type = src_image.type(); |
135 dst_image.caption = src_image.caption(); | 137 dst_image.caption = src_image.caption(); |
136 dst_image.width = src_image.width(); | 138 dst_image.width = src_image.width(); |
137 dst_image.height = src_image.height(); | 139 dst_image.height = src_image.height(); |
138 dst_markup_info.images.push_back(dst_image); | 140 dst_markup_info.images.push_back(dst_image); |
139 } | 141 } |
| 142 if (distiller_result.has_timing_info()) { |
| 143 const dom_distiller::proto::TimingInfo& timing = |
| 144 distiller_result.timing_info(); |
| 145 if (timing.has_markup_parsing_time()) { |
| 146 UMA_HISTOGRAM_TIMES( |
| 147 "DomDistiller.Time.MarkupParsing", |
| 148 base::TimeDelta::FromMillisecondsD(timing.markup_parsing_time())); |
| 149 } |
| 150 if (timing.has_document_construction_time()) { |
| 151 UMA_HISTOGRAM_TIMES( |
| 152 "DomDistiller.Time.DocumentConstruction", |
| 153 base::TimeDelta::FromMillisecondsD( |
| 154 timing.document_construction_time())); |
| 155 } |
| 156 if (timing.has_article_processing_time()) { |
| 157 UMA_HISTOGRAM_TIMES( |
| 158 "DomDistiller.Time.ArticleProcessing", |
| 159 base::TimeDelta::FromMillisecondsD( |
| 160 timing.article_processing_time())); |
| 161 } |
| 162 if (timing.has_formatting_time()) { |
| 163 UMA_HISTOGRAM_TIMES( |
| 164 "DomDistiller.Time.Formatting", |
| 165 base::TimeDelta::FromMillisecondsD(timing.formatting_time())); |
| 166 } |
| 167 if (timing.has_total_time()) { |
| 168 UMA_HISTOGRAM_TIMES( |
| 169 "DomDistiller.Time.DistillationTotal", |
| 170 base::TimeDelta::FromMillisecondsD(timing.total_time())); |
| 171 } |
| 172 } |
140 } | 173 } |
141 | 174 |
142 base::MessageLoop::current()->PostTask( | 175 base::MessageLoop::current()->PostTask( |
143 FROM_HERE, | 176 FROM_HERE, |
144 base::Bind( | 177 base::Bind( |
145 distiller_page_callback_, base::Passed(&page_info), found_content)); | 178 distiller_page_callback_, base::Passed(&page_info), found_content)); |
146 } | 179 } |
147 | 180 |
148 } // namespace dom_distiller | 181 } // namespace dom_distiller |
OLD | NEW |