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

Side by Side Diff: third_party/WebKit/Source/core/frame/HostsUsingFeatures.cpp

Issue 2057153002: Add GetUserMedia ETLD+1 rappor metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change approach to use per-document instead of per-call stats, update metric names Created 4 years, 6 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
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 "core/frame/HostsUsingFeatures.h" 5 #include "core/frame/HostsUsingFeatures.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/frame/LocalDOMWindow.h" 9 #include "core/frame/LocalDOMWindow.h"
10 #include "core/page/Page.h" 10 #include "core/page/Page.h"
11 #include "platform/weborigin/KURL.h"
11 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 HostsUsingFeatures::~HostsUsingFeatures() 16 HostsUsingFeatures::~HostsUsingFeatures()
16 { 17 {
17 updateMeasurementsAndClear(); 18 updateMeasurementsAndClear();
18 } 19 }
19 20
20 HostsUsingFeatures::Value::Value() 21 HostsUsingFeatures::Value::Value()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 69 }
69 70
70 void HostsUsingFeatures::countName(Feature feature, const String& name) 71 void HostsUsingFeatures::countName(Feature feature, const String& name)
71 { 72 {
72 auto result = m_valueByName.add(name, Value()); 73 auto result = m_valueByName.add(name, Value());
73 result.storedValue->value.count(feature); 74 result.storedValue->value.count(feature);
74 } 75 }
75 76
76 void HostsUsingFeatures::clear() 77 void HostsUsingFeatures::clear()
77 { 78 {
78 m_hostAndValues.clear(); 79 m_urlAndValues.clear();
79 m_valueByName.clear(); 80 m_valueByName.clear();
80 } 81 }
81 82
82 void HostsUsingFeatures::documentDetached(Document& document) 83 void HostsUsingFeatures::documentDetached(Document& document)
83 { 84 {
84 HostsUsingFeatures::Value counter = document.HostsUsingFeaturesValue(); 85 HostsUsingFeatures::Value counter = document.HostsUsingFeaturesValue();
85 if (counter.isEmpty()) 86 if (counter.isEmpty())
86 return; 87 return;
87 88
88 const KURL& url = document.url(); 89 const KURL& url = document.url();
89 if (!url.protocolIsInHTTPFamily()) 90 if (!url.protocolIsInHTTPFamily())
90 return; 91 return;
91 92
92 m_hostAndValues.append(std::make_pair(url.host(), counter)); 93 m_urlAndValues.append(std::make_pair(url.getString(), counter));
jww 2016/06/11 18:43:20 nit: Per my comment in HostsUsingFeatures.h, I'd p
Guido Urdaneta 2016/06/12 11:06:22 Done.
93 document.HostsUsingFeaturesValue().clear(); 94 document.HostsUsingFeaturesValue().clear();
94 DCHECK(document.HostsUsingFeaturesValue().isEmpty()); 95 DCHECK(document.HostsUsingFeaturesValue().isEmpty());
95 } 96 }
96 97
97 void HostsUsingFeatures::updateMeasurementsAndClear() 98 void HostsUsingFeatures::updateMeasurementsAndClear()
98 { 99 {
99 if (!m_hostAndValues.isEmpty()) 100 if (!m_urlAndValues.isEmpty())
100 recordHostToRappor(); 101 recordURLToRappor();
101 if (!m_valueByName.isEmpty()) 102 if (!m_valueByName.isEmpty())
102 recordNamesToRappor(); 103 recordNamesToRappor();
103 } 104 }
104 105
105 void HostsUsingFeatures::recordHostToRappor() 106 void HostsUsingFeatures::recordURLToRappor()
106 { 107 {
107 DCHECK(!m_hostAndValues.isEmpty()); 108 DCHECK(!m_urlAndValues.isEmpty());
108 109
109 // Aggregate values by hosts. 110 // Aggregate values by URLs.
110 HashMap<String, HostsUsingFeatures::Value> aggregatedByHost; 111 HashMap<String, HostsUsingFeatures::Value> aggregatedByHost;
jww 2016/06/11 18:43:20 Things are a bit confused here, as represented by
Guido Urdaneta 2016/06/12 11:06:22 Fixed. Now there are separate functions to aggrega
111 for (const auto& hostAndValue : m_hostAndValues) { 112 for (const auto& urlAndValue : m_urlAndValues) {
112 DCHECK(!hostAndValue.first.isEmpty()); 113 DCHECK(!urlAndValue.first.isEmpty());
113 auto result = aggregatedByHost.add(hostAndValue.first, hostAndValue.seco nd); 114 auto result = aggregatedByHost.add(urlAndValue.first, urlAndValue.second );
114 if (!result.isNewEntry) 115 if (!result.isNewEntry)
115 result.storedValue->value.aggregate(hostAndValue.second); 116 result.storedValue->value.aggregate(urlAndValue.second);
116 } 117 }
117 118
118 // Report to RAPPOR. 119 // Report to RAPPOR.
119 for (auto& hostAndValue : aggregatedByHost) 120 for (auto& urlAndValue : aggregatedByHost)
120 hostAndValue.value.recordHostToRappor(hostAndValue.key); 121 urlAndValue.value.recordURLToRappor(KURL(ParsedURLString, urlAndValue.ke y));
121 122
122 m_hostAndValues.clear(); 123 m_urlAndValues.clear();
123 } 124 }
124 125
125 void HostsUsingFeatures::recordNamesToRappor() 126 void HostsUsingFeatures::recordNamesToRappor()
126 { 127 {
127 DCHECK(!m_valueByName.isEmpty()); 128 DCHECK(!m_valueByName.isEmpty());
128 129
129 for (auto& nameAndValue : m_valueByName) 130 for (auto& nameAndValue : m_valueByName)
130 nameAndValue.value.recordNameToRappor(nameAndValue.key); 131 nameAndValue.value.recordNameToRappor(nameAndValue.key);
131 132
132 m_valueByName.clear(); 133 m_valueByName.clear();
133 } 134 }
134 135
135 void HostsUsingFeatures::Value::aggregate(HostsUsingFeatures::Value other) 136 void HostsUsingFeatures::Value::aggregate(HostsUsingFeatures::Value other)
136 { 137 {
137 m_countBits |= other.m_countBits; 138 m_countBits |= other.m_countBits;
138 } 139 }
139 140
140 void HostsUsingFeatures::Value::recordHostToRappor(const String& host) 141 void HostsUsingFeatures::Value::recordURLToRappor(const KURL& url)
jww 2016/06/11 18:43:21 See my comments above in recordURLToRappor(), but
Guido Urdaneta 2016/06/12 11:06:22 Done.
141 { 142 {
142 if (get(Feature::ElementCreateShadowRoot)) 143 if (get(Feature::ElementCreateShadowRoot))
143 Platform::current()->recordRappor("WebComponents.ElementCreateShadowRoot ", host); 144 Platform::current()->recordRappor("WebComponents.ElementCreateShadowRoot ", url.host());
144 if (get(Feature::ElementAttachShadow)) 145 if (get(Feature::ElementAttachShadow))
145 Platform::current()->recordRappor("WebComponents.ElementAttachShadow", h ost); 146 Platform::current()->recordRappor("WebComponents.ElementAttachShadow", u rl.host());
146 if (get(Feature::DocumentRegisterElement)) 147 if (get(Feature::DocumentRegisterElement))
147 Platform::current()->recordRappor("WebComponents.DocumentRegisterElement ", host); 148 Platform::current()->recordRappor("WebComponents.DocumentRegisterElement ", url.host());
148 if (get(Feature::EventPath)) 149 if (get(Feature::EventPath))
149 Platform::current()->recordRappor("WebComponents.EventPath", host); 150 Platform::current()->recordRappor("WebComponents.EventPath", url.host()) ;
150 if (get(Feature::DeviceMotionInsecureHost)) 151 if (get(Feature::DeviceMotionInsecureHost))
151 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceMotion. Insecure", host); 152 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceMotion. Insecure", url.host());
152 if (get(Feature::DeviceOrientationInsecureHost)) 153 if (get(Feature::DeviceOrientationInsecureHost))
153 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceOrienta tion.Insecure", host); 154 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceOrienta tion.Insecure", url.host());
154 if (get(Feature::FullscreenInsecureHost)) 155 if (get(Feature::FullscreenInsecureHost))
155 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Fullscreen.In secure", host); 156 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Fullscreen.In secure", url.host());
156 if (get(Feature::GeolocationInsecureHost)) 157 if (get(Feature::GeolocationInsecureHost))
157 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Geolocation.I nsecure", host); 158 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Geolocation.I nsecure", url.host());
158 if (get(Feature::GetUserMediaInsecureHost)) 159 if (get(Feature::GetUserMediaInsecureHost))
159 Platform::current()->recordRappor("PowerfulFeatureUse.Host.GetUserMedia. Insecure", host); 160 Platform::current()->recordRappor("PowerfulFeatureUse.Host.GetUserMedia. Insecure", url.host());
160 if (get(Feature::GetUserMediaSecureHost)) 161 if (get(Feature::GetUserMediaSecureHost))
161 Platform::current()->recordRappor("PowerfulFeatureUse.Host.GetUserMedia. Secure", host); 162 Platform::current()->recordRappor("PowerfulFeatureUse.Host.GetUserMedia. Secure", url.host());
162 if (get(Feature::ApplicationCacheManifestSelectInsecureHost)) 163 if (get(Feature::ApplicationCacheManifestSelectInsecureHost))
163 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheManifestSelect.Insecure", host); 164 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheManifestSelect.Insecure", url.host());
164 if (get(Feature::ApplicationCacheAPIInsecureHost)) 165 if (get(Feature::ApplicationCacheAPIInsecureHost))
165 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheAPI.Insecure", host); 166 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheAPI.Insecure", url.host());
167
168 // Platform::recordRapporURL uses the ETLD+1 of the given URL
jww 2016/06/11 18:43:21 nit: Would you mind updating the comment above Pla
Guido Urdaneta 2016/06/12 11:06:22 Done.
169 if (get(Feature::GetUserMediaInsecureETLDPlus1))
170 Platform::current()->recordRapporURL("PowerfulFeatureUse.ETLDPlus1.GetUs erMedia.Insecure", WebURL(url));
171 if (get(Feature::GetUserMediaSecureETLDPlus1))
172 Platform::current()->recordRapporURL("PowerfulFeatureUse.ETLDPlus1.GetUs erMedia.Secure", WebURL(url));
166 } 173 }
167 174
168 void HostsUsingFeatures::Value::recordNameToRappor(const String& name) 175 void HostsUsingFeatures::Value::recordNameToRappor(const String& name)
169 { 176 {
170 if (get(Feature::EventPath)) 177 if (get(Feature::EventPath))
171 Platform::current()->recordRappor("WebComponents.EventPath.Extensions", name); 178 Platform::current()->recordRappor("WebComponents.EventPath.Extensions", name);
172 } 179 }
173 180
174 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698