Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/test/test_mock_time_task_runner.h" | |
| 19 #include "base/test/test_simple_task_runner.h" | 20 #include "base/test/test_simple_task_runner.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "net/base/ip_address.h" | 23 #include "net/base/ip_address.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 using base::StringPrintf; | 32 using base::StringPrintf; |
| 33 using base::TestMockTimeTaskRunner; | |
| 32 using ::testing::_; | 34 using ::testing::_; |
| 33 using ::testing::Invoke; | 35 using ::testing::Invoke; |
| 34 using ::testing::Mock; | 36 using ::testing::Mock; |
| 35 using ::testing::StrictMock; | 37 using ::testing::StrictMock; |
| 36 | 38 |
| 37 class MockPrefDelegate : public net::HttpServerPropertiesManager::PrefDelegate { | 39 class MockPrefDelegate : public net::HttpServerPropertiesManager::PrefDelegate { |
| 38 public: | 40 public: |
| 39 MockPrefDelegate() {} | 41 MockPrefDelegate() {} |
| 40 ~MockPrefDelegate() override {} | 42 ~MockPrefDelegate() override {} |
| 41 | 43 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 }; | 144 }; |
| 143 | 145 |
| 144 } // namespace | 146 } // namespace |
| 145 | 147 |
| 146 // TODO(rtenneti): After we stop supporting version 3 and everyone has migrated | 148 // TODO(rtenneti): After we stop supporting version 3 and everyone has migrated |
| 147 // to version 4, delete the following code. | 149 // to version 4, delete the following code. |
| 148 static const int kHttpServerPropertiesVersions[] = {3, 4, 5}; | 150 static const int kHttpServerPropertiesVersions[] = {3, 4, 5}; |
| 149 | 151 |
| 150 class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> { | 152 class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> { |
| 151 protected: | 153 protected: |
| 152 HttpServerPropertiesManagerTest() {} | 154 HttpServerPropertiesManagerTest() |
| 155 : net_test_task_runner_(new TestMockTimeTaskRunner()) {} | |
| 153 | 156 |
| 154 void SetUp() override { | 157 void SetUp() override { |
| 155 one_day_from_now_ = base::Time::Now() + base::TimeDelta::FromDays(1); | 158 one_day_from_now_ = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 156 pref_delegate_ = new MockPrefDelegate; | 159 pref_delegate_ = new MockPrefDelegate; |
| 157 http_server_props_manager_.reset( | 160 http_server_props_manager_.reset( |
| 158 new StrictMock<TestingHttpServerPropertiesManager>( | 161 new StrictMock<TestingHttpServerPropertiesManager>( |
| 159 pref_delegate_, base::ThreadTaskRunnerHandle::Get())); | 162 pref_delegate_, net_test_task_runner_)); |
| 163 | |
| 160 ExpectCacheUpdate(); | 164 ExpectCacheUpdate(); |
| 161 base::RunLoop().RunUntilIdle(); | 165 base::RunLoop().RunUntilIdle(); |
| 162 } | 166 } |
| 163 | 167 |
| 164 void TearDown() override { | 168 void TearDown() override { |
| 165 if (http_server_props_manager_.get()) | 169 if (http_server_props_manager_.get()) |
| 166 http_server_props_manager_->ShutdownOnPrefThread(); | 170 http_server_props_manager_->ShutdownOnPrefThread(); |
| 167 base::RunLoop().RunUntilIdle(); | 171 base::RunLoop().RunUntilIdle(); |
| 168 http_server_props_manager_.reset(); | 172 http_server_props_manager_.reset(); |
| 169 } | 173 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 bool HasAlternativeService(const url::SchemeHostPort& server) { | 215 bool HasAlternativeService(const url::SchemeHostPort& server) { |
| 212 const AlternativeServiceVector alternative_service_vector = | 216 const AlternativeServiceVector alternative_service_vector = |
| 213 http_server_props_manager_->GetAlternativeServices(server); | 217 http_server_props_manager_->GetAlternativeServices(server); |
| 214 return !alternative_service_vector.empty(); | 218 return !alternative_service_vector.empty(); |
| 215 } | 219 } |
| 216 | 220 |
| 217 MockPrefDelegate* pref_delegate_; // Owned by HttpServerPropertiesManager. | 221 MockPrefDelegate* pref_delegate_; // Owned by HttpServerPropertiesManager. |
| 218 std::unique_ptr<TestingHttpServerPropertiesManager> | 222 std::unique_ptr<TestingHttpServerPropertiesManager> |
| 219 http_server_props_manager_; | 223 http_server_props_manager_; |
| 220 base::Time one_day_from_now_; | 224 base::Time one_day_from_now_; |
| 225 scoped_refptr<TestMockTimeTaskRunner> net_test_task_runner_; | |
|
Ryan Hamilton
2016/12/12 05:30:20
Just confirming, there are no new tests in the CL,
Zhongyi Shi
2016/12/12 21:14:46
Yup. New tests will come in later CLs.
| |
| 221 | 226 |
| 222 private: | 227 private: |
| 223 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest); | 228 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest); |
| 224 }; | 229 }; |
| 225 | 230 |
| 226 INSTANTIATE_TEST_CASE_P(Tests, | 231 INSTANTIATE_TEST_CASE_P(Tests, |
| 227 HttpServerPropertiesManagerTest, | 232 HttpServerPropertiesManagerTest, |
| 228 ::testing::ValuesIn(kHttpServerPropertiesVersions)); | 233 ::testing::ValuesIn(kHttpServerPropertiesVersions)); |
| 229 | 234 |
| 230 TEST_P(HttpServerPropertiesManagerTest, | 235 TEST_P(HttpServerPropertiesManagerTest, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(), | 355 quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(), |
| 351 quic_server_pref_dict3); | 356 quic_server_pref_dict3); |
| 352 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", | 357 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", |
| 353 quic_servers_dict); | 358 quic_servers_dict); |
| 354 | 359 |
| 355 // Set the same value for kHttpServerProperties multiple times. | 360 // Set the same value for kHttpServerProperties multiple times. |
| 356 pref_delegate_->SetPrefs(http_server_properties_dict); | 361 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 357 pref_delegate_->SetPrefs(http_server_properties_dict); | 362 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 358 | 363 |
| 359 base::RunLoop().RunUntilIdle(); | 364 base::RunLoop().RunUntilIdle(); |
| 365 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 366 | |
| 360 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 367 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 361 | 368 |
| 362 // Verify SupportsSpdy. | 369 // Verify SupportsSpdy. |
| 363 EXPECT_TRUE( | 370 EXPECT_TRUE( |
| 364 http_server_props_manager_->SupportsRequestPriority(google_server)); | 371 http_server_props_manager_->SupportsRequestPriority(google_server)); |
| 365 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(mail_server)); | 372 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(mail_server)); |
| 366 HostPortPair foo_host_port_pair = | 373 HostPortPair foo_host_port_pair = |
| 367 HostPortPair::FromString("foo.google.com:1337"); | 374 HostPortPair::FromString("foo.google.com:1337"); |
| 368 url::SchemeHostPort foo_server("http", foo_host_port_pair.host(), | 375 url::SchemeHostPort foo_server("http", foo_host_port_pair.host(), |
| 369 foo_host_port_pair.port()); | 376 foo_host_port_pair.port()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 google_quic_server_id)); | 447 google_quic_server_id)); |
| 441 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( | 448 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( |
| 442 mail_quic_server_id)); | 449 mail_quic_server_id)); |
| 443 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo( | 450 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo( |
| 444 play_quic_server_id)); | 451 play_quic_server_id)); |
| 445 */ | 452 */ |
| 446 } | 453 } |
| 447 | 454 |
| 448 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) { | 455 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) { |
| 449 ExpectCacheUpdate(); | 456 ExpectCacheUpdate(); |
| 450 // The prefs are automaticalls updated in the case corruption is detected. | 457 // The prefs are automatically updated in the case corruption is detected. |
| 451 ExpectPrefsUpdate(); | 458 ExpectPrefsUpdate(); |
| 452 ExpectScheduleUpdatePrefsOnNetworkThread(); | 459 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 453 | 460 |
| 454 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 461 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| 455 | 462 |
| 456 // Set supports_spdy for www.google.com:65536. | 463 // Set supports_spdy for www.google.com:65536. |
| 457 server_pref_dict->SetBoolean("supports_spdy", true); | 464 server_pref_dict->SetBoolean("supports_spdy", true); |
| 458 | 465 |
| 459 // Set up alternative_service for www.google.com:65536. | 466 // Set up alternative_service for www.google.com:65536. |
| 460 std::unique_ptr<base::DictionaryValue> alternative_service_dict( | 467 std::unique_ptr<base::DictionaryValue> alternative_service_dict( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 quic_servers_dict->SetWithoutPathExpansion("http://mail.google.com:65536", | 509 quic_servers_dict->SetWithoutPathExpansion("http://mail.google.com:65536", |
| 503 quic_server_pref_dict1); | 510 quic_server_pref_dict1); |
| 504 | 511 |
| 505 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", | 512 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", |
| 506 quic_servers_dict); | 513 quic_servers_dict); |
| 507 | 514 |
| 508 // Set up the pref. | 515 // Set up the pref. |
| 509 pref_delegate_->SetPrefs(http_server_properties_dict); | 516 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 510 | 517 |
| 511 base::RunLoop().RunUntilIdle(); | 518 base::RunLoop().RunUntilIdle(); |
| 519 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 512 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 520 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 513 | 521 |
| 514 // Verify that nothing is set. | 522 // Verify that nothing is set. |
| 515 HostPortPair google_host_port_pair = | 523 HostPortPair google_host_port_pair = |
| 516 HostPortPair::FromString("www.google.com:65536"); | 524 HostPortPair::FromString("www.google.com:65536"); |
| 517 url::SchemeHostPort gooler_server("http", google_host_port_pair.host(), | 525 url::SchemeHostPort gooler_server("http", google_host_port_pair.host(), |
| 518 google_host_port_pair.port()); | 526 google_host_port_pair.port()); |
| 519 | 527 |
| 520 EXPECT_FALSE( | 528 EXPECT_FALSE( |
| 521 http_server_props_manager_->SupportsRequestPriority(gooler_server)); | 529 http_server_props_manager_->SupportsRequestPriority(gooler_server)); |
| 522 EXPECT_FALSE(HasAlternativeService(gooler_server)); | 530 EXPECT_FALSE(HasAlternativeService(gooler_server)); |
| 523 const ServerNetworkStats* stats1 = | 531 const ServerNetworkStats* stats1 = |
| 524 http_server_props_manager_->GetServerNetworkStats(gooler_server); | 532 http_server_props_manager_->GetServerNetworkStats(gooler_server); |
| 525 EXPECT_EQ(nullptr, stats1); | 533 EXPECT_EQ(nullptr, stats1); |
| 526 EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size()); | 534 EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size()); |
| 527 } | 535 } |
| 528 | 536 |
| 529 TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) { | 537 TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) { |
| 530 ExpectCacheUpdate(); | 538 ExpectCacheUpdate(); |
| 531 // The prefs are automaticalls updated in the case corruption is detected. | 539 // The prefs are automatically updated in the case corruption is detected. |
| 532 ExpectPrefsUpdate(); | 540 ExpectPrefsUpdate(); |
| 533 ExpectScheduleUpdatePrefsOnNetworkThread(); | 541 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 534 | 542 |
| 535 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 543 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| 536 | 544 |
| 537 // Set supports_spdy for www.google.com:80. | 545 // Set supports_spdy for www.google.com:80. |
| 538 server_pref_dict->SetBoolean("supports_spdy", true); | 546 server_pref_dict->SetBoolean("supports_spdy", true); |
| 539 | 547 |
| 540 // Set up alternative_service for www.google.com:80. | 548 // Set up alternative_service for www.google.com:80. |
| 541 std::unique_ptr<base::DictionaryValue> alternative_service_dict( | 549 std::unique_ptr<base::DictionaryValue> alternative_service_dict( |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 566 HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, | 574 HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, |
| 567 GetParam()); | 575 GetParam()); |
| 568 http_server_properties_dict.SetWithoutPathExpansion( | 576 http_server_properties_dict.SetWithoutPathExpansion( |
| 569 "servers", std::move(servers_dict)); | 577 "servers", std::move(servers_dict)); |
| 570 } | 578 } |
| 571 | 579 |
| 572 // Set up the pref. | 580 // Set up the pref. |
| 573 pref_delegate_->SetPrefs(http_server_properties_dict); | 581 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 574 | 582 |
| 575 base::RunLoop().RunUntilIdle(); | 583 base::RunLoop().RunUntilIdle(); |
| 584 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 576 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 585 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 577 | 586 |
| 578 // Verify alternative service is not set. | 587 // Verify alternative service is not set. |
| 579 EXPECT_FALSE( | 588 EXPECT_FALSE( |
| 580 HasAlternativeService(url::SchemeHostPort("http", "www.google.com", 80))); | 589 HasAlternativeService(url::SchemeHostPort("http", "www.google.com", 80))); |
| 581 } | 590 } |
| 582 | 591 |
| 583 TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) { | 592 TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) { |
| 584 ExpectPrefsUpdate(); | 593 ExpectPrefsUpdate(); |
| 585 ExpectScheduleUpdatePrefsOnNetworkThread(); | 594 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 586 | 595 |
| 587 // Post an update task to the network thread. SetSupportsSpdy calls | 596 // Post an update task to the network thread. SetSupportsSpdy calls |
| 588 // ScheduleUpdatePrefsOnNetworkThread. | 597 // ScheduleUpdatePrefsOnNetworkThread. |
| 589 | 598 |
| 590 // Add mail.google.com:443 as a supporting spdy server. | 599 // Add mail.google.com:443 as a supporting spdy server. |
| 591 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); | 600 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); |
| 592 EXPECT_FALSE( | 601 EXPECT_FALSE( |
| 593 http_server_props_manager_->SupportsRequestPriority(spdy_server)); | 602 http_server_props_manager_->SupportsRequestPriority(spdy_server)); |
| 594 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); | 603 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); |
| 595 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 604 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 596 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); | 605 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); |
| 597 | 606 |
| 598 // Run the task. | 607 // Run the task. |
| 599 base::RunLoop().RunUntilIdle(); | 608 base::RunLoop().RunUntilIdle(); |
| 609 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 600 | 610 |
| 601 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); | 611 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); |
| 602 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 612 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 603 } | 613 } |
| 604 | 614 |
| 605 TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) { | 615 TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) { |
| 606 ExpectPrefsUpdate(); | 616 ExpectPrefsUpdate(); |
| 607 ExpectScheduleUpdatePrefsOnNetworkThread(); | 617 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 608 | 618 |
| 609 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); | 619 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); |
| 610 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | 620 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 611 const AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", | 621 const AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", |
| 612 443); | 622 443); |
| 613 http_server_props_manager_->SetAlternativeService( | 623 http_server_props_manager_->SetAlternativeService( |
| 614 spdy_server_mail, alternative_service, one_day_from_now_); | 624 spdy_server_mail, alternative_service, one_day_from_now_); |
| 615 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 625 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 616 http_server_props_manager_->SetAlternativeService( | 626 http_server_props_manager_->SetAlternativeService( |
| 617 spdy_server_mail, alternative_service, one_day_from_now_); | 627 spdy_server_mail, alternative_service, one_day_from_now_); |
| 618 | 628 |
| 619 // Run the task. | 629 // Run the task. |
| 620 base::RunLoop().RunUntilIdle(); | 630 base::RunLoop().RunUntilIdle(); |
| 631 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
|
Ryan Hamilton
2016/12/12 05:30:20
nit: sometimes there are newlines after this call
Zhongyi Shi
2016/12/12 21:14:46
Done.
| |
| 632 | |
| 621 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 633 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 622 | 634 |
| 623 AlternativeServiceVector alternative_service_vector = | 635 AlternativeServiceVector alternative_service_vector = |
| 624 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); | 636 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); |
| 625 ASSERT_EQ(1u, alternative_service_vector.size()); | 637 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 626 EXPECT_EQ(alternative_service, alternative_service_vector[0]); | 638 EXPECT_EQ(alternative_service, alternative_service_vector[0]); |
| 627 } | 639 } |
| 628 | 640 |
| 629 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) { | 641 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) { |
| 630 ExpectPrefsUpdate(); | 642 ExpectPrefsUpdate(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 642 alternative_service_info_vector.push_back( | 654 alternative_service_info_vector.push_back( |
| 643 AlternativeServiceInfo(alternative_service2, one_day_from_now_)); | 655 AlternativeServiceInfo(alternative_service2, one_day_from_now_)); |
| 644 http_server_props_manager_->SetAlternativeServices( | 656 http_server_props_manager_->SetAlternativeServices( |
| 645 spdy_server_mail, alternative_service_info_vector); | 657 spdy_server_mail, alternative_service_info_vector); |
| 646 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 658 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 647 http_server_props_manager_->SetAlternativeServices( | 659 http_server_props_manager_->SetAlternativeServices( |
| 648 spdy_server_mail, alternative_service_info_vector); | 660 spdy_server_mail, alternative_service_info_vector); |
| 649 | 661 |
| 650 // Run the task. | 662 // Run the task. |
| 651 base::RunLoop().RunUntilIdle(); | 663 base::RunLoop().RunUntilIdle(); |
| 664 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 665 | |
| 652 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 666 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 653 | 667 |
| 654 AlternativeServiceVector alternative_service_vector = | 668 AlternativeServiceVector alternative_service_vector = |
| 655 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); | 669 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); |
| 656 ASSERT_EQ(2u, alternative_service_vector.size()); | 670 ASSERT_EQ(2u, alternative_service_vector.size()); |
| 657 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); | 671 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); |
| 658 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); | 672 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); |
| 659 } | 673 } |
| 660 | 674 |
| 661 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) { | 675 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 alternative_service)); | 719 alternative_service)); |
| 706 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 720 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 707 http_server_props_manager_->ConfirmAlternativeService(alternative_service); | 721 http_server_props_manager_->ConfirmAlternativeService(alternative_service); |
| 708 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( | 722 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 709 alternative_service)); | 723 alternative_service)); |
| 710 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( | 724 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 711 alternative_service)); | 725 alternative_service)); |
| 712 | 726 |
| 713 // Run the task. | 727 // Run the task. |
| 714 base::RunLoop().RunUntilIdle(); | 728 base::RunLoop().RunUntilIdle(); |
| 729 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 730 | |
| 715 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 731 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 716 | 732 |
| 717 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( | 733 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 718 alternative_service)); | 734 alternative_service)); |
| 719 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( | 735 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 720 alternative_service)); | 736 alternative_service)); |
| 721 } | 737 } |
| 722 | 738 |
| 723 TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) { | 739 TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) { |
| 724 ExpectPrefsUpdate(); | 740 ExpectPrefsUpdate(); |
| 725 ExpectScheduleUpdatePrefsOnNetworkThread(); | 741 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 726 | 742 |
| 727 IPAddress address; | 743 IPAddress address; |
| 728 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); | 744 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 729 | 745 |
| 730 IPAddress actual_address(127, 0, 0, 1); | 746 IPAddress actual_address(127, 0, 0, 1); |
| 731 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 747 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 732 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 748 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 733 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 749 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 734 | 750 |
| 735 // Run the task. | 751 // Run the task. |
| 736 base::RunLoop().RunUntilIdle(); | 752 base::RunLoop().RunUntilIdle(); |
| 753 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 754 | |
| 737 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 755 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 738 | 756 |
| 739 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); | 757 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 740 EXPECT_EQ(actual_address, address); | 758 EXPECT_EQ(actual_address, address); |
| 741 } | 759 } |
| 742 | 760 |
| 743 TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) { | 761 TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) { |
| 744 ExpectPrefsUpdate(); | 762 ExpectPrefsUpdate(); |
| 745 ExpectScheduleUpdatePrefsOnNetworkThread(); | 763 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 746 | 764 |
| 747 url::SchemeHostPort mail_server("http", "mail.google.com", 80); | 765 url::SchemeHostPort mail_server("http", "mail.google.com", 80); |
| 748 const ServerNetworkStats* stats = | 766 const ServerNetworkStats* stats = |
| 749 http_server_props_manager_->GetServerNetworkStats(mail_server); | 767 http_server_props_manager_->GetServerNetworkStats(mail_server); |
| 750 EXPECT_EQ(nullptr, stats); | 768 EXPECT_EQ(nullptr, stats); |
| 751 ServerNetworkStats stats1; | 769 ServerNetworkStats stats1; |
| 752 stats1.srtt = base::TimeDelta::FromMicroseconds(10); | 770 stats1.srtt = base::TimeDelta::FromMicroseconds(10); |
| 753 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); | 771 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); |
| 754 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 772 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 755 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); | 773 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); |
| 756 | 774 |
| 757 // Run the task. | 775 // Run the task. |
| 758 base::RunLoop().RunUntilIdle(); | 776 base::RunLoop().RunUntilIdle(); |
| 777 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 778 | |
| 759 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 779 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 760 | 780 |
| 761 const ServerNetworkStats* stats2 = | 781 const ServerNetworkStats* stats2 = |
| 762 http_server_props_manager_->GetServerNetworkStats(mail_server); | 782 http_server_props_manager_->GetServerNetworkStats(mail_server); |
| 763 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); | 783 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); |
| 764 } | 784 } |
| 765 | 785 |
| 766 TEST_P(HttpServerPropertiesManagerTest, QuicServerInfo) { | 786 TEST_P(HttpServerPropertiesManagerTest, QuicServerInfo) { |
| 767 ExpectPrefsUpdate(); | 787 ExpectPrefsUpdate(); |
| 768 ExpectScheduleUpdatePrefsOnNetworkThread(); | 788 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 769 | 789 |
| 770 QuicServerId mail_quic_server_id("mail.google.com", 80); | 790 QuicServerId mail_quic_server_id("mail.google.com", 80); |
| 771 EXPECT_EQ(nullptr, | 791 EXPECT_EQ(nullptr, |
| 772 http_server_props_manager_->GetQuicServerInfo(mail_quic_server_id)); | 792 http_server_props_manager_->GetQuicServerInfo(mail_quic_server_id)); |
| 773 std::string quic_server_info1("quic_server_info1"); | 793 std::string quic_server_info1("quic_server_info1"); |
| 774 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, | 794 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, |
| 775 quic_server_info1); | 795 quic_server_info1); |
| 776 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 796 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 777 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, | 797 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, |
| 778 quic_server_info1); | 798 quic_server_info1); |
| 779 | 799 |
| 780 // Run the task. | 800 // Run the task. |
| 781 base::RunLoop().RunUntilIdle(); | 801 base::RunLoop().RunUntilIdle(); |
| 802 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 782 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 803 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 783 | 804 |
| 784 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( | 805 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( |
| 785 mail_quic_server_id)); | 806 mail_quic_server_id)); |
| 786 } | 807 } |
| 787 | 808 |
| 788 TEST_P(HttpServerPropertiesManagerTest, Clear) { | 809 TEST_P(HttpServerPropertiesManagerTest, Clear) { |
| 789 ExpectPrefsUpdate(); | 810 ExpectPrefsUpdate(); |
| 790 ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(); | 811 ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(); |
| 791 | 812 |
| 792 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); | 813 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); |
| 793 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); | 814 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); |
| 794 AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", 1234); | 815 AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", 1234); |
| 795 http_server_props_manager_->SetAlternativeService( | 816 http_server_props_manager_->SetAlternativeService( |
| 796 spdy_server, alternative_service, one_day_from_now_); | 817 spdy_server, alternative_service, one_day_from_now_); |
| 797 IPAddress actual_address(127, 0, 0, 1); | 818 IPAddress actual_address(127, 0, 0, 1); |
| 798 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 819 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 799 ServerNetworkStats stats; | 820 ServerNetworkStats stats; |
| 800 stats.srtt = base::TimeDelta::FromMicroseconds(10); | 821 stats.srtt = base::TimeDelta::FromMicroseconds(10); |
| 801 http_server_props_manager_->SetServerNetworkStats(spdy_server, stats); | 822 http_server_props_manager_->SetServerNetworkStats(spdy_server, stats); |
| 802 | 823 |
| 803 QuicServerId mail_quic_server_id("mail.google.com", 80); | 824 QuicServerId mail_quic_server_id("mail.google.com", 80); |
| 804 std::string quic_server_info1("quic_server_info1"); | 825 std::string quic_server_info1("quic_server_info1"); |
| 805 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, | 826 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, |
| 806 quic_server_info1); | 827 quic_server_info1); |
| 807 | 828 |
| 808 // Run the task. | 829 // Run the task. |
| 809 base::RunLoop().RunUntilIdle(); | 830 base::RunLoop().RunUntilIdle(); |
| 831 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 810 | 832 |
| 811 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); | 833 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); |
| 812 EXPECT_TRUE(HasAlternativeService(spdy_server)); | 834 EXPECT_TRUE(HasAlternativeService(spdy_server)); |
| 813 IPAddress address; | 835 IPAddress address; |
| 814 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); | 836 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 815 EXPECT_EQ(actual_address, address); | 837 EXPECT_EQ(actual_address, address); |
| 816 const ServerNetworkStats* stats1 = | 838 const ServerNetworkStats* stats1 = |
| 817 http_server_props_manager_->GetServerNetworkStats(spdy_server); | 839 http_server_props_manager_->GetServerNetworkStats(spdy_server); |
| 818 EXPECT_EQ(10, stats1->srtt.ToInternalValue()); | 840 EXPECT_EQ(10, stats1->srtt.ToInternalValue()); |
| 819 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( | 841 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 905 base::DictionaryValue* supports_quic = new base::DictionaryValue; | 927 base::DictionaryValue* supports_quic = new base::DictionaryValue; |
| 906 supports_quic->SetBoolean("used_quic", true); | 928 supports_quic->SetBoolean("used_quic", true); |
| 907 supports_quic->SetString("address", "127.0.0.1"); | 929 supports_quic->SetString("address", "127.0.0.1"); |
| 908 http_server_properties_dict.SetWithoutPathExpansion("supports_quic", | 930 http_server_properties_dict.SetWithoutPathExpansion("supports_quic", |
| 909 supports_quic); | 931 supports_quic); |
| 910 | 932 |
| 911 // Set up the pref. | 933 // Set up the pref. |
| 912 pref_delegate_->SetPrefs(http_server_properties_dict); | 934 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 913 | 935 |
| 914 base::RunLoop().RunUntilIdle(); | 936 base::RunLoop().RunUntilIdle(); |
| 937 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 915 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 938 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 916 | 939 |
| 917 // Verify alternative service. | 940 // Verify alternative service. |
| 918 for (int i = 1; i <= 200; ++i) { | 941 for (int i = 1; i <= 200; ++i) { |
| 919 GURL server_gurl; | 942 GURL server_gurl; |
| 920 if (GetParam() >= 5) { | 943 if (GetParam() >= 5) { |
| 921 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); | 944 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); |
| 922 } else { | 945 } else { |
| 923 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); | 946 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); |
| 924 } | 947 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 quic_server_info1); | 999 quic_server_info1); |
| 977 | 1000 |
| 978 // Set SupportsQuic. | 1001 // Set SupportsQuic. |
| 979 IPAddress actual_address(127, 0, 0, 1); | 1002 IPAddress actual_address(127, 0, 0, 1); |
| 980 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 1003 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 981 | 1004 |
| 982 // Update cache. | 1005 // Update cache. |
| 983 ExpectPrefsUpdate(); | 1006 ExpectPrefsUpdate(); |
| 984 ExpectCacheUpdate(); | 1007 ExpectCacheUpdate(); |
| 985 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); | 1008 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); |
| 1009 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 986 base::RunLoop().RunUntilIdle(); | 1010 base::RunLoop().RunUntilIdle(); |
| 987 | 1011 |
| 988 // Verify preferences. | 1012 // Verify preferences. |
| 989 const char expected_json[] = | 1013 const char expected_json[] = |
| 990 "{\"quic_servers\":{\"https://" | 1014 "{\"quic_servers\":{\"https://" |
| 991 "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}}," | 1015 "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}}," |
| 992 "\"servers\":[" | 1016 "\"servers\":[" |
| 993 "{\"http://www.google.com\":{" | 1017 "{\"http://www.google.com\":{" |
| 994 "\"alternative_service\":[{\"expiration\":\"13756212000000000\"," | 1018 "\"alternative_service\":[{\"expiration\":\"13756212000000000\"," |
| 995 "\"port\":443,\"protocol_str\":\"h2\"}," | 1019 "\"port\":443,\"protocol_str\":\"h2\"}," |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1107 AlternativeServiceInfo(valid_alternative_service, time_one_day_later)); | 1131 AlternativeServiceInfo(valid_alternative_service, time_one_day_later)); |
| 1108 | 1132 |
| 1109 const url::SchemeHostPort server("https", "www.example.com", 443); | 1133 const url::SchemeHostPort server("https", "www.example.com", 443); |
| 1110 http_server_props_manager_->SetAlternativeServices( | 1134 http_server_props_manager_->SetAlternativeServices( |
| 1111 server, alternative_service_info_vector); | 1135 server, alternative_service_info_vector); |
| 1112 | 1136 |
| 1113 // Update cache. | 1137 // Update cache. |
| 1114 ExpectPrefsUpdate(); | 1138 ExpectPrefsUpdate(); |
| 1115 ExpectCacheUpdate(); | 1139 ExpectCacheUpdate(); |
| 1116 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); | 1140 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); |
| 1141 | |
| 1142 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 1117 base::RunLoop().RunUntilIdle(); | 1143 base::RunLoop().RunUntilIdle(); |
| 1118 | 1144 |
| 1119 const base::DictionaryValue& pref_dict = | 1145 const base::DictionaryValue& pref_dict = |
| 1120 pref_delegate_->GetServerProperties(); | 1146 pref_delegate_->GetServerProperties(); |
| 1121 | 1147 |
| 1122 const base::ListValue* servers_list = nullptr; | 1148 const base::ListValue* servers_list = nullptr; |
| 1123 ASSERT_TRUE(pref_dict.GetListWithoutPathExpansion("servers", &servers_list)); | 1149 ASSERT_TRUE(pref_dict.GetListWithoutPathExpansion("servers", &servers_list)); |
| 1124 base::ListValue::const_iterator it = servers_list->begin(); | 1150 base::ListValue::const_iterator it = servers_list->begin(); |
| 1125 const base::DictionaryValue* server_pref_dict; | 1151 const base::DictionaryValue* server_pref_dict; |
| 1126 ASSERT_TRUE((*it)->GetAsDictionary(&server_pref_dict)); | 1152 ASSERT_TRUE((*it)->GetAsDictionary(&server_pref_dict)); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 base::RunLoop().RunUntilIdle(); | 1260 base::RunLoop().RunUntilIdle(); |
| 1235 } | 1261 } |
| 1236 | 1262 |
| 1237 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { | 1263 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { |
| 1238 ExpectPrefsUpdate(); | 1264 ExpectPrefsUpdate(); |
| 1239 // Post an update task. | 1265 // Post an update task. |
| 1240 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); | 1266 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); |
| 1241 // Shutdown comes before the task is executed. | 1267 // Shutdown comes before the task is executed. |
| 1242 http_server_props_manager_->ShutdownOnPrefThread(); | 1268 http_server_props_manager_->ShutdownOnPrefThread(); |
| 1243 // Run the task after shutdown, but before deletion. | 1269 // Run the task after shutdown, but before deletion. |
| 1270 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 1244 base::RunLoop().RunUntilIdle(); | 1271 base::RunLoop().RunUntilIdle(); |
| 1245 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 1272 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 1246 http_server_props_manager_.reset(); | 1273 http_server_props_manager_.reset(); |
| 1247 base::RunLoop().RunUntilIdle(); | 1274 base::RunLoop().RunUntilIdle(); |
| 1248 } | 1275 } |
| 1249 | 1276 |
| 1250 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { | 1277 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { |
| 1251 // This posts a task to the UI thread. | 1278 // This posts a task to the UI thread. |
| 1252 http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete( | 1279 http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete( |
| 1253 base::Closure()); | 1280 base::Closure()); |
| 1254 // Shutdown comes before the task is executed. | 1281 // Shutdown comes before the task is executed. |
| 1255 http_server_props_manager_->ShutdownOnPrefThread(); | 1282 http_server_props_manager_->ShutdownOnPrefThread(); |
| 1256 // Run the task after shutdown, but before deletion. | 1283 // Run the task after shutdown, but before deletion. |
| 1257 base::RunLoop().RunUntilIdle(); | 1284 base::RunLoop().RunUntilIdle(); |
| 1258 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 1285 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 1259 http_server_props_manager_.reset(); | 1286 http_server_props_manager_.reset(); |
| 1260 base::RunLoop().RunUntilIdle(); | 1287 base::RunLoop().RunUntilIdle(); |
| 1261 } | 1288 } |
| 1262 | 1289 |
| 1263 } // namespace net | 1290 } // namespace net |
| OLD | NEW |