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

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: Fixed comments for patch set 2 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
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const HostPortPair& server) { 153 const HostPortPair& server) {
154 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 154 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
155 return http_server_properties_impl_->SupportsRequestPriority(server); 155 return http_server_properties_impl_->SupportsRequestPriority(server);
156 } 156 }
157 157
158 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, 158 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server,
159 bool support_spdy) { 159 bool support_spdy) {
160 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 160 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
161 161
162 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); 162 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy);
163 ScheduleUpdatePrefsOnNetworkThread(); 163 ScheduleUpdatePrefsOnNetworkThread(SUPPORTS_SPDY);
164 } 164 }
165 165
166 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) { 166 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) {
167 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 167 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
168 return http_server_properties_impl_->RequiresHTTP11(server); 168 return http_server_properties_impl_->RequiresHTTP11(server);
169 } 169 }
170 170
171 void HttpServerPropertiesManager::SetHTTP11Required( 171 void HttpServerPropertiesManager::SetHTTP11Required(
172 const HostPortPair& server) { 172 const HostPortPair& server) {
173 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 173 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
174 174
175 http_server_properties_impl_->SetHTTP11Required(server); 175 http_server_properties_impl_->SetHTTP11Required(server);
176 ScheduleUpdatePrefsOnNetworkThread(); 176 ScheduleUpdatePrefsOnNetworkThread(HTTP_11_REQUIRED);
177 } 177 }
178 178
179 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server, 179 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server,
180 SSLConfig* ssl_config) { 180 SSLConfig* ssl_config) {
181 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 181 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
182 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config); 182 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config);
183 } 183 }
184 184
185 AlternativeService HttpServerPropertiesManager::GetAlternativeService( 185 AlternativeService HttpServerPropertiesManager::GetAlternativeService(
186 const HostPortPair& origin) { 186 const HostPortPair& origin) {
187 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 187 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
188 return http_server_properties_impl_->GetAlternativeService(origin); 188 return http_server_properties_impl_->GetAlternativeService(origin);
189 } 189 }
190 190
191 void HttpServerPropertiesManager::SetAlternativeService( 191 void HttpServerPropertiesManager::SetAlternativeService(
192 const HostPortPair& origin, 192 const HostPortPair& origin,
193 const AlternativeService& alternative_service, 193 const AlternativeService& alternative_service,
194 double alternative_probability) { 194 double alternative_probability) {
195 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 195 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
196 http_server_properties_impl_->SetAlternativeService( 196 http_server_properties_impl_->SetAlternativeService(
197 origin, alternative_service, alternative_probability); 197 origin, alternative_service, alternative_probability);
198 ScheduleUpdatePrefsOnNetworkThread(); 198 ScheduleUpdatePrefsOnNetworkThread(SET_ALTERNATIVE_SERVICE);
199 } 199 }
200 200
201 void HttpServerPropertiesManager::MarkAlternativeServiceBroken( 201 void HttpServerPropertiesManager::MarkAlternativeServiceBroken(
202 const AlternativeService& alternative_service) { 202 const AlternativeService& alternative_service) {
203 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 203 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
204 http_server_properties_impl_->MarkAlternativeServiceBroken( 204 http_server_properties_impl_->MarkAlternativeServiceBroken(
205 alternative_service); 205 alternative_service);
206 ScheduleUpdatePrefsOnNetworkThread(); 206 ScheduleUpdatePrefsOnNetworkThread(MARK_ALTERNATIVE_SERVICE_BROKEN);
207 } 207 }
208 208
209 void HttpServerPropertiesManager::MarkAlternativeServiceRecentlyBroken( 209 void HttpServerPropertiesManager::MarkAlternativeServiceRecentlyBroken(
210 const AlternativeService& alternative_service) { 210 const AlternativeService& alternative_service) {
211 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 211 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
212 http_server_properties_impl_->MarkAlternativeServiceRecentlyBroken( 212 http_server_properties_impl_->MarkAlternativeServiceRecentlyBroken(
213 alternative_service); 213 alternative_service);
214 ScheduleUpdatePrefsOnNetworkThread(); 214 ScheduleUpdatePrefsOnNetworkThread(MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN);
215 } 215 }
216 216
217 bool HttpServerPropertiesManager::IsAlternativeServiceBroken( 217 bool HttpServerPropertiesManager::IsAlternativeServiceBroken(
218 const AlternativeService& alternative_service) const { 218 const AlternativeService& alternative_service) const {
219 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 219 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
220 return http_server_properties_impl_->IsAlternativeServiceBroken( 220 return http_server_properties_impl_->IsAlternativeServiceBroken(
221 alternative_service); 221 alternative_service);
222 } 222 }
223 223
224 bool HttpServerPropertiesManager::WasAlternativeServiceRecentlyBroken( 224 bool HttpServerPropertiesManager::WasAlternativeServiceRecentlyBroken(
225 const AlternativeService& alternative_service) { 225 const AlternativeService& alternative_service) {
226 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 226 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
227 return http_server_properties_impl_->WasAlternativeServiceRecentlyBroken( 227 return http_server_properties_impl_->WasAlternativeServiceRecentlyBroken(
228 alternative_service); 228 alternative_service);
229 } 229 }
230 230
231 void HttpServerPropertiesManager::ConfirmAlternativeService( 231 void HttpServerPropertiesManager::ConfirmAlternativeService(
232 const AlternativeService& alternative_service) { 232 const AlternativeService& alternative_service) {
233 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 233 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
234 http_server_properties_impl_->ConfirmAlternativeService(alternative_service); 234 http_server_properties_impl_->ConfirmAlternativeService(alternative_service);
235 ScheduleUpdatePrefsOnNetworkThread(); 235 ScheduleUpdatePrefsOnNetworkThread(CONFIRM_ALTERNATIVE_SERVICE);
236 } 236 }
237 237
238 void HttpServerPropertiesManager::ClearAlternativeService( 238 void HttpServerPropertiesManager::ClearAlternativeService(
239 const HostPortPair& origin) { 239 const HostPortPair& origin) {
240 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 240 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
241 http_server_properties_impl_->ClearAlternativeService(origin); 241 http_server_properties_impl_->ClearAlternativeService(origin);
242 ScheduleUpdatePrefsOnNetworkThread(); 242 ScheduleUpdatePrefsOnNetworkThread(CLEAR_ALTERNATIVE_SERVICE);
243 } 243 }
244 244
245 const AlternativeServiceMap& 245 const AlternativeServiceMap&
246 HttpServerPropertiesManager::alternative_service_map() const { 246 HttpServerPropertiesManager::alternative_service_map() const {
247 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 247 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
248 return http_server_properties_impl_->alternative_service_map(); 248 return http_server_properties_impl_->alternative_service_map();
249 } 249 }
250 250
251 base::Value* HttpServerPropertiesManager::GetAlternativeServiceInfoAsValue() 251 base::Value* HttpServerPropertiesManager::GetAlternativeServiceInfoAsValue()
252 const { 252 const {
(...skipping 16 matching lines...) Expand all
269 269
270 bool HttpServerPropertiesManager::SetSpdySetting( 270 bool HttpServerPropertiesManager::SetSpdySetting(
271 const HostPortPair& host_port_pair, 271 const HostPortPair& host_port_pair,
272 SpdySettingsIds id, 272 SpdySettingsIds id,
273 SpdySettingsFlags flags, 273 SpdySettingsFlags flags,
274 uint32 value) { 274 uint32 value) {
275 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 275 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
276 bool persist = http_server_properties_impl_->SetSpdySetting( 276 bool persist = http_server_properties_impl_->SetSpdySetting(
277 host_port_pair, id, flags, value); 277 host_port_pair, id, flags, value);
278 if (persist) 278 if (persist)
279 ScheduleUpdatePrefsOnNetworkThread(); 279 ScheduleUpdatePrefsOnNetworkThread(SET_SPDY_SETTING);
280 return persist; 280 return persist;
281 } 281 }
282 282
283 void HttpServerPropertiesManager::ClearSpdySettings( 283 void HttpServerPropertiesManager::ClearSpdySettings(
284 const HostPortPair& host_port_pair) { 284 const HostPortPair& host_port_pair) {
285 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 285 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
286 http_server_properties_impl_->ClearSpdySettings(host_port_pair); 286 http_server_properties_impl_->ClearSpdySettings(host_port_pair);
287 ScheduleUpdatePrefsOnNetworkThread(); 287 ScheduleUpdatePrefsOnNetworkThread(CLEAR_SPDY_SETTINGS);
288 } 288 }
289 289
290 void HttpServerPropertiesManager::ClearAllSpdySettings() { 290 void HttpServerPropertiesManager::ClearAllSpdySettings() {
291 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 291 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
292 http_server_properties_impl_->ClearAllSpdySettings(); 292 http_server_properties_impl_->ClearAllSpdySettings();
293 ScheduleUpdatePrefsOnNetworkThread(); 293 ScheduleUpdatePrefsOnNetworkThread(CLEAR_ALL_SPDY_SETTINGS);
294 } 294 }
295 295
296 const SpdySettingsMap& HttpServerPropertiesManager::spdy_settings_map() 296 const SpdySettingsMap& HttpServerPropertiesManager::spdy_settings_map()
297 const { 297 const {
298 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 298 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
299 return http_server_properties_impl_->spdy_settings_map(); 299 return http_server_properties_impl_->spdy_settings_map();
300 } 300 }
301 301
302 bool HttpServerPropertiesManager::GetSupportsQuic( 302 bool HttpServerPropertiesManager::GetSupportsQuic(
303 IPAddressNumber* last_address) const { 303 IPAddressNumber* last_address) const {
304 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 304 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
305 return http_server_properties_impl_->GetSupportsQuic(last_address); 305 return http_server_properties_impl_->GetSupportsQuic(last_address);
306 } 306 }
307 307
308 void HttpServerPropertiesManager::SetSupportsQuic( 308 void HttpServerPropertiesManager::SetSupportsQuic(
309 bool used_quic, 309 bool used_quic,
310 const IPAddressNumber& address) { 310 const IPAddressNumber& address) {
311 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 311 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
312 http_server_properties_impl_->SetSupportsQuic(used_quic, address); 312 http_server_properties_impl_->SetSupportsQuic(used_quic, address);
313 ScheduleUpdatePrefsOnNetworkThread(); 313 ScheduleUpdatePrefsOnNetworkThread(SET_SUPPORTS_QUIC);
314 } 314 }
315 315
316 void HttpServerPropertiesManager::SetServerNetworkStats( 316 void HttpServerPropertiesManager::SetServerNetworkStats(
317 const HostPortPair& host_port_pair, 317 const HostPortPair& host_port_pair,
318 ServerNetworkStats stats) { 318 ServerNetworkStats stats) {
319 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 319 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
320 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); 320 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats);
321 ScheduleUpdatePrefsOnNetworkThread(); 321 ScheduleUpdatePrefsOnNetworkThread(SET_SERVER_NETWORK_STATS);
322 } 322 }
323 323
324 const ServerNetworkStats* HttpServerPropertiesManager::GetServerNetworkStats( 324 const ServerNetworkStats* HttpServerPropertiesManager::GetServerNetworkStats(
325 const HostPortPair& host_port_pair) { 325 const HostPortPair& host_port_pair) {
326 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 326 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
327 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); 327 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair);
328 } 328 }
329 329
330 const ServerNetworkStatsMap& 330 const ServerNetworkStatsMap&
331 HttpServerPropertiesManager::server_network_stats_map() const { 331 HttpServerPropertiesManager::server_network_stats_map() const {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 http_server_properties_impl_->InitializeAlternativeServiceServers( 645 http_server_properties_impl_->InitializeAlternativeServiceServers(
646 alternative_service_map); 646 alternative_service_map);
647 647
648 http_server_properties_impl_->InitializeSupportsQuic(last_quic_address); 648 http_server_properties_impl_->InitializeSupportsQuic(last_quic_address);
649 649
650 http_server_properties_impl_->InitializeServerNetworkStats( 650 http_server_properties_impl_->InitializeServerNetworkStats(
651 server_network_stats_map); 651 server_network_stats_map);
652 652
653 // Update the prefs with what we have read (delete all corrupted prefs). 653 // Update the prefs with what we have read (delete all corrupted prefs).
654 if (detected_corrupted_prefs) 654 if (detected_corrupted_prefs)
655 ScheduleUpdatePrefsOnNetworkThread(); 655 ScheduleUpdatePrefsOnNetworkThread(DETECTED_CORRUPTED_PREFS);
656 } 656 }
657 657
658 // 658 //
659 // Update Preferences with data from the cached data. 659 // Update Preferences with data from the cached data.
660 // 660 //
661 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnNetworkThread() { 661 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnNetworkThread(
662 Location location) {
662 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 663 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
663 // Cancel pending updates, if any. 664 // Cancel pending updates, if any.
664 network_prefs_update_timer_->Stop(); 665 network_prefs_update_timer_->Stop();
665 StartPrefsUpdateTimerOnNetworkThread( 666 StartPrefsUpdateTimerOnNetworkThread(
666 base::TimeDelta::FromMilliseconds(kUpdatePrefsDelayMs)); 667 base::TimeDelta::FromMilliseconds(kUpdatePrefsDelayMs));
668 // TODO(rtenneti): Delete the following histogram after collecting some data.
669 UMA_HISTOGRAM_ENUMERATION("Net.HttpServerProperties.UpdatePrefs", location,
670 HttpServerPropertiesManager::NUM_LOCATIONS);
667 } 671 }
668 672
669 void HttpServerPropertiesManager::StartPrefsUpdateTimerOnNetworkThread( 673 void HttpServerPropertiesManager::StartPrefsUpdateTimerOnNetworkThread(
670 base::TimeDelta delay) { 674 base::TimeDelta delay) {
671 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 675 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
672 // This is overridden in tests to post the task without the delay. 676 // This is overridden in tests to post the task without the delay.
673 network_prefs_update_timer_->Start( 677 network_prefs_update_timer_->Start(
674 FROM_HERE, 678 FROM_HERE,
675 delay, 679 delay,
676 this, 680 this,
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 server_network_stats_dict); 950 server_network_stats_dict);
947 } 951 }
948 952
949 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 953 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
950 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 954 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
951 if (!setting_prefs_) 955 if (!setting_prefs_)
952 ScheduleUpdateCacheOnPrefThread(); 956 ScheduleUpdateCacheOnPrefThread();
953 } 957 }
954 958
955 } // namespace net 959 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698