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

Side by Side Diff: net/http/http_server_properties_manager.cc

Issue 1139843002: HttpServerProperties - Track UpdatePrefs callers. In offical builds, on (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "net/http/http_server_properties_manager.h" 5 #include "net/http/http_server_properties_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const char kAddressKey[] = "address"; 59 const char kAddressKey[] = "address";
60 const char kAlternateProtocolKey[] = "alternate_protocol"; 60 const char kAlternateProtocolKey[] = "alternate_protocol";
61 const char kAlternativeServiceKey[] = "alternative_service"; 61 const char kAlternativeServiceKey[] = "alternative_service";
62 const char kProtocolKey[] = "protocol_str"; 62 const char kProtocolKey[] = "protocol_str";
63 const char kHostKey[] = "host"; 63 const char kHostKey[] = "host";
64 const char kPortKey[] = "port"; 64 const char kPortKey[] = "port";
65 const char kProbabilityKey[] = "probability"; 65 const char kProbabilityKey[] = "probability";
66 const char kNetworkStatsKey[] = "network_stats"; 66 const char kNetworkStatsKey[] = "network_stats";
67 const char kSrttKey[] = "srtt"; 67 const char kSrttKey[] = "srtt";
68 68
69 enum Location {
70 SUPPORTS_SPDY = 0,
71 HTTP_11_REQUIRED = 1,
72 SET_ALTERNATIVE_SERVICE = 2,
73 MARK_ALTERNATIVE_SERVICE_BROKEN = 3,
74 MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN = 4,
75 CONFIRM_ALTERNATIVE_SERVICE = 5,
76 CLEAR_ALTERNATIVE_SERVICE = 6,
77 SET_SPDY_SETTING = 7,
78 CLEAR_SPDY_SETTINGS = 8,
79 CLEAR_ALL_SPDY_SETTINGS = 9,
80 SET_SUPPORTS_QUIC = 10,
81 SET_SERVER_NETWORK_STATS = 11,
82 DETECTED_CORRUPTED_PREFS = 12,
83 NUM_LOCATIONS = 13,
84 };
85
86 // TODO(rtenneti): Delete the following histogram after collecting some data.
87 void RecordUpdatePrefs(Location location) {
88 UMA_HISTOGRAM_ENUMERATION("Net.HttpServerProperties.UpdatePrefs", location,
89 NUM_LOCATIONS);
90 }
91
69 } // namespace 92 } // namespace
70 93
71 //////////////////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////////////////
72 // HttpServerPropertiesManager 95 // HttpServerPropertiesManager
73 96
74 HttpServerPropertiesManager::HttpServerPropertiesManager( 97 HttpServerPropertiesManager::HttpServerPropertiesManager(
75 PrefService* pref_service, 98 PrefService* pref_service,
76 const char* pref_path, 99 const char* pref_path,
77 scoped_refptr<base::SequencedTaskRunner> network_task_runner) 100 scoped_refptr<base::SequencedTaskRunner> network_task_runner)
78 : pref_task_runner_(base::ThreadTaskRunnerHandle::Get()), 101 : pref_task_runner_(base::ThreadTaskRunnerHandle::Get()),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 177 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
155 return http_server_properties_impl_->SupportsRequestPriority(server); 178 return http_server_properties_impl_->SupportsRequestPriority(server);
156 } 179 }
157 180
158 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, 181 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server,
159 bool support_spdy) { 182 bool support_spdy) {
160 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 183 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
161 184
162 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); 185 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy);
163 ScheduleUpdatePrefsOnNetworkThread(); 186 ScheduleUpdatePrefsOnNetworkThread();
187 RecordUpdatePrefs(SUPPORTS_SPDY);
164 } 188 }
165 189
166 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) { 190 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) {
167 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 191 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
168 return http_server_properties_impl_->RequiresHTTP11(server); 192 return http_server_properties_impl_->RequiresHTTP11(server);
169 } 193 }
170 194
171 void HttpServerPropertiesManager::SetHTTP11Required( 195 void HttpServerPropertiesManager::SetHTTP11Required(
172 const HostPortPair& server) { 196 const HostPortPair& server) {
173 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 197 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
174 198
175 http_server_properties_impl_->SetHTTP11Required(server); 199 http_server_properties_impl_->SetHTTP11Required(server);
176 ScheduleUpdatePrefsOnNetworkThread(); 200 ScheduleUpdatePrefsOnNetworkThread();
201 RecordUpdatePrefs(HTTP_11_REQUIRED);
177 } 202 }
178 203
179 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server, 204 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server,
180 SSLConfig* ssl_config) { 205 SSLConfig* ssl_config) {
181 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 206 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
182 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config); 207 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config);
183 } 208 }
184 209
185 AlternativeService HttpServerPropertiesManager::GetAlternativeService( 210 AlternativeService HttpServerPropertiesManager::GetAlternativeService(
186 const HostPortPair& origin) { 211 const HostPortPair& origin) {
187 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 212 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
188 return http_server_properties_impl_->GetAlternativeService(origin); 213 return http_server_properties_impl_->GetAlternativeService(origin);
189 } 214 }
190 215
191 void HttpServerPropertiesManager::SetAlternativeService( 216 void HttpServerPropertiesManager::SetAlternativeService(
192 const HostPortPair& origin, 217 const HostPortPair& origin,
193 const AlternativeService& alternative_service, 218 const AlternativeService& alternative_service,
194 double alternative_probability) { 219 double alternative_probability) {
195 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 220 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
196 http_server_properties_impl_->SetAlternativeService( 221 http_server_properties_impl_->SetAlternativeService(
197 origin, alternative_service, alternative_probability); 222 origin, alternative_service, alternative_probability);
198 ScheduleUpdatePrefsOnNetworkThread(); 223 ScheduleUpdatePrefsOnNetworkThread();
224 RecordUpdatePrefs(SET_ALTERNATIVE_SERVICE);
199 } 225 }
200 226
201 void HttpServerPropertiesManager::MarkAlternativeServiceBroken( 227 void HttpServerPropertiesManager::MarkAlternativeServiceBroken(
202 const AlternativeService& alternative_service) { 228 const AlternativeService& alternative_service) {
203 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 229 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
204 http_server_properties_impl_->MarkAlternativeServiceBroken( 230 http_server_properties_impl_->MarkAlternativeServiceBroken(
205 alternative_service); 231 alternative_service);
206 ScheduleUpdatePrefsOnNetworkThread(); 232 ScheduleUpdatePrefsOnNetworkThread();
233 RecordUpdatePrefs(MARK_ALTERNATIVE_SERVICE_BROKEN);
207 } 234 }
208 235
209 void HttpServerPropertiesManager::MarkAlternativeServiceRecentlyBroken( 236 void HttpServerPropertiesManager::MarkAlternativeServiceRecentlyBroken(
210 const AlternativeService& alternative_service) { 237 const AlternativeService& alternative_service) {
211 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 238 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
212 http_server_properties_impl_->MarkAlternativeServiceRecentlyBroken( 239 http_server_properties_impl_->MarkAlternativeServiceRecentlyBroken(
213 alternative_service); 240 alternative_service);
214 ScheduleUpdatePrefsOnNetworkThread(); 241 ScheduleUpdatePrefsOnNetworkThread();
242 RecordUpdatePrefs(MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN);
215 } 243 }
216 244
217 bool HttpServerPropertiesManager::IsAlternativeServiceBroken( 245 bool HttpServerPropertiesManager::IsAlternativeServiceBroken(
218 const AlternativeService& alternative_service) const { 246 const AlternativeService& alternative_service) const {
219 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 247 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
220 return http_server_properties_impl_->IsAlternativeServiceBroken( 248 return http_server_properties_impl_->IsAlternativeServiceBroken(
221 alternative_service); 249 alternative_service);
222 } 250 }
223 251
224 bool HttpServerPropertiesManager::WasAlternativeServiceRecentlyBroken( 252 bool HttpServerPropertiesManager::WasAlternativeServiceRecentlyBroken(
225 const AlternativeService& alternative_service) { 253 const AlternativeService& alternative_service) {
226 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 254 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
227 return http_server_properties_impl_->WasAlternativeServiceRecentlyBroken( 255 return http_server_properties_impl_->WasAlternativeServiceRecentlyBroken(
228 alternative_service); 256 alternative_service);
229 } 257 }
230 258
231 void HttpServerPropertiesManager::ConfirmAlternativeService( 259 void HttpServerPropertiesManager::ConfirmAlternativeService(
232 const AlternativeService& alternative_service) { 260 const AlternativeService& alternative_service) {
233 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 261 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
234 http_server_properties_impl_->ConfirmAlternativeService(alternative_service); 262 http_server_properties_impl_->ConfirmAlternativeService(alternative_service);
235 ScheduleUpdatePrefsOnNetworkThread(); 263 ScheduleUpdatePrefsOnNetworkThread();
264 RecordUpdatePrefs(CONFIRM_ALTERNATIVE_SERVICE);
236 } 265 }
237 266
238 void HttpServerPropertiesManager::ClearAlternativeService( 267 void HttpServerPropertiesManager::ClearAlternativeService(
239 const HostPortPair& origin) { 268 const HostPortPair& origin) {
240 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 269 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
241 http_server_properties_impl_->ClearAlternativeService(origin); 270 http_server_properties_impl_->ClearAlternativeService(origin);
242 ScheduleUpdatePrefsOnNetworkThread(); 271 ScheduleUpdatePrefsOnNetworkThread();
272 RecordUpdatePrefs(CLEAR_ALTERNATIVE_SERVICE);
243 } 273 }
244 274
245 const AlternativeServiceMap& 275 const AlternativeServiceMap&
246 HttpServerPropertiesManager::alternative_service_map() const { 276 HttpServerPropertiesManager::alternative_service_map() const {
247 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 277 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
248 return http_server_properties_impl_->alternative_service_map(); 278 return http_server_properties_impl_->alternative_service_map();
249 } 279 }
250 280
251 base::Value* HttpServerPropertiesManager::GetAlternativeServiceInfoAsValue() 281 base::Value* HttpServerPropertiesManager::GetAlternativeServiceInfoAsValue()
252 const { 282 const {
(...skipping 15 matching lines...) Expand all
268 } 298 }
269 299
270 bool HttpServerPropertiesManager::SetSpdySetting( 300 bool HttpServerPropertiesManager::SetSpdySetting(
271 const HostPortPair& host_port_pair, 301 const HostPortPair& host_port_pair,
272 SpdySettingsIds id, 302 SpdySettingsIds id,
273 SpdySettingsFlags flags, 303 SpdySettingsFlags flags,
274 uint32 value) { 304 uint32 value) {
275 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 305 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
276 bool persist = http_server_properties_impl_->SetSpdySetting( 306 bool persist = http_server_properties_impl_->SetSpdySetting(
277 host_port_pair, id, flags, value); 307 host_port_pair, id, flags, value);
278 if (persist) 308 if (persist) {
279 ScheduleUpdatePrefsOnNetworkThread(); 309 ScheduleUpdatePrefsOnNetworkThread();
310 RecordUpdatePrefs(SET_SPDY_SETTING);
311 }
280 return persist; 312 return persist;
281 } 313 }
282 314
283 void HttpServerPropertiesManager::ClearSpdySettings( 315 void HttpServerPropertiesManager::ClearSpdySettings(
284 const HostPortPair& host_port_pair) { 316 const HostPortPair& host_port_pair) {
285 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 317 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
286 http_server_properties_impl_->ClearSpdySettings(host_port_pair); 318 http_server_properties_impl_->ClearSpdySettings(host_port_pair);
287 ScheduleUpdatePrefsOnNetworkThread(); 319 ScheduleUpdatePrefsOnNetworkThread();
320 RecordUpdatePrefs(CLEAR_SPDY_SETTINGS);
288 } 321 }
289 322
290 void HttpServerPropertiesManager::ClearAllSpdySettings() { 323 void HttpServerPropertiesManager::ClearAllSpdySettings() {
291 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 324 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
292 http_server_properties_impl_->ClearAllSpdySettings(); 325 http_server_properties_impl_->ClearAllSpdySettings();
293 ScheduleUpdatePrefsOnNetworkThread(); 326 ScheduleUpdatePrefsOnNetworkThread();
327 RecordUpdatePrefs(CLEAR_ALL_SPDY_SETTINGS);
294 } 328 }
295 329
296 const SpdySettingsMap& HttpServerPropertiesManager::spdy_settings_map() 330 const SpdySettingsMap& HttpServerPropertiesManager::spdy_settings_map()
297 const { 331 const {
298 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 332 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
299 return http_server_properties_impl_->spdy_settings_map(); 333 return http_server_properties_impl_->spdy_settings_map();
300 } 334 }
301 335
302 bool HttpServerPropertiesManager::GetSupportsQuic( 336 bool HttpServerPropertiesManager::GetSupportsQuic(
303 IPAddressNumber* last_address) const { 337 IPAddressNumber* last_address) const {
304 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 338 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
305 return http_server_properties_impl_->GetSupportsQuic(last_address); 339 return http_server_properties_impl_->GetSupportsQuic(last_address);
306 } 340 }
307 341
308 void HttpServerPropertiesManager::SetSupportsQuic( 342 void HttpServerPropertiesManager::SetSupportsQuic(
309 bool used_quic, 343 bool used_quic,
310 const IPAddressNumber& address) { 344 const IPAddressNumber& address) {
311 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 345 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
312 http_server_properties_impl_->SetSupportsQuic(used_quic, address); 346 http_server_properties_impl_->SetSupportsQuic(used_quic, address);
313 ScheduleUpdatePrefsOnNetworkThread(); 347 ScheduleUpdatePrefsOnNetworkThread();
348 RecordUpdatePrefs(SET_SUPPORTS_QUIC);
314 } 349 }
315 350
316 void HttpServerPropertiesManager::SetServerNetworkStats( 351 void HttpServerPropertiesManager::SetServerNetworkStats(
317 const HostPortPair& host_port_pair, 352 const HostPortPair& host_port_pair,
318 ServerNetworkStats stats) { 353 ServerNetworkStats stats) {
319 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 354 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
320 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); 355 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats);
321 ScheduleUpdatePrefsOnNetworkThread(); 356 ScheduleUpdatePrefsOnNetworkThread();
357 RecordUpdatePrefs(SET_SERVER_NETWORK_STATS);
mmenke 2015/05/12 14:35:03 Suggest making this an argument to ScheduleUpdateP
ramant (doing other things) 2015/05/12 17:32:22 Doh!. Thanks and Done.
322 } 358 }
323 359
324 const ServerNetworkStats* HttpServerPropertiesManager::GetServerNetworkStats( 360 const ServerNetworkStats* HttpServerPropertiesManager::GetServerNetworkStats(
325 const HostPortPair& host_port_pair) { 361 const HostPortPair& host_port_pair) {
326 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 362 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
327 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); 363 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair);
328 } 364 }
329 365
330 const ServerNetworkStatsMap& 366 const ServerNetworkStatsMap&
331 HttpServerPropertiesManager::server_network_stats_map() const { 367 HttpServerPropertiesManager::server_network_stats_map() const {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 alternative_service_map->size()); 680 alternative_service_map->size());
645 http_server_properties_impl_->InitializeAlternativeServiceServers( 681 http_server_properties_impl_->InitializeAlternativeServiceServers(
646 alternative_service_map); 682 alternative_service_map);
647 683
648 http_server_properties_impl_->InitializeSupportsQuic(last_quic_address); 684 http_server_properties_impl_->InitializeSupportsQuic(last_quic_address);
649 685
650 http_server_properties_impl_->InitializeServerNetworkStats( 686 http_server_properties_impl_->InitializeServerNetworkStats(
651 server_network_stats_map); 687 server_network_stats_map);
652 688
653 // Update the prefs with what we have read (delete all corrupted prefs). 689 // Update the prefs with what we have read (delete all corrupted prefs).
654 if (detected_corrupted_prefs) 690 if (detected_corrupted_prefs) {
655 ScheduleUpdatePrefsOnNetworkThread(); 691 ScheduleUpdatePrefsOnNetworkThread();
692 RecordUpdatePrefs(DETECTED_CORRUPTED_PREFS);
693 }
656 } 694 }
657 695
658 // 696 //
659 // Update Preferences with data from the cached data. 697 // Update Preferences with data from the cached data.
660 // 698 //
661 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnNetworkThread() { 699 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnNetworkThread() {
662 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 700 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
663 // Cancel pending updates, if any. 701 // Cancel pending updates, if any.
664 network_prefs_update_timer_->Stop(); 702 network_prefs_update_timer_->Stop();
665 StartPrefsUpdateTimerOnNetworkThread( 703 StartPrefsUpdateTimerOnNetworkThread(
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 server_network_stats_dict); 984 server_network_stats_dict);
947 } 985 }
948 986
949 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 987 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
950 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 988 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
951 if (!setting_prefs_) 989 if (!setting_prefs_)
952 ScheduleUpdateCacheOnPrefThread(); 990 ScheduleUpdateCacheOnPrefThread();
953 } 991 }
954 992
955 } // namespace net 993 } // namespace net
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