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

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: Stop reporting host-based GetUserMedia rappor 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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 void HostsUsingFeatures::countName(Feature feature, const String& name) 70 void HostsUsingFeatures::countName(Feature feature, const String& name)
71 { 71 {
72 auto result = m_valueByName.add(name, Value()); 72 auto result = m_valueByName.add(name, Value());
73 result.storedValue->value.count(feature); 73 result.storedValue->value.count(feature);
74 } 74 }
75 75
76 void HostsUsingFeatures::clear() 76 void HostsUsingFeatures::clear()
77 { 77 {
78 m_hostAndValues.clear();
79 m_valueByName.clear(); 78 m_valueByName.clear();
79 m_urlAndValues.clear();
80 } 80 }
81 81
82 void HostsUsingFeatures::documentDetached(Document& document) 82 void HostsUsingFeatures::documentDetached(Document& document)
83 { 83 {
84 HostsUsingFeatures::Value counter = document.HostsUsingFeaturesValue(); 84 HostsUsingFeatures::Value counter = document.HostsUsingFeaturesValue();
85 if (counter.isEmpty()) 85 if (counter.isEmpty())
86 return; 86 return;
87 87
88 const KURL& url = document.url(); 88 const KURL& url = document.url();
89 if (!url.protocolIsInHTTPFamily()) 89 if (!url.protocolIsInHTTPFamily())
90 return; 90 return;
91 91
92 m_hostAndValues.append(std::make_pair(url.host(), counter)); 92 m_urlAndValues.append(std::make_pair(url, counter));
93 document.HostsUsingFeaturesValue().clear(); 93 document.HostsUsingFeaturesValue().clear();
94 DCHECK(document.HostsUsingFeaturesValue().isEmpty()); 94 DCHECK(document.HostsUsingFeaturesValue().isEmpty());
95 } 95 }
96 96
97 void HostsUsingFeatures::updateMeasurementsAndClear() 97 void HostsUsingFeatures::updateMeasurementsAndClear()
98 { 98 {
99 if (!m_hostAndValues.isEmpty()) 99 if (!m_urlAndValues.isEmpty()) {
100 recordHostToRappor(); 100 recordHostToRappor();
101 recordETLDPlus1ToRappor();
102 m_urlAndValues.clear();
103 }
101 if (!m_valueByName.isEmpty()) 104 if (!m_valueByName.isEmpty())
102 recordNamesToRappor(); 105 recordNamesToRappor();
103 } 106 }
104 107
105 void HostsUsingFeatures::recordHostToRappor() 108 void HostsUsingFeatures::recordHostToRappor()
106 { 109 {
107 DCHECK(!m_hostAndValues.isEmpty()); 110 DCHECK(!m_urlAndValues.isEmpty());
108 111
109 // Aggregate values by hosts. 112 // Aggregate values by hosts.
110 HashMap<String, HostsUsingFeatures::Value> aggregatedByHost; 113 HashMap<String, HostsUsingFeatures::Value> aggregatedByHost;
111 for (const auto& hostAndValue : m_hostAndValues) { 114 for (const auto& urlAndValue : m_urlAndValues) {
112 DCHECK(!hostAndValue.first.isEmpty()); 115 DCHECK(!urlAndValue.first.isEmpty());
113 auto result = aggregatedByHost.add(hostAndValue.first, hostAndValue.seco nd); 116 auto result = aggregatedByHost.add(urlAndValue.first.host(), urlAndValue .second);
114 if (!result.isNewEntry) 117 if (!result.isNewEntry)
115 result.storedValue->value.aggregate(hostAndValue.second); 118 result.storedValue->value.aggregate(urlAndValue.second);
116 } 119 }
117 120
118 // Report to RAPPOR. 121 // Report to RAPPOR.
119 for (auto& hostAndValue : aggregatedByHost) 122 for (auto& hostAndValue : aggregatedByHost)
120 hostAndValue.value.recordHostToRappor(hostAndValue.key); 123 hostAndValue.value.recordHostToRappor(hostAndValue.key);
124 }
121 125
122 m_hostAndValues.clear(); 126 void HostsUsingFeatures::recordETLDPlus1ToRappor()
127 {
128 DCHECK(!m_urlAndValues.isEmpty());
129
130 // Aggregate values by URL.
131 HashMap<String, HostsUsingFeatures::Value> aggregatedByURL;
132 for (const auto& urlAndValue : m_urlAndValues) {
133 DCHECK(!urlAndValue.first.isEmpty());
134 auto result = aggregatedByURL.add(urlAndValue.first, urlAndValue.second) ;
135 if (!result.isNewEntry)
136 result.storedValue->value.aggregate(urlAndValue.second);
137 }
138
139 // Report to RAPPOR.
140 for (auto& urlAndValue : aggregatedByURL)
141 urlAndValue.value.recordETLDPlus1ToRappor(KURL(ParsedURLString, urlAndVa lue.key));
123 } 142 }
124 143
125 void HostsUsingFeatures::recordNamesToRappor() 144 void HostsUsingFeatures::recordNamesToRappor()
126 { 145 {
127 DCHECK(!m_valueByName.isEmpty()); 146 DCHECK(!m_valueByName.isEmpty());
128 147
129 for (auto& nameAndValue : m_valueByName) 148 for (auto& nameAndValue : m_valueByName)
130 nameAndValue.value.recordNameToRappor(nameAndValue.key); 149 nameAndValue.value.recordNameToRappor(nameAndValue.key);
131 150
132 m_valueByName.clear(); 151 m_valueByName.clear();
(...skipping 15 matching lines...) Expand all
148 if (get(Feature::EventPath)) 167 if (get(Feature::EventPath))
149 Platform::current()->recordRappor("WebComponents.EventPath", host); 168 Platform::current()->recordRappor("WebComponents.EventPath", host);
150 if (get(Feature::DeviceMotionInsecureHost)) 169 if (get(Feature::DeviceMotionInsecureHost))
151 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceMotion. Insecure", host); 170 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceMotion. Insecure", host);
152 if (get(Feature::DeviceOrientationInsecureHost)) 171 if (get(Feature::DeviceOrientationInsecureHost))
153 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceOrienta tion.Insecure", host); 172 Platform::current()->recordRappor("PowerfulFeatureUse.Host.DeviceOrienta tion.Insecure", host);
154 if (get(Feature::FullscreenInsecureHost)) 173 if (get(Feature::FullscreenInsecureHost))
155 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Fullscreen.In secure", host); 174 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Fullscreen.In secure", host);
156 if (get(Feature::GeolocationInsecureHost)) 175 if (get(Feature::GeolocationInsecureHost))
157 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Geolocation.I nsecure", host); 176 Platform::current()->recordRappor("PowerfulFeatureUse.Host.Geolocation.I nsecure", host);
158 if (get(Feature::GetUserMediaInsecureHost))
159 Platform::current()->recordRappor("PowerfulFeatureUse.Host.GetUserMedia. Insecure", host);
160 if (get(Feature::GetUserMediaSecureHost))
161 Platform::current()->recordRappor("PowerfulFeatureUse.Host.GetUserMedia. Secure", host);
162 if (get(Feature::ApplicationCacheManifestSelectInsecureHost)) 177 if (get(Feature::ApplicationCacheManifestSelectInsecureHost))
163 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheManifestSelect.Insecure", host); 178 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheManifestSelect.Insecure", host);
164 if (get(Feature::ApplicationCacheAPIInsecureHost)) 179 if (get(Feature::ApplicationCacheAPIInsecureHost))
165 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheAPI.Insecure", host); 180 Platform::current()->recordRappor("PowerfulFeatureUse.Host.ApplicationCa cheAPI.Insecure", host);
166 } 181 }
167 182
168 void HostsUsingFeatures::Value::recordNameToRappor(const String& name) 183 void HostsUsingFeatures::Value::recordNameToRappor(const String& name)
169 { 184 {
170 if (get(Feature::EventPath)) 185 if (get(Feature::EventPath))
171 Platform::current()->recordRappor("WebComponents.EventPath.Extensions", name); 186 Platform::current()->recordRappor("WebComponents.EventPath.Extensions", name);
172 } 187 }
173 188
189 void HostsUsingFeatures::Value::recordETLDPlus1ToRappor(const KURL& url)
190 {
191 if (get(Feature::GetUserMediaInsecureHost))
192 Platform::current()->recordRapporURL("PowerfulFeatureUse.ETLDPlus1.GetUs erMedia.Insecure", WebURL(url));
193 if (get(Feature::GetUserMediaSecureHost))
194 Platform::current()->recordRapporURL("PowerfulFeatureUse.ETLDPlus1.GetUs erMedia.Secure", WebURL(url));
195 }
196
174 } // namespace blink 197 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/HostsUsingFeatures.h ('k') | third_party/WebKit/public/platform/Platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698