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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ready_ = false; | 66 ready_ = false; |
67 distiller_page_callback_ = callback; | 67 distiller_page_callback_ = callback; |
68 DistillPageImpl(gurl, GetDistillerScriptWithOptions(options)); | 68 DistillPageImpl(gurl, GetDistillerScriptWithOptions(options)); |
69 } | 69 } |
70 | 70 |
71 void DistillerPage::OnDistillationDone(const GURL& page_url, | 71 void DistillerPage::OnDistillationDone(const GURL& page_url, |
72 const base::Value* value) { | 72 const base::Value* value) { |
73 DCHECK(!ready_); | 73 DCHECK(!ready_); |
74 ready_ = true; | 74 ready_ = true; |
75 | 75 |
76 scoped_ptr<dom_distiller::proto::DomDistillerResult> distiller_result; | 76 scoped_ptr<dom_distiller::proto::DomDistillerResult> distiller_result( |
77 | 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 = true; | 82 found_content = |
83 distiller_result.reset(new dom_distiller::proto::DomDistillerResult( | 83 dom_distiller::proto::json::DomDistillerResult::ReadFromValue( |
84 dom_distiller::proto::json::DomDistillerResult::ReadFromValue(value))); | 84 value, distiller_result.get()); |
85 if (distiller_result->has_timing_info()) { | 85 if (!found_content) { |
| 86 DVLOG(1) << "Unable to parse DomDistillerResult."; |
| 87 } else if (distiller_result->has_timing_info()) { |
86 const dom_distiller::proto::TimingInfo& timing = | 88 const dom_distiller::proto::TimingInfo& timing = |
87 distiller_result->timing_info(); | 89 distiller_result->timing_info(); |
88 if (timing.has_markup_parsing_time()) { | 90 if (timing.has_markup_parsing_time()) { |
89 UMA_HISTOGRAM_TIMES( | 91 UMA_HISTOGRAM_TIMES( |
90 "DomDistiller.Time.MarkupParsing", | 92 "DomDistiller.Time.MarkupParsing", |
91 base::TimeDelta::FromMillisecondsD(timing.markup_parsing_time())); | 93 base::TimeDelta::FromMillisecondsD(timing.markup_parsing_time())); |
92 } | 94 } |
93 if (timing.has_document_construction_time()) { | 95 if (timing.has_document_construction_time()) { |
94 UMA_HISTOGRAM_TIMES( | 96 UMA_HISTOGRAM_TIMES( |
95 "DomDistiller.Time.DocumentConstruction", | 97 "DomDistiller.Time.DocumentConstruction", |
(...skipping 20 matching lines...) Expand all Loading... |
116 } | 118 } |
117 | 119 |
118 base::MessageLoop::current()->PostTask( | 120 base::MessageLoop::current()->PostTask( |
119 FROM_HERE, | 121 FROM_HERE, |
120 base::Bind(distiller_page_callback_, | 122 base::Bind(distiller_page_callback_, |
121 base::Passed(&distiller_result), | 123 base::Passed(&distiller_result), |
122 found_content)); | 124 found_content)); |
123 } | 125 } |
124 | 126 |
125 } // namespace dom_distiller | 127 } // namespace dom_distiller |
OLD | NEW |