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" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 new dom_distiller::proto::DomDistillerResult()); | 77 new dom_distiller::proto::DomDistillerResult()); |
78 bool found_content; | 78 bool found_content; |
79 if (value->IsType(base::Value::TYPE_NULL)) { | 79 if (value->IsType(base::Value::TYPE_NULL)) { |
80 found_content = false; | 80 found_content = false; |
81 } else { | 81 } else { |
82 found_content = | 82 found_content = |
83 dom_distiller::proto::json::DomDistillerResult::ReadFromValue( | 83 dom_distiller::proto::json::DomDistillerResult::ReadFromValue( |
84 value, distiller_result.get()); | 84 value, distiller_result.get()); |
85 if (!found_content) { | 85 if (!found_content) { |
86 DVLOG(1) << "Unable to parse DomDistillerResult."; | 86 DVLOG(1) << "Unable to parse DomDistillerResult."; |
87 } else if (distiller_result->has_timing_info()) { | 87 } else { |
88 const dom_distiller::proto::TimingInfo& timing = | 88 if (distiller_result->has_timing_info()) { |
89 distiller_result->timing_info(); | 89 const dom_distiller::proto::TimingInfo& timing = |
90 if (timing.has_markup_parsing_time()) { | 90 distiller_result->timing_info(); |
91 UMA_HISTOGRAM_TIMES( | 91 if (timing.has_markup_parsing_time()) { |
92 "DomDistiller.Time.MarkupParsing", | 92 UMA_HISTOGRAM_TIMES( |
93 base::TimeDelta::FromMillisecondsD(timing.markup_parsing_time())); | 93 "DomDistiller.Time.MarkupParsing", |
| 94 base::TimeDelta::FromMillisecondsD(timing.markup_parsing_time())); |
| 95 } |
| 96 if (timing.has_document_construction_time()) { |
| 97 UMA_HISTOGRAM_TIMES( |
| 98 "DomDistiller.Time.DocumentConstruction", |
| 99 base::TimeDelta::FromMillisecondsD( |
| 100 timing.document_construction_time())); |
| 101 } |
| 102 if (timing.has_article_processing_time()) { |
| 103 UMA_HISTOGRAM_TIMES( |
| 104 "DomDistiller.Time.ArticleProcessing", |
| 105 base::TimeDelta::FromMillisecondsD( |
| 106 timing.article_processing_time())); |
| 107 } |
| 108 if (timing.has_formatting_time()) { |
| 109 UMA_HISTOGRAM_TIMES( |
| 110 "DomDistiller.Time.Formatting", |
| 111 base::TimeDelta::FromMillisecondsD(timing.formatting_time())); |
| 112 } |
| 113 if (timing.has_total_time()) { |
| 114 UMA_HISTOGRAM_TIMES( |
| 115 "DomDistiller.Time.DistillationTotal", |
| 116 base::TimeDelta::FromMillisecondsD(timing.total_time())); |
| 117 } |
94 } | 118 } |
95 if (timing.has_document_construction_time()) { | 119 if (distiller_result->has_statistics_info()) { |
96 UMA_HISTOGRAM_TIMES( | 120 const dom_distiller::proto::StatisticsInfo& statistics = |
97 "DomDistiller.Time.DocumentConstruction", | 121 distiller_result->statistics_info(); |
98 base::TimeDelta::FromMillisecondsD( | 122 if (statistics.has_word_count()) { |
99 timing.document_construction_time())); | 123 UMA_HISTOGRAM_CUSTOM_COUNTS( |
100 } | 124 "DomDistiller.Statistics.WordCount", |
101 if (timing.has_article_processing_time()) { | 125 statistics.word_count(), |
102 UMA_HISTOGRAM_TIMES( | 126 1, 4000, 50); |
103 "DomDistiller.Time.ArticleProcessing", | 127 } |
104 base::TimeDelta::FromMillisecondsD( | |
105 timing.article_processing_time())); | |
106 } | |
107 if (timing.has_formatting_time()) { | |
108 UMA_HISTOGRAM_TIMES( | |
109 "DomDistiller.Time.Formatting", | |
110 base::TimeDelta::FromMillisecondsD(timing.formatting_time())); | |
111 } | |
112 if (timing.has_total_time()) { | |
113 UMA_HISTOGRAM_TIMES( | |
114 "DomDistiller.Time.DistillationTotal", | |
115 base::TimeDelta::FromMillisecondsD(timing.total_time())); | |
116 } | 128 } |
117 } | 129 } |
118 } | 130 } |
119 | 131 |
120 base::MessageLoop::current()->PostTask( | 132 base::MessageLoop::current()->PostTask( |
121 FROM_HERE, | 133 FROM_HERE, |
122 base::Bind(distiller_page_callback_, | 134 base::Bind(distiller_page_callback_, |
123 base::Passed(&distiller_result), | 135 base::Passed(&distiller_result), |
124 found_content)); | 136 found_content)); |
125 } | 137 } |
126 | 138 |
127 } // namespace dom_distiller | 139 } // namespace dom_distiller |
OLD | NEW |