| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/net/http_server_properties_manager.h" | 5 #include "chrome/browser/net/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/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 NetworkStats stats) { | 257 NetworkStats stats) { |
| 258 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); | 258 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); |
| 259 } | 259 } |
| 260 | 260 |
| 261 const HttpServerPropertiesManager::NetworkStats* | 261 const HttpServerPropertiesManager::NetworkStats* |
| 262 HttpServerPropertiesManager::GetServerNetworkStats( | 262 HttpServerPropertiesManager::GetServerNetworkStats( |
| 263 const net::HostPortPair& host_port_pair) const { | 263 const net::HostPortPair& host_port_pair) const { |
| 264 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); | 264 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); |
| 265 } | 265 } |
| 266 | 266 |
| 267 net::HttpPipelinedHostCapability | |
| 268 HttpServerPropertiesManager::GetPipelineCapability( | |
| 269 const net::HostPortPair& origin) { | |
| 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 271 return http_server_properties_impl_->GetPipelineCapability(origin); | |
| 272 } | |
| 273 | |
| 274 void HttpServerPropertiesManager::SetPipelineCapability( | |
| 275 const net::HostPortPair& origin, | |
| 276 net::HttpPipelinedHostCapability capability) { | |
| 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 278 http_server_properties_impl_->SetPipelineCapability(origin, capability); | |
| 279 ScheduleUpdatePrefsOnIO(); | |
| 280 } | |
| 281 | |
| 282 void HttpServerPropertiesManager::ClearPipelineCapabilities() { | |
| 283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 284 http_server_properties_impl_->ClearPipelineCapabilities(); | |
| 285 ScheduleUpdatePrefsOnIO(); | |
| 286 } | |
| 287 | |
| 288 net::PipelineCapabilityMap | |
| 289 HttpServerPropertiesManager::GetPipelineCapabilityMap() const { | |
| 290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 291 return http_server_properties_impl_->GetPipelineCapabilityMap(); | |
| 292 } | |
| 293 | |
| 294 // | 267 // |
| 295 // Update the HttpServerPropertiesImpl's cache with data from preferences. | 268 // Update the HttpServerPropertiesImpl's cache with data from preferences. |
| 296 // | 269 // |
| 297 void HttpServerPropertiesManager::ScheduleUpdateCacheOnUI() { | 270 void HttpServerPropertiesManager::ScheduleUpdateCacheOnUI() { |
| 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 299 // Cancel pending updates, if any. | 272 // Cancel pending updates, if any. |
| 300 ui_cache_update_timer_->Stop(); | 273 ui_cache_update_timer_->Stop(); |
| 301 StartCacheUpdateTimerOnUI( | 274 StartCacheUpdateTimerOnUI( |
| 302 base::TimeDelta::FromMilliseconds(kUpdateCacheDelayMs)); | 275 base::TimeDelta::FromMilliseconds(kUpdateCacheDelayMs)); |
| 303 } | 276 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 334 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( | 307 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( |
| 335 "servers", &servers_dict)) { | 308 "servers", &servers_dict)) { |
| 336 DVLOG(1) << "Malformed http_server_properties for servers."; | 309 DVLOG(1) << "Malformed http_server_properties for servers."; |
| 337 return; | 310 return; |
| 338 } | 311 } |
| 339 | 312 |
| 340 // String is host/port pair of spdy server. | 313 // String is host/port pair of spdy server. |
| 341 scoped_ptr<StringVector> spdy_servers(new StringVector); | 314 scoped_ptr<StringVector> spdy_servers(new StringVector); |
| 342 scoped_ptr<net::SpdySettingsMap> spdy_settings_map( | 315 scoped_ptr<net::SpdySettingsMap> spdy_settings_map( |
| 343 new net::SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); | 316 new net::SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); |
| 344 scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map( | |
| 345 new net::PipelineCapabilityMap); | |
| 346 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map( | 317 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map( |
| 347 new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist)); | 318 new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist)); |
| 348 | 319 |
| 349 for (base::DictionaryValue::Iterator it(*servers_dict); !it.IsAtEnd(); | 320 for (base::DictionaryValue::Iterator it(*servers_dict); !it.IsAtEnd(); |
| 350 it.Advance()) { | 321 it.Advance()) { |
| 351 // Get server's host/pair. | 322 // Get server's host/pair. |
| 352 const std::string& server_str = it.key(); | 323 const std::string& server_str = it.key(); |
| 353 net::HostPortPair server = net::HostPortPair::FromString(server_str); | 324 net::HostPortPair server = net::HostPortPair::FromString(server_str); |
| 354 if (server.host().empty()) { | 325 if (server.host().empty()) { |
| 355 DVLOG(1) << "Malformed http_server_properties for server: " << server_str; | 326 DVLOG(1) << "Malformed http_server_properties for server: " << server_str; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 NOTREACHED(); | 365 NOTREACHED(); |
| 395 continue; | 366 continue; |
| 396 } | 367 } |
| 397 net::SettingsFlagsAndValue flags_and_value( | 368 net::SettingsFlagsAndValue flags_and_value( |
| 398 net::SETTINGS_FLAG_PERSISTED, value); | 369 net::SETTINGS_FLAG_PERSISTED, value); |
| 399 settings_map[static_cast<net::SpdySettingsIds>(id)] = flags_and_value; | 370 settings_map[static_cast<net::SpdySettingsIds>(id)] = flags_and_value; |
| 400 } | 371 } |
| 401 spdy_settings_map->Put(server, settings_map); | 372 spdy_settings_map->Put(server, settings_map); |
| 402 } | 373 } |
| 403 | 374 |
| 404 int pipeline_capability = net::PIPELINE_UNKNOWN; | |
| 405 if ((server_pref_dict->GetInteger( | |
| 406 "pipeline_capability", &pipeline_capability)) && | |
| 407 pipeline_capability != net::PIPELINE_UNKNOWN) { | |
| 408 (*pipeline_capability_map)[server] = | |
| 409 static_cast<net::HttpPipelinedHostCapability>(pipeline_capability); | |
| 410 } | |
| 411 | |
| 412 // Get alternate_protocol server. | 375 // Get alternate_protocol server. |
| 413 DCHECK(alternate_protocol_map->Peek(server) == | 376 DCHECK(alternate_protocol_map->Peek(server) == |
| 414 alternate_protocol_map->end()); | 377 alternate_protocol_map->end()); |
| 415 const base::DictionaryValue* port_alternate_protocol_dict = NULL; | 378 const base::DictionaryValue* port_alternate_protocol_dict = NULL; |
| 416 if (!server_pref_dict->GetDictionaryWithoutPathExpansion( | 379 if (!server_pref_dict->GetDictionaryWithoutPathExpansion( |
| 417 "alternate_protocol", &port_alternate_protocol_dict)) { | 380 "alternate_protocol", &port_alternate_protocol_dict)) { |
| 418 continue; | 381 continue; |
| 419 } | 382 } |
| 420 | 383 |
| 421 do { | 384 do { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 451 | 414 |
| 452 BrowserThread::PostTask( | 415 BrowserThread::PostTask( |
| 453 BrowserThread::IO, | 416 BrowserThread::IO, |
| 454 FROM_HERE, | 417 FROM_HERE, |
| 455 base::Bind(&HttpServerPropertiesManager:: | 418 base::Bind(&HttpServerPropertiesManager:: |
| 456 UpdateCacheFromPrefsOnIO, | 419 UpdateCacheFromPrefsOnIO, |
| 457 base::Unretained(this), | 420 base::Unretained(this), |
| 458 base::Owned(spdy_servers.release()), | 421 base::Owned(spdy_servers.release()), |
| 459 base::Owned(spdy_settings_map.release()), | 422 base::Owned(spdy_settings_map.release()), |
| 460 base::Owned(alternate_protocol_map.release()), | 423 base::Owned(alternate_protocol_map.release()), |
| 461 base::Owned(pipeline_capability_map.release()), | |
| 462 detected_corrupted_prefs)); | 424 detected_corrupted_prefs)); |
| 463 } | 425 } |
| 464 | 426 |
| 465 void HttpServerPropertiesManager::UpdateCacheFromPrefsOnIO( | 427 void HttpServerPropertiesManager::UpdateCacheFromPrefsOnIO( |
| 466 StringVector* spdy_servers, | 428 StringVector* spdy_servers, |
| 467 net::SpdySettingsMap* spdy_settings_map, | 429 net::SpdySettingsMap* spdy_settings_map, |
| 468 net::AlternateProtocolMap* alternate_protocol_map, | 430 net::AlternateProtocolMap* alternate_protocol_map, |
| 469 net::PipelineCapabilityMap* pipeline_capability_map, | |
| 470 bool detected_corrupted_prefs) { | 431 bool detected_corrupted_prefs) { |
| 471 // Preferences have the master data because admins might have pushed new | 432 // Preferences have the master data because admins might have pushed new |
| 472 // preferences. Update the cached data with new data from preferences. | 433 // preferences. Update the cached data with new data from preferences. |
| 473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 474 | 435 |
| 475 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdyServers", spdy_servers->size()); | 436 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdyServers", spdy_servers->size()); |
| 476 http_server_properties_impl_->InitializeSpdyServers(spdy_servers, true); | 437 http_server_properties_impl_->InitializeSpdyServers(spdy_servers, true); |
| 477 | 438 |
| 478 // Clear the cached data and use the new spdy_settings from preferences. | 439 // Clear the cached data and use the new spdy_settings from preferences. |
| 479 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdySettings", spdy_settings_map->size()); | 440 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdySettings", spdy_settings_map->size()); |
| 480 http_server_properties_impl_->InitializeSpdySettingsServers( | 441 http_server_properties_impl_->InitializeSpdySettingsServers( |
| 481 spdy_settings_map); | 442 spdy_settings_map); |
| 482 | 443 |
| 483 // Clear the cached data and use the new Alternate-Protocol server list from | 444 // Clear the cached data and use the new Alternate-Protocol server list from |
| 484 // preferences. | 445 // preferences. |
| 485 UMA_HISTOGRAM_COUNTS("Net.CountOfAlternateProtocolServers", | 446 UMA_HISTOGRAM_COUNTS("Net.CountOfAlternateProtocolServers", |
| 486 alternate_protocol_map->size()); | 447 alternate_protocol_map->size()); |
| 487 http_server_properties_impl_->InitializeAlternateProtocolServers( | 448 http_server_properties_impl_->InitializeAlternateProtocolServers( |
| 488 alternate_protocol_map); | 449 alternate_protocol_map); |
| 489 | 450 |
| 490 UMA_HISTOGRAM_COUNTS("Net.CountOfPipelineCapableServers", | |
| 491 pipeline_capability_map->size()); | |
| 492 http_server_properties_impl_->InitializePipelineCapabilities( | |
| 493 pipeline_capability_map); | |
| 494 | |
| 495 // Update the prefs with what we have read (delete all corrupted prefs). | 451 // Update the prefs with what we have read (delete all corrupted prefs). |
| 496 if (detected_corrupted_prefs) | 452 if (detected_corrupted_prefs) |
| 497 ScheduleUpdatePrefsOnIO(); | 453 ScheduleUpdatePrefsOnIO(); |
| 498 } | 454 } |
| 499 | 455 |
| 500 | 456 |
| 501 // | 457 // |
| 502 // Update Preferences with data from the cached data. | 458 // Update Preferences with data from the cached data. |
| 503 // | 459 // |
| 504 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnIO() { | 460 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnIO() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist); | 502 new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist); |
| 547 const net::AlternateProtocolMap& map = | 503 const net::AlternateProtocolMap& map = |
| 548 http_server_properties_impl_->alternate_protocol_map(); | 504 http_server_properties_impl_->alternate_protocol_map(); |
| 549 count = 0; | 505 count = 0; |
| 550 for (net::AlternateProtocolMap::const_iterator it = map.begin(); | 506 for (net::AlternateProtocolMap::const_iterator it = map.begin(); |
| 551 it != map.end() && count < kMaxAlternateProtocolHostsToPersist; | 507 it != map.end() && count < kMaxAlternateProtocolHostsToPersist; |
| 552 ++it, ++count) { | 508 ++it, ++count) { |
| 553 alternate_protocol_map->Put(it->first, it->second); | 509 alternate_protocol_map->Put(it->first, it->second); |
| 554 } | 510 } |
| 555 | 511 |
| 556 net::PipelineCapabilityMap* pipeline_capability_map = | |
| 557 new net::PipelineCapabilityMap; | |
| 558 *pipeline_capability_map = | |
| 559 http_server_properties_impl_->GetPipelineCapabilityMap(); | |
| 560 | |
| 561 // Update the preferences on the UI thread. | 512 // Update the preferences on the UI thread. |
| 562 BrowserThread::PostTask( | 513 BrowserThread::PostTask( |
| 563 BrowserThread::UI, | 514 BrowserThread::UI, |
| 564 FROM_HERE, | 515 FROM_HERE, |
| 565 base::Bind(&HttpServerPropertiesManager::UpdatePrefsOnUI, | 516 base::Bind(&HttpServerPropertiesManager::UpdatePrefsOnUI, |
| 566 ui_weak_ptr_, | 517 ui_weak_ptr_, |
| 567 base::Owned(spdy_server_list), | 518 base::Owned(spdy_server_list), |
| 568 base::Owned(spdy_settings_map), | 519 base::Owned(spdy_settings_map), |
| 569 base::Owned(alternate_protocol_map), | 520 base::Owned(alternate_protocol_map), |
| 570 base::Owned(pipeline_capability_map), | |
| 571 completion)); | 521 completion)); |
| 572 } | 522 } |
| 573 | 523 |
| 574 // A local or temporary data structure to hold |supports_spdy|, SpdySettings, | 524 // A local or temporary data structure to hold |supports_spdy|, SpdySettings, |
| 575 // PortAlternateProtocolPair, and |pipeline_capability| preferences for a | 525 // and PortAlternateProtocolPair preferences for a server. This is used only in |
| 576 // server. This is used only in UpdatePrefsOnUI. | 526 // UpdatePrefsOnUI. |
| 577 struct ServerPref { | 527 struct ServerPref { |
| 578 ServerPref() | 528 ServerPref() |
| 579 : supports_spdy(false), | 529 : supports_spdy(false), |
| 580 settings_map(NULL), | 530 settings_map(NULL), |
| 581 alternate_protocol(NULL), | 531 alternate_protocol(NULL) { |
| 582 pipeline_capability(net::PIPELINE_UNKNOWN) { | |
| 583 } | 532 } |
| 584 ServerPref(bool supports_spdy, | 533 ServerPref(bool supports_spdy, |
| 585 const net::SettingsMap* settings_map, | 534 const net::SettingsMap* settings_map, |
| 586 const net::PortAlternateProtocolPair* alternate_protocol) | 535 const net::PortAlternateProtocolPair* alternate_protocol) |
| 587 : supports_spdy(supports_spdy), | 536 : supports_spdy(supports_spdy), |
| 588 settings_map(settings_map), | 537 settings_map(settings_map), |
| 589 alternate_protocol(alternate_protocol), | 538 alternate_protocol(alternate_protocol) { |
| 590 pipeline_capability(net::PIPELINE_UNKNOWN) { | |
| 591 } | 539 } |
| 592 bool supports_spdy; | 540 bool supports_spdy; |
| 593 const net::SettingsMap* settings_map; | 541 const net::SettingsMap* settings_map; |
| 594 const net::PortAlternateProtocolPair* alternate_protocol; | 542 const net::PortAlternateProtocolPair* alternate_protocol; |
| 595 net::HttpPipelinedHostCapability pipeline_capability; | |
| 596 }; | 543 }; |
| 597 | 544 |
| 598 void HttpServerPropertiesManager::UpdatePrefsOnUI( | 545 void HttpServerPropertiesManager::UpdatePrefsOnUI( |
| 599 base::ListValue* spdy_server_list, | 546 base::ListValue* spdy_server_list, |
| 600 net::SpdySettingsMap* spdy_settings_map, | 547 net::SpdySettingsMap* spdy_settings_map, |
| 601 net::AlternateProtocolMap* alternate_protocol_map, | 548 net::AlternateProtocolMap* alternate_protocol_map, |
| 602 net::PipelineCapabilityMap* pipeline_capability_map, | |
| 603 const base::Closure& completion) { | 549 const base::Closure& completion) { |
| 604 | 550 |
| 605 typedef std::map<net::HostPortPair, ServerPref> ServerPrefMap; | 551 typedef std::map<net::HostPortPair, ServerPref> ServerPrefMap; |
| 606 ServerPrefMap server_pref_map; | 552 ServerPrefMap server_pref_map; |
| 607 | 553 |
| 608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 609 | 555 |
| 610 // Add servers that support spdy to server_pref_map. | 556 // Add servers that support spdy to server_pref_map. |
| 611 std::string s; | 557 std::string s; |
| 612 for (base::ListValue::const_iterator list_it = spdy_server_list->begin(); | 558 for (base::ListValue::const_iterator list_it = spdy_server_list->begin(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 | 597 |
| 652 ServerPrefMap::iterator it = server_pref_map.find(server); | 598 ServerPrefMap::iterator it = server_pref_map.find(server); |
| 653 if (it == server_pref_map.end()) { | 599 if (it == server_pref_map.end()) { |
| 654 ServerPref server_pref(false, NULL, &map_it->second); | 600 ServerPref server_pref(false, NULL, &map_it->second); |
| 655 server_pref_map[server] = server_pref; | 601 server_pref_map[server] = server_pref; |
| 656 } else { | 602 } else { |
| 657 it->second.alternate_protocol = &map_it->second; | 603 it->second.alternate_protocol = &map_it->second; |
| 658 } | 604 } |
| 659 } | 605 } |
| 660 | 606 |
| 661 for (net::PipelineCapabilityMap::const_iterator map_it = | |
| 662 pipeline_capability_map->begin(); | |
| 663 map_it != pipeline_capability_map->end(); ++map_it) { | |
| 664 const net::HostPortPair& server = map_it->first; | |
| 665 const net::HttpPipelinedHostCapability& pipeline_capability = | |
| 666 map_it->second; | |
| 667 | |
| 668 ServerPrefMap::iterator it = server_pref_map.find(server); | |
| 669 if (it == server_pref_map.end()) { | |
| 670 ServerPref server_pref; | |
| 671 server_pref.pipeline_capability = pipeline_capability; | |
| 672 server_pref_map[server] = server_pref; | |
| 673 } else { | |
| 674 it->second.pipeline_capability = pipeline_capability; | |
| 675 } | |
| 676 } | |
| 677 | |
| 678 // Persist the prefs::kHttpServerProperties. | 607 // Persist the prefs::kHttpServerProperties. |
| 679 base::DictionaryValue http_server_properties_dict; | 608 base::DictionaryValue http_server_properties_dict; |
| 680 base::DictionaryValue* servers_dict = new base::DictionaryValue; | 609 base::DictionaryValue* servers_dict = new base::DictionaryValue; |
| 681 for (ServerPrefMap::const_iterator map_it = | 610 for (ServerPrefMap::const_iterator map_it = |
| 682 server_pref_map.begin(); | 611 server_pref_map.begin(); |
| 683 map_it != server_pref_map.end(); ++map_it) { | 612 map_it != server_pref_map.end(); ++map_it) { |
| 684 const net::HostPortPair& server = map_it->first; | 613 const net::HostPortPair& server = map_it->first; |
| 685 const ServerPref& server_pref = map_it->second; | 614 const ServerPref& server_pref = map_it->second; |
| 686 | 615 |
| 687 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 616 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 712 server_pref.alternate_protocol; | 641 server_pref.alternate_protocol; |
| 713 port_alternate_protocol_dict->SetInteger( | 642 port_alternate_protocol_dict->SetInteger( |
| 714 "port", port_alternate_protocol->port); | 643 "port", port_alternate_protocol->port); |
| 715 const char* protocol_str = | 644 const char* protocol_str = |
| 716 net::AlternateProtocolToString(port_alternate_protocol->protocol); | 645 net::AlternateProtocolToString(port_alternate_protocol->protocol); |
| 717 port_alternate_protocol_dict->SetString("protocol_str", protocol_str); | 646 port_alternate_protocol_dict->SetString("protocol_str", protocol_str); |
| 718 server_pref_dict->SetWithoutPathExpansion( | 647 server_pref_dict->SetWithoutPathExpansion( |
| 719 "alternate_protocol", port_alternate_protocol_dict); | 648 "alternate_protocol", port_alternate_protocol_dict); |
| 720 } | 649 } |
| 721 | 650 |
| 722 if (server_pref.pipeline_capability != net::PIPELINE_UNKNOWN) { | |
| 723 server_pref_dict->SetInteger("pipeline_capability", | |
| 724 server_pref.pipeline_capability); | |
| 725 } | |
| 726 | |
| 727 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict); | 651 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict); |
| 728 } | 652 } |
| 729 | 653 |
| 730 http_server_properties_dict.SetWithoutPathExpansion("servers", servers_dict); | 654 http_server_properties_dict.SetWithoutPathExpansion("servers", servers_dict); |
| 731 SetVersion(&http_server_properties_dict, kVersionNumber); | 655 SetVersion(&http_server_properties_dict, kVersionNumber); |
| 732 setting_prefs_ = true; | 656 setting_prefs_ = true; |
| 733 pref_service_->Set(prefs::kHttpServerProperties, | 657 pref_service_->Set(prefs::kHttpServerProperties, |
| 734 http_server_properties_dict); | 658 http_server_properties_dict); |
| 735 setting_prefs_ = false; | 659 setting_prefs_ = false; |
| 736 | 660 |
| 737 // Note that |completion| will be fired after we have written everything to | 661 // Note that |completion| will be fired after we have written everything to |
| 738 // the Preferences, but likely before these changes are serialized to disk. | 662 // the Preferences, but likely before these changes are serialized to disk. |
| 739 // This is not a problem though, as JSONPrefStore guarantees that this will | 663 // This is not a problem though, as JSONPrefStore guarantees that this will |
| 740 // happen, pretty soon, and even in the case we shut down immediately. | 664 // happen, pretty soon, and even in the case we shut down immediately. |
| 741 if (!completion.is_null()) | 665 if (!completion.is_null()) |
| 742 completion.Run(); | 666 completion.Run(); |
| 743 } | 667 } |
| 744 | 668 |
| 745 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 669 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
| 746 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 670 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 747 if (!setting_prefs_) | 671 if (!setting_prefs_) |
| 748 ScheduleUpdateCacheOnUI(); | 672 ScheduleUpdateCacheOnUI(); |
| 749 } | 673 } |
| 750 | 674 |
| 751 } // namespace chrome_browser_net | 675 } // namespace chrome_browser_net |
| OLD | NEW |