| 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/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 NetworkStats stats) { | 271 NetworkStats stats) { |
| 272 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); | 272 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); |
| 273 } | 273 } |
| 274 | 274 |
| 275 const HttpServerPropertiesManager::NetworkStats* | 275 const HttpServerPropertiesManager::NetworkStats* |
| 276 HttpServerPropertiesManager::GetServerNetworkStats( | 276 HttpServerPropertiesManager::GetServerNetworkStats( |
| 277 const net::HostPortPair& host_port_pair) const { | 277 const net::HostPortPair& host_port_pair) const { |
| 278 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); | 278 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); |
| 279 } | 279 } |
| 280 | 280 |
| 281 net::HttpPipelinedHostCapability | |
| 282 HttpServerPropertiesManager::GetPipelineCapability( | |
| 283 const net::HostPortPair& origin) { | |
| 284 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 285 return http_server_properties_impl_->GetPipelineCapability(origin); | |
| 286 } | |
| 287 | |
| 288 void HttpServerPropertiesManager::SetPipelineCapability( | |
| 289 const net::HostPortPair& origin, | |
| 290 net::HttpPipelinedHostCapability capability) { | |
| 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 292 http_server_properties_impl_->SetPipelineCapability(origin, capability); | |
| 293 ScheduleUpdatePrefsOnIO(); | |
| 294 } | |
| 295 | |
| 296 void HttpServerPropertiesManager::ClearPipelineCapabilities() { | |
| 297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 298 http_server_properties_impl_->ClearPipelineCapabilities(); | |
| 299 ScheduleUpdatePrefsOnIO(); | |
| 300 } | |
| 301 | |
| 302 net::PipelineCapabilityMap | |
| 303 HttpServerPropertiesManager::GetPipelineCapabilityMap() const { | |
| 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 305 return http_server_properties_impl_->GetPipelineCapabilityMap(); | |
| 306 } | |
| 307 | |
| 308 // | 281 // |
| 309 // Update the HttpServerPropertiesImpl's cache with data from preferences. | 282 // Update the HttpServerPropertiesImpl's cache with data from preferences. |
| 310 // | 283 // |
| 311 void HttpServerPropertiesManager::ScheduleUpdateCacheOnUI() { | 284 void HttpServerPropertiesManager::ScheduleUpdateCacheOnUI() { |
| 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 313 // Cancel pending updates, if any. | 286 // Cancel pending updates, if any. |
| 314 ui_cache_update_timer_->Stop(); | 287 ui_cache_update_timer_->Stop(); |
| 315 StartCacheUpdateTimerOnUI( | 288 StartCacheUpdateTimerOnUI( |
| 316 base::TimeDelta::FromMilliseconds(kUpdateCacheDelayMs)); | 289 base::TimeDelta::FromMilliseconds(kUpdateCacheDelayMs)); |
| 317 } | 290 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 348 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( | 321 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( |
| 349 "servers", &servers_dict)) { | 322 "servers", &servers_dict)) { |
| 350 DVLOG(1) << "Malformed http_server_properties for servers."; | 323 DVLOG(1) << "Malformed http_server_properties for servers."; |
| 351 return; | 324 return; |
| 352 } | 325 } |
| 353 | 326 |
| 354 // String is host/port pair of spdy server. | 327 // String is host/port pair of spdy server. |
| 355 scoped_ptr<StringVector> spdy_servers(new StringVector); | 328 scoped_ptr<StringVector> spdy_servers(new StringVector); |
| 356 scoped_ptr<net::SpdySettingsMap> spdy_settings_map( | 329 scoped_ptr<net::SpdySettingsMap> spdy_settings_map( |
| 357 new net::SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); | 330 new net::SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); |
| 358 scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map( | |
| 359 new net::PipelineCapabilityMap); | |
| 360 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map( | 331 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map( |
| 361 new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist)); | 332 new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist)); |
| 362 // TODO(rtenneti): Delete the following code after the experiment. | 333 // TODO(rtenneti): Delete the following code after the experiment. |
| 363 int alternate_protocols_to_load = k200AlternateProtocolHostsToLoad; | 334 int alternate_protocols_to_load = k200AlternateProtocolHostsToLoad; |
| 364 net::AlternateProtocolExperiment alternate_protocol_experiment = | 335 net::AlternateProtocolExperiment alternate_protocol_experiment = |
| 365 net::ALTERNATE_PROTOCOL_NOT_PART_OF_EXPERIMENT; | 336 net::ALTERNATE_PROTOCOL_NOT_PART_OF_EXPERIMENT; |
| 366 if (version == kVersionNumber) { | 337 if (version == kVersionNumber) { |
| 367 if (base::RandInt(0, 99) == 0) { | 338 if (base::RandInt(0, 99) == 0) { |
| 368 alternate_protocol_experiment = | 339 alternate_protocol_experiment = |
| 369 net::ALTERNATE_PROTOCOL_TRUNCATED_200_SERVERS; | 340 net::ALTERNATE_PROTOCOL_TRUNCATED_200_SERVERS; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 NOTREACHED(); | 396 NOTREACHED(); |
| 426 continue; | 397 continue; |
| 427 } | 398 } |
| 428 net::SettingsFlagsAndValue flags_and_value( | 399 net::SettingsFlagsAndValue flags_and_value( |
| 429 net::SETTINGS_FLAG_PERSISTED, value); | 400 net::SETTINGS_FLAG_PERSISTED, value); |
| 430 settings_map[static_cast<net::SpdySettingsIds>(id)] = flags_and_value; | 401 settings_map[static_cast<net::SpdySettingsIds>(id)] = flags_and_value; |
| 431 } | 402 } |
| 432 spdy_settings_map->Put(server, settings_map); | 403 spdy_settings_map->Put(server, settings_map); |
| 433 } | 404 } |
| 434 | 405 |
| 435 int pipeline_capability = net::PIPELINE_UNKNOWN; | |
| 436 if ((server_pref_dict->GetInteger( | |
| 437 "pipeline_capability", &pipeline_capability)) && | |
| 438 pipeline_capability != net::PIPELINE_UNKNOWN) { | |
| 439 (*pipeline_capability_map)[server] = | |
| 440 static_cast<net::HttpPipelinedHostCapability>(pipeline_capability); | |
| 441 } | |
| 442 | |
| 443 // Get alternate_protocol server. | 406 // Get alternate_protocol server. |
| 444 DCHECK(alternate_protocol_map->Peek(server) == | 407 DCHECK(alternate_protocol_map->Peek(server) == |
| 445 alternate_protocol_map->end()); | 408 alternate_protocol_map->end()); |
| 446 const base::DictionaryValue* port_alternate_protocol_dict = NULL; | 409 const base::DictionaryValue* port_alternate_protocol_dict = NULL; |
| 447 if (!server_pref_dict->GetDictionaryWithoutPathExpansion( | 410 if (!server_pref_dict->GetDictionaryWithoutPathExpansion( |
| 448 "alternate_protocol", &port_alternate_protocol_dict)) { | 411 "alternate_protocol", &port_alternate_protocol_dict)) { |
| 449 continue; | 412 continue; |
| 450 } | 413 } |
| 451 | 414 |
| 452 if (count >= alternate_protocols_to_load) | 415 if (count >= alternate_protocols_to_load) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 448 |
| 486 BrowserThread::PostTask( | 449 BrowserThread::PostTask( |
| 487 BrowserThread::IO, | 450 BrowserThread::IO, |
| 488 FROM_HERE, | 451 FROM_HERE, |
| 489 base::Bind(&HttpServerPropertiesManager:: | 452 base::Bind(&HttpServerPropertiesManager:: |
| 490 UpdateCacheFromPrefsOnIO, | 453 UpdateCacheFromPrefsOnIO, |
| 491 base::Unretained(this), | 454 base::Unretained(this), |
| 492 base::Owned(spdy_servers.release()), | 455 base::Owned(spdy_servers.release()), |
| 493 base::Owned(spdy_settings_map.release()), | 456 base::Owned(spdy_settings_map.release()), |
| 494 base::Owned(alternate_protocol_map.release()), | 457 base::Owned(alternate_protocol_map.release()), |
| 495 base::Owned(pipeline_capability_map.release()), | |
| 496 alternate_protocol_experiment, | 458 alternate_protocol_experiment, |
| 497 detected_corrupted_prefs)); | 459 detected_corrupted_prefs)); |
| 498 } | 460 } |
| 499 | 461 |
| 500 void HttpServerPropertiesManager::UpdateCacheFromPrefsOnIO( | 462 void HttpServerPropertiesManager::UpdateCacheFromPrefsOnIO( |
| 501 StringVector* spdy_servers, | 463 StringVector* spdy_servers, |
| 502 net::SpdySettingsMap* spdy_settings_map, | 464 net::SpdySettingsMap* spdy_settings_map, |
| 503 net::AlternateProtocolMap* alternate_protocol_map, | 465 net::AlternateProtocolMap* alternate_protocol_map, |
| 504 net::PipelineCapabilityMap* pipeline_capability_map, | |
| 505 net::AlternateProtocolExperiment alternate_protocol_experiment, | 466 net::AlternateProtocolExperiment alternate_protocol_experiment, |
| 506 bool detected_corrupted_prefs) { | 467 bool detected_corrupted_prefs) { |
| 507 // Preferences have the master data because admins might have pushed new | 468 // Preferences have the master data because admins might have pushed new |
| 508 // preferences. Update the cached data with new data from preferences. | 469 // preferences. Update the cached data with new data from preferences. |
| 509 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 510 | 471 |
| 511 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdyServers", spdy_servers->size()); | 472 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdyServers", spdy_servers->size()); |
| 512 http_server_properties_impl_->InitializeSpdyServers(spdy_servers, true); | 473 http_server_properties_impl_->InitializeSpdyServers(spdy_servers, true); |
| 513 | 474 |
| 514 // Update the cached data and use the new spdy_settings from preferences. | 475 // Update the cached data and use the new spdy_settings from preferences. |
| 515 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdySettings", spdy_settings_map->size()); | 476 UMA_HISTOGRAM_COUNTS("Net.CountOfSpdySettings", spdy_settings_map->size()); |
| 516 http_server_properties_impl_->InitializeSpdySettingsServers( | 477 http_server_properties_impl_->InitializeSpdySettingsServers( |
| 517 spdy_settings_map); | 478 spdy_settings_map); |
| 518 | 479 |
| 519 // Update the cached data and use the new Alternate-Protocol server list from | 480 // Update the cached data and use the new Alternate-Protocol server list from |
| 520 // preferences. | 481 // preferences. |
| 521 UMA_HISTOGRAM_COUNTS("Net.CountOfAlternateProtocolServers", | 482 UMA_HISTOGRAM_COUNTS("Net.CountOfAlternateProtocolServers", |
| 522 alternate_protocol_map->size()); | 483 alternate_protocol_map->size()); |
| 523 http_server_properties_impl_->InitializeAlternateProtocolServers( | 484 http_server_properties_impl_->InitializeAlternateProtocolServers( |
| 524 alternate_protocol_map); | 485 alternate_protocol_map); |
| 525 http_server_properties_impl_->SetAlternateProtocolExperiment( | 486 http_server_properties_impl_->SetAlternateProtocolExperiment( |
| 526 alternate_protocol_experiment); | 487 alternate_protocol_experiment); |
| 527 | 488 |
| 528 UMA_HISTOGRAM_COUNTS("Net.CountOfPipelineCapableServers", | |
| 529 pipeline_capability_map->size()); | |
| 530 http_server_properties_impl_->InitializePipelineCapabilities( | |
| 531 pipeline_capability_map); | |
| 532 | |
| 533 // Update the prefs with what we have read (delete all corrupted prefs). | 489 // Update the prefs with what we have read (delete all corrupted prefs). |
| 534 if (detected_corrupted_prefs) | 490 if (detected_corrupted_prefs) |
| 535 ScheduleUpdatePrefsOnIO(); | 491 ScheduleUpdatePrefsOnIO(); |
| 536 } | 492 } |
| 537 | 493 |
| 538 | 494 |
| 539 // | 495 // |
| 540 // Update Preferences with data from the cached data. | 496 // Update Preferences with data from the cached data. |
| 541 // | 497 // |
| 542 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnIO() { | 498 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnIO() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 http_server_properties_impl_->GetCanonicalSuffix(server); | 551 http_server_properties_impl_->GetCanonicalSuffix(server); |
| 596 if (!canonical_suffix.empty()) { | 552 if (!canonical_suffix.empty()) { |
| 597 if (persisted_map.find(canonical_suffix) != persisted_map.end()) | 553 if (persisted_map.find(canonical_suffix) != persisted_map.end()) |
| 598 continue; | 554 continue; |
| 599 persisted_map[canonical_suffix] = true; | 555 persisted_map[canonical_suffix] = true; |
| 600 } | 556 } |
| 601 alternate_protocol_map->Put(server, it->second); | 557 alternate_protocol_map->Put(server, it->second); |
| 602 ++count; | 558 ++count; |
| 603 } | 559 } |
| 604 | 560 |
| 605 net::PipelineCapabilityMap* pipeline_capability_map = | |
| 606 new net::PipelineCapabilityMap; | |
| 607 *pipeline_capability_map = | |
| 608 http_server_properties_impl_->GetPipelineCapabilityMap(); | |
| 609 | |
| 610 // Update the preferences on the UI thread. | 561 // Update the preferences on the UI thread. |
| 611 BrowserThread::PostTask( | 562 BrowserThread::PostTask( |
| 612 BrowserThread::UI, | 563 BrowserThread::UI, |
| 613 FROM_HERE, | 564 FROM_HERE, |
| 614 base::Bind(&HttpServerPropertiesManager::UpdatePrefsOnUI, | 565 base::Bind(&HttpServerPropertiesManager::UpdatePrefsOnUI, |
| 615 ui_weak_ptr_, | 566 ui_weak_ptr_, |
| 616 base::Owned(spdy_server_list), | 567 base::Owned(spdy_server_list), |
| 617 base::Owned(spdy_settings_map), | 568 base::Owned(spdy_settings_map), |
| 618 base::Owned(alternate_protocol_map), | 569 base::Owned(alternate_protocol_map), |
| 619 base::Owned(pipeline_capability_map), | |
| 620 completion)); | 570 completion)); |
| 621 } | 571 } |
| 622 | 572 |
| 623 // A local or temporary data structure to hold |supports_spdy|, SpdySettings, | 573 // A local or temporary data structure to hold |supports_spdy|, SpdySettings, |
| 624 // PortAlternateProtocolPair, and |pipeline_capability| preferences for a | 574 // and PortAlternateProtocolPair preferences for a server. This is used only in |
| 625 // server. This is used only in UpdatePrefsOnUI. | 575 // UpdatePrefsOnUI. |
| 626 struct ServerPref { | 576 struct ServerPref { |
| 627 ServerPref() | 577 ServerPref() |
| 628 : supports_spdy(false), | 578 : supports_spdy(false), |
| 629 settings_map(NULL), | 579 settings_map(NULL), |
| 630 alternate_protocol(NULL), | 580 alternate_protocol(NULL) { |
| 631 pipeline_capability(net::PIPELINE_UNKNOWN) { | |
| 632 } | 581 } |
| 633 ServerPref(bool supports_spdy, | 582 ServerPref(bool supports_spdy, |
| 634 const net::SettingsMap* settings_map, | 583 const net::SettingsMap* settings_map, |
| 635 const net::PortAlternateProtocolPair* alternate_protocol) | 584 const net::PortAlternateProtocolPair* alternate_protocol) |
| 636 : supports_spdy(supports_spdy), | 585 : supports_spdy(supports_spdy), |
| 637 settings_map(settings_map), | 586 settings_map(settings_map), |
| 638 alternate_protocol(alternate_protocol), | 587 alternate_protocol(alternate_protocol) { |
| 639 pipeline_capability(net::PIPELINE_UNKNOWN) { | |
| 640 } | 588 } |
| 641 bool supports_spdy; | 589 bool supports_spdy; |
| 642 const net::SettingsMap* settings_map; | 590 const net::SettingsMap* settings_map; |
| 643 const net::PortAlternateProtocolPair* alternate_protocol; | 591 const net::PortAlternateProtocolPair* alternate_protocol; |
| 644 net::HttpPipelinedHostCapability pipeline_capability; | |
| 645 }; | 592 }; |
| 646 | 593 |
| 647 void HttpServerPropertiesManager::UpdatePrefsOnUI( | 594 void HttpServerPropertiesManager::UpdatePrefsOnUI( |
| 648 base::ListValue* spdy_server_list, | 595 base::ListValue* spdy_server_list, |
| 649 net::SpdySettingsMap* spdy_settings_map, | 596 net::SpdySettingsMap* spdy_settings_map, |
| 650 net::AlternateProtocolMap* alternate_protocol_map, | 597 net::AlternateProtocolMap* alternate_protocol_map, |
| 651 net::PipelineCapabilityMap* pipeline_capability_map, | |
| 652 const base::Closure& completion) { | 598 const base::Closure& completion) { |
| 653 | 599 |
| 654 typedef std::map<net::HostPortPair, ServerPref> ServerPrefMap; | 600 typedef std::map<net::HostPortPair, ServerPref> ServerPrefMap; |
| 655 ServerPrefMap server_pref_map; | 601 ServerPrefMap server_pref_map; |
| 656 | 602 |
| 657 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 603 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 658 | 604 |
| 659 // Add servers that support spdy to server_pref_map. | 605 // Add servers that support spdy to server_pref_map. |
| 660 std::string s; | 606 std::string s; |
| 661 for (base::ListValue::const_iterator list_it = spdy_server_list->begin(); | 607 for (base::ListValue::const_iterator list_it = spdy_server_list->begin(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 646 |
| 701 ServerPrefMap::iterator it = server_pref_map.find(server); | 647 ServerPrefMap::iterator it = server_pref_map.find(server); |
| 702 if (it == server_pref_map.end()) { | 648 if (it == server_pref_map.end()) { |
| 703 ServerPref server_pref(false, NULL, &map_it->second); | 649 ServerPref server_pref(false, NULL, &map_it->second); |
| 704 server_pref_map[server] = server_pref; | 650 server_pref_map[server] = server_pref; |
| 705 } else { | 651 } else { |
| 706 it->second.alternate_protocol = &map_it->second; | 652 it->second.alternate_protocol = &map_it->second; |
| 707 } | 653 } |
| 708 } | 654 } |
| 709 | 655 |
| 710 for (net::PipelineCapabilityMap::const_iterator map_it = | |
| 711 pipeline_capability_map->begin(); | |
| 712 map_it != pipeline_capability_map->end(); ++map_it) { | |
| 713 const net::HostPortPair& server = map_it->first; | |
| 714 const net::HttpPipelinedHostCapability& pipeline_capability = | |
| 715 map_it->second; | |
| 716 | |
| 717 ServerPrefMap::iterator it = server_pref_map.find(server); | |
| 718 if (it == server_pref_map.end()) { | |
| 719 ServerPref server_pref; | |
| 720 server_pref.pipeline_capability = pipeline_capability; | |
| 721 server_pref_map[server] = server_pref; | |
| 722 } else { | |
| 723 it->second.pipeline_capability = pipeline_capability; | |
| 724 } | |
| 725 } | |
| 726 | |
| 727 // Persist the prefs::kHttpServerProperties. | 656 // Persist the prefs::kHttpServerProperties. |
| 728 base::DictionaryValue http_server_properties_dict; | 657 base::DictionaryValue http_server_properties_dict; |
| 729 base::DictionaryValue* servers_dict = new base::DictionaryValue; | 658 base::DictionaryValue* servers_dict = new base::DictionaryValue; |
| 730 for (ServerPrefMap::const_iterator map_it = | 659 for (ServerPrefMap::const_iterator map_it = |
| 731 server_pref_map.begin(); | 660 server_pref_map.begin(); |
| 732 map_it != server_pref_map.end(); ++map_it) { | 661 map_it != server_pref_map.end(); ++map_it) { |
| 733 const net::HostPortPair& server = map_it->first; | 662 const net::HostPortPair& server = map_it->first; |
| 734 const ServerPref& server_pref = map_it->second; | 663 const ServerPref& server_pref = map_it->second; |
| 735 | 664 |
| 736 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 665 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 761 server_pref.alternate_protocol; | 690 server_pref.alternate_protocol; |
| 762 port_alternate_protocol_dict->SetInteger( | 691 port_alternate_protocol_dict->SetInteger( |
| 763 "port", port_alternate_protocol->port); | 692 "port", port_alternate_protocol->port); |
| 764 const char* protocol_str = | 693 const char* protocol_str = |
| 765 net::AlternateProtocolToString(port_alternate_protocol->protocol); | 694 net::AlternateProtocolToString(port_alternate_protocol->protocol); |
| 766 port_alternate_protocol_dict->SetString("protocol_str", protocol_str); | 695 port_alternate_protocol_dict->SetString("protocol_str", protocol_str); |
| 767 server_pref_dict->SetWithoutPathExpansion( | 696 server_pref_dict->SetWithoutPathExpansion( |
| 768 "alternate_protocol", port_alternate_protocol_dict); | 697 "alternate_protocol", port_alternate_protocol_dict); |
| 769 } | 698 } |
| 770 | 699 |
| 771 if (server_pref.pipeline_capability != net::PIPELINE_UNKNOWN) { | |
| 772 server_pref_dict->SetInteger("pipeline_capability", | |
| 773 server_pref.pipeline_capability); | |
| 774 } | |
| 775 | |
| 776 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict); | 700 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict); |
| 777 } | 701 } |
| 778 | 702 |
| 779 http_server_properties_dict.SetWithoutPathExpansion("servers", servers_dict); | 703 http_server_properties_dict.SetWithoutPathExpansion("servers", servers_dict); |
| 780 SetVersion(&http_server_properties_dict, kVersionNumber); | 704 SetVersion(&http_server_properties_dict, kVersionNumber); |
| 781 setting_prefs_ = true; | 705 setting_prefs_ = true; |
| 782 pref_service_->Set(prefs::kHttpServerProperties, | 706 pref_service_->Set(prefs::kHttpServerProperties, |
| 783 http_server_properties_dict); | 707 http_server_properties_dict); |
| 784 setting_prefs_ = false; | 708 setting_prefs_ = false; |
| 785 | 709 |
| 786 // Note that |completion| will be fired after we have written everything to | 710 // Note that |completion| will be fired after we have written everything to |
| 787 // the Preferences, but likely before these changes are serialized to disk. | 711 // the Preferences, but likely before these changes are serialized to disk. |
| 788 // This is not a problem though, as JSONPrefStore guarantees that this will | 712 // This is not a problem though, as JSONPrefStore guarantees that this will |
| 789 // happen, pretty soon, and even in the case we shut down immediately. | 713 // happen, pretty soon, and even in the case we shut down immediately. |
| 790 if (!completion.is_null()) | 714 if (!completion.is_null()) |
| 791 completion.Run(); | 715 completion.Run(); |
| 792 } | 716 } |
| 793 | 717 |
| 794 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 718 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
| 795 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 719 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 796 if (!setting_prefs_) | 720 if (!setting_prefs_) |
| 797 ScheduleUpdateCacheOnUI(); | 721 ScheduleUpdateCacheOnUI(); |
| 798 } | 722 } |
| 799 | 723 |
| 800 } // namespace chrome_browser_net | 724 } // namespace chrome_browser_net |
| OLD | NEW |