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

Unified 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: jww comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/HostsUsingFeatures.cpp
diff --git a/third_party/WebKit/Source/core/frame/HostsUsingFeatures.cpp b/third_party/WebKit/Source/core/frame/HostsUsingFeatures.cpp
index 8277ba8423c8d111fd9994ea6c5ab40342b99bdf..fca66d57706a680eaa036f7dc39c01fc1e3e799f 100644
--- a/third_party/WebKit/Source/core/frame/HostsUsingFeatures.cpp
+++ b/third_party/WebKit/Source/core/frame/HostsUsingFeatures.cpp
@@ -75,8 +75,8 @@ void HostsUsingFeatures::countName(Feature feature, const String& name)
void HostsUsingFeatures::clear()
{
- m_hostAndValues.clear();
m_valueByName.clear();
+ m_urlAndValues.clear();
}
void HostsUsingFeatures::documentDetached(Document& document)
@@ -89,37 +89,56 @@ void HostsUsingFeatures::documentDetached(Document& document)
if (!url.protocolIsInHTTPFamily())
return;
- m_hostAndValues.append(std::make_pair(url.host(), counter));
+ m_urlAndValues.append(std::make_pair(url, counter));
document.HostsUsingFeaturesValue().clear();
DCHECK(document.HostsUsingFeaturesValue().isEmpty());
}
void HostsUsingFeatures::updateMeasurementsAndClear()
{
- if (!m_hostAndValues.isEmpty())
+ if (!m_urlAndValues.isEmpty()) {
recordHostToRappor();
+ recordETLDPlus1ToRappor();
+ m_urlAndValues.clear();
+ }
if (!m_valueByName.isEmpty())
recordNamesToRappor();
}
void HostsUsingFeatures::recordHostToRappor()
{
- DCHECK(!m_hostAndValues.isEmpty());
+ DCHECK(!m_urlAndValues.isEmpty());
// Aggregate values by hosts.
HashMap<String, HostsUsingFeatures::Value> aggregatedByHost;
- for (const auto& hostAndValue : m_hostAndValues) {
- DCHECK(!hostAndValue.first.isEmpty());
- auto result = aggregatedByHost.add(hostAndValue.first, hostAndValue.second);
+ for (const auto& urlAndValue : m_urlAndValues) {
+ DCHECK(!urlAndValue.first.isEmpty());
+ auto result = aggregatedByHost.add(urlAndValue.first.host(), urlAndValue.second);
if (!result.isNewEntry)
- result.storedValue->value.aggregate(hostAndValue.second);
+ result.storedValue->value.aggregate(urlAndValue.second);
}
// Report to RAPPOR.
for (auto& hostAndValue : aggregatedByHost)
hostAndValue.value.recordHostToRappor(hostAndValue.key);
+}
+
+void HostsUsingFeatures::recordETLDPlus1ToRappor()
+{
+ DCHECK(!m_urlAndValues.isEmpty());
+
+ // Aggregate values by URL.
+ HashMap<String, HostsUsingFeatures::Value> aggregatedByURL;
+ for (const auto& urlAndValue : m_urlAndValues) {
+ DCHECK(!urlAndValue.first.isEmpty());
+ auto result = aggregatedByURL.add(urlAndValue.first, urlAndValue.second);
+ if (!result.isNewEntry)
+ result.storedValue->value.aggregate(urlAndValue.second);
+ }
- m_hostAndValues.clear();
+ // Report to RAPPOR.
+ for (auto& urlAndValue : aggregatedByURL)
+ urlAndValue.value.recordETLDPlus1ToRappor(KURL(ParsedURLString, urlAndValue.key));
}
void HostsUsingFeatures::recordNamesToRappor()
@@ -171,4 +190,12 @@ void HostsUsingFeatures::Value::recordNameToRappor(const String& name)
Platform::current()->recordRappor("WebComponents.EventPath.Extensions", name);
}
+void HostsUsingFeatures::Value::recordETLDPlus1ToRappor(const KURL& url)
+{
+ if (get(Feature::GetUserMediaInsecureHost))
+ Platform::current()->recordRapporURL("PowerfulFeatureUse.ETLDPlus1.GetUserMedia.Insecure", WebURL(url));
+ if (get(Feature::GetUserMediaSecureHost))
+ Platform::current()->recordRapporURL("PowerfulFeatureUse.ETLDPlus1.GetUserMedia.Secure", WebURL(url));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698