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

Side by Side Diff: components/dom_distiller/content/renderer/distillability_agent.cc

Issue 1984853002: Record detailed breakdown of Reader Mode triggering (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/metrics/histogram.h" 5 #include "base/metrics/histogram.h"
6 6
7 #include "components/dom_distiller/content/common/distiller_messages.h" 7 #include "components/dom_distiller/content/common/distiller_messages.h"
8 #include "components/dom_distiller/content/renderer/distillability_agent.h" 8 #include "components/dom_distiller/content/renderer/distillability_agent.h"
9 #include "components/dom_distiller/core/distillable_page_detector.h" 9 #include "components/dom_distiller/core/distillable_page_detector.h"
10 #include "components/dom_distiller/core/experiments.h" 10 #include "components/dom_distiller/core/experiments.h"
11 #include "components/dom_distiller/core/page_features.h" 11 #include "components/dom_distiller/core/page_features.h"
12 #include "components/dom_distiller/core/url_utils.h" 12 #include "components/dom_distiller/core/url_utils.h"
13 #include "content/public/renderer/render_frame.h" 13 #include "content/public/renderer/render_frame.h"
14 14
15 #include "third_party/WebKit/public/platform/WebDistillability.h" 15 #include "third_party/WebKit/public/platform/WebDistillability.h"
16 #include "third_party/WebKit/public/web/WebDocument.h" 16 #include "third_party/WebKit/public/web/WebDocument.h"
17 #include "third_party/WebKit/public/web/WebElement.h" 17 #include "third_party/WebKit/public/web/WebElement.h"
18 #include "third_party/WebKit/public/web/WebLocalFrame.h" 18 #include "third_party/WebKit/public/web/WebLocalFrame.h"
19 19
20 namespace dom_distiller { 20 namespace dom_distiller {
21 21
22 using namespace blink; 22 using namespace blink;
23 23
24 namespace { 24 namespace {
25 25
26 const char* const kBlacklist[] = { 26 const char* const kBlacklist[] = {
27 "www.reddit.com" 27 "www.reddit.com"
28 }; 28 };
29 29
30 enum RejectionBuckets {
31 NOT_ARTICLE = 0,
32 MOBILE_FRIENDLY,
33 BLACKLISTED,
34 TOO_SHORT,
35 NOT_REJECTED,
36 REJECTION_BUCKET_BOUNDARY
37 };
38
30 // Returns whether it is necessary to send updates back to the browser. 39 // Returns whether it is necessary to send updates back to the browser.
31 // The number of updates can be from 0 to 2. See the tests in 40 // The number of updates can be from 0 to 2. See the tests in
32 // "distillable_page_utils_browsertest.cc". 41 // "distillable_page_utils_browsertest.cc".
33 // Most heuristics types only require one update after parsing. 42 // Most heuristics types only require one update after parsing.
34 // Adaboost is the only one doing the second update, which is after loading. 43 // Adaboost is the only one doing the second update, which is after loading.
35 bool NeedToUpdate(bool is_loaded) { 44 bool NeedToUpdate(bool is_loaded) {
36 switch (GetDistillerHeuristicsType()) { 45 switch (GetDistillerHeuristicsType()) {
37 case DistillerHeuristicsType::ALWAYS_TRUE: 46 case DistillerHeuristicsType::ALWAYS_TRUE:
38 return !is_loaded; 47 return !is_loaded;
39 case DistillerHeuristicsType::OG_ARTICLE: 48 case DistillerHeuristicsType::OG_ARTICLE:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 bool blacklisted = IsBlacklisted(parsed_url); 96 bool blacklisted = IsBlacklisted(parsed_url);
88 97
89 int bucket = static_cast<unsigned>(features.isMobileFriendly) | 98 int bucket = static_cast<unsigned>(features.isMobileFriendly) |
90 (static_cast<unsigned>(distillable) << 1); 99 (static_cast<unsigned>(distillable) << 1);
91 if (is_last) { 100 if (is_last) {
92 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterLoading", 101 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterLoading",
93 bucket, 4); 102 bucket, 4);
94 } else { 103 } else {
95 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterParsing", 104 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterParsing",
96 bucket, 4); 105 bucket, 4);
106 if (!distillable) {
107 UMA_HISTOGRAM_ENUMERATION("DomDistiller.DistillabilityRejection",
108 NOT_ARTICLE, REJECTION_BUCKET_BOUNDARY);
109 } else if (features.isMobileFriendly) {
110 UMA_HISTOGRAM_ENUMERATION("DomDistiller.DistillabilityRejection",
111 MOBILE_FRIENDLY, REJECTION_BUCKET_BOUNDARY);
112 } else if (blacklisted) {
113 UMA_HISTOGRAM_ENUMERATION("DomDistiller.DistillabilityRejection",
114 BLACKLISTED, REJECTION_BUCKET_BOUNDARY);
115 } else if (!long_article) {
116 UMA_HISTOGRAM_ENUMERATION("DomDistiller.DistillabilityRejection",
117 TOO_SHORT, REJECTION_BUCKET_BOUNDARY);
118 } else {
119 UMA_HISTOGRAM_ENUMERATION("DomDistiller.DistillabilityRejection",
120 NOT_REJECTED, REJECTION_BUCKET_BOUNDARY);
121 }
97 } 122 }
98 123
99 if (blacklisted) { 124 if (blacklisted) {
100 return false; 125 return false;
101 } 126 }
102 if (features.isMobileFriendly) { 127 if (features.isMobileFriendly) {
103 return false; 128 return false;
104 } 129 }
105 return distillable && long_article; 130 return distillable && long_article;
106 } 131 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 172
148 bool is_last = IsLast(is_loaded); 173 bool is_last = IsLast(is_loaded);
149 Send(new FrameHostMsg_Distillability(routing_id(), 174 Send(new FrameHostMsg_Distillability(routing_id(),
150 IsDistillablePage(doc, is_last), is_last)); 175 IsDistillablePage(doc, is_last), is_last));
151 } 176 }
152 177
153 178
154 DistillabilityAgent::~DistillabilityAgent() {} 179 DistillabilityAgent::~DistillabilityAgent() {}
155 180
156 } // namespace dom_distiller 181 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698