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

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

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 years, 10 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 page->hostsUsingFeatures().countName( 58 page->hostsUsingFeatures().countName(
59 feature, scriptState->world().isolatedWorldHumanReadableName()); 59 feature, scriptState->world().isolatedWorldHumanReadableName());
60 } 60 }
61 61
62 void HostsUsingFeatures::Value::count(Feature feature) { 62 void HostsUsingFeatures::Value::count(Feature feature) {
63 DCHECK(feature < Feature::NumberOfFeatures); 63 DCHECK(feature < Feature::NumberOfFeatures);
64 m_countBits |= 1 << static_cast<unsigned>(feature); 64 m_countBits |= 1 << static_cast<unsigned>(feature);
65 } 65 }
66 66
67 void HostsUsingFeatures::countName(Feature feature, const String& name) { 67 void HostsUsingFeatures::countName(Feature feature, const String& name) {
68 auto result = m_valueByName.add(name, Value()); 68 auto result = m_valueByName.insert(name, Value());
69 result.storedValue->value.count(feature); 69 result.storedValue->value.count(feature);
70 } 70 }
71 71
72 void HostsUsingFeatures::clear() { 72 void HostsUsingFeatures::clear() {
73 m_valueByName.clear(); 73 m_valueByName.clear();
74 m_urlAndValues.clear(); 74 m_urlAndValues.clear();
75 } 75 }
76 76
77 void HostsUsingFeatures::documentDetached(Document& document) { 77 void HostsUsingFeatures::documentDetached(Document& document) {
78 HostsUsingFeatures::Value counter = document.HostsUsingFeaturesValue(); 78 HostsUsingFeatures::Value counter = document.HostsUsingFeaturesValue();
(...skipping 20 matching lines...) Expand all
99 } 99 }
100 100
101 void HostsUsingFeatures::recordHostToRappor() { 101 void HostsUsingFeatures::recordHostToRappor() {
102 DCHECK(!m_urlAndValues.isEmpty()); 102 DCHECK(!m_urlAndValues.isEmpty());
103 103
104 // Aggregate values by hosts. 104 // Aggregate values by hosts.
105 HashMap<String, HostsUsingFeatures::Value> aggregatedByHost; 105 HashMap<String, HostsUsingFeatures::Value> aggregatedByHost;
106 for (const auto& urlAndValue : m_urlAndValues) { 106 for (const auto& urlAndValue : m_urlAndValues) {
107 DCHECK(!urlAndValue.first.isEmpty()); 107 DCHECK(!urlAndValue.first.isEmpty());
108 auto result = 108 auto result =
109 aggregatedByHost.add(urlAndValue.first.host(), urlAndValue.second); 109 aggregatedByHost.insert(urlAndValue.first.host(), urlAndValue.second);
110 if (!result.isNewEntry) 110 if (!result.isNewEntry)
111 result.storedValue->value.aggregate(urlAndValue.second); 111 result.storedValue->value.aggregate(urlAndValue.second);
112 } 112 }
113 113
114 // Report to RAPPOR. 114 // Report to RAPPOR.
115 for (auto& hostAndValue : aggregatedByHost) 115 for (auto& hostAndValue : aggregatedByHost)
116 hostAndValue.value.recordHostToRappor(hostAndValue.key); 116 hostAndValue.value.recordHostToRappor(hostAndValue.key);
117 } 117 }
118 118
119 void HostsUsingFeatures::recordETLDPlus1ToRappor() { 119 void HostsUsingFeatures::recordETLDPlus1ToRappor() {
120 DCHECK(!m_urlAndValues.isEmpty()); 120 DCHECK(!m_urlAndValues.isEmpty());
121 121
122 // Aggregate values by URL. 122 // Aggregate values by URL.
123 HashMap<String, HostsUsingFeatures::Value> aggregatedByURL; 123 HashMap<String, HostsUsingFeatures::Value> aggregatedByURL;
124 for (const auto& urlAndValue : m_urlAndValues) { 124 for (const auto& urlAndValue : m_urlAndValues) {
125 DCHECK(!urlAndValue.first.isEmpty()); 125 DCHECK(!urlAndValue.first.isEmpty());
126 auto result = aggregatedByURL.add(urlAndValue.first, urlAndValue.second); 126 auto result = aggregatedByURL.insert(urlAndValue.first, urlAndValue.second);
127 if (!result.isNewEntry) 127 if (!result.isNewEntry)
128 result.storedValue->value.aggregate(urlAndValue.second); 128 result.storedValue->value.aggregate(urlAndValue.second);
129 } 129 }
130 130
131 // Report to RAPPOR. 131 // Report to RAPPOR.
132 for (auto& urlAndValue : aggregatedByURL) 132 for (auto& urlAndValue : aggregatedByURL)
133 urlAndValue.value.recordETLDPlus1ToRappor( 133 urlAndValue.value.recordETLDPlus1ToRappor(
134 KURL(ParsedURLString, urlAndValue.key)); 134 KURL(ParsedURLString, urlAndValue.key));
135 } 135 }
136 136
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (get(Feature::RTCPeerConnectionUsed) && 205 if (get(Feature::RTCPeerConnectionUsed) &&
206 !get(Feature::RTCPeerConnectionAudio) && 206 !get(Feature::RTCPeerConnectionAudio) &&
207 !get(Feature::RTCPeerConnectionVideo) && 207 !get(Feature::RTCPeerConnectionVideo) &&
208 !get(Feature::RTCPeerConnectionDataChannel)) { 208 !get(Feature::RTCPeerConnectionDataChannel)) {
209 Platform::current()->recordRapporURL("RTCPeerConnection.Unconnected", 209 Platform::current()->recordRapporURL("RTCPeerConnection.Unconnected",
210 WebURL(url)); 210 WebURL(url));
211 } 211 }
212 } 212 }
213 213
214 } // namespace blink 214 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698