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 |
| 30 class HttpServerPropertiesManagerPeer { | |
| 31 public: | |
| 32 static void SetNetworkTaskRunnerForTimer( | |
| 33 HttpServerPropertiesManager* manager, | |
| 34 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) { | |
| 35 manager->network_prefs_update_timer_->SetTaskRunner( | |
| 36 std::move(network_task_runner)); | |
| 37 } | |
| 38 }; | |
| 39 | |
| 29 namespace { | 40 namespace { |
| 30 | 41 |
| 31 using base::StringPrintf; | 42 using base::StringPrintf; |
| 43 using base::TestMockTimeTaskRunner; | |
| 32 using ::testing::_; | 44 using ::testing::_; |
| 33 using ::testing::Invoke; | 45 using ::testing::Invoke; |
| 34 using ::testing::Mock; | 46 using ::testing::Mock; |
| 35 using ::testing::StrictMock; | 47 using ::testing::StrictMock; |
| 36 | 48 |
| 37 class MockPrefDelegate : public net::HttpServerPropertiesManager::PrefDelegate { | 49 class MockPrefDelegate : public net::HttpServerPropertiesManager::PrefDelegate { |
| 38 public: | 50 public: |
| 39 MockPrefDelegate() {} | 51 MockPrefDelegate() {} |
| 40 ~MockPrefDelegate() override {} | 52 ~MockPrefDelegate() override {} |
| 41 | 53 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 }; | 154 }; |
| 143 | 155 |
| 144 } // namespace | 156 } // namespace |
| 145 | 157 |
| 146 // TODO(rtenneti): After we stop supporting version 3 and everyone has migrated | 158 // TODO(rtenneti): After we stop supporting version 3 and everyone has migrated |
| 147 // to version 4, delete the following code. | 159 // to version 4, delete the following code. |
| 148 static const int kHttpServerPropertiesVersions[] = {3, 4, 5}; | 160 static const int kHttpServerPropertiesVersions[] = {3, 4, 5}; |
| 149 | 161 |
| 150 class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> { | 162 class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> { |
| 151 protected: | 163 protected: |
| 152 HttpServerPropertiesManagerTest() {} | 164 HttpServerPropertiesManagerTest() |
| 165 : net_test_task_runner_(new TestMockTimeTaskRunner()) {} | |
| 153 | 166 |
| 154 void SetUp() override { | 167 void SetUp() override { |
| 155 one_day_from_now_ = base::Time::Now() + base::TimeDelta::FromDays(1); | 168 one_day_from_now_ = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 156 pref_delegate_ = new MockPrefDelegate; | 169 pref_delegate_ = new MockPrefDelegate; |
| 157 http_server_props_manager_.reset( | 170 http_server_props_manager_.reset( |
| 158 new StrictMock<TestingHttpServerPropertiesManager>( | 171 new StrictMock<TestingHttpServerPropertiesManager>( |
| 159 pref_delegate_, base::ThreadTaskRunnerHandle::Get())); | 172 pref_delegate_, net_test_task_runner_)); |
| 173 // Set up the network timer in manager to post tasks to | |
| 174 // |net_test_task_runner_|. | |
| 175 HttpServerPropertiesManagerPeer::SetNetworkTaskRunnerForTimer( | |
| 176 http_server_props_manager_.get(), net_test_task_runner_); | |
|
Ryan Hamilton
2016/12/11 19:36:57
Instead of doing this in the test, can you change
Zhongyi Shi
2016/12/12 05:08:39
Done.
| |
| 177 | |
| 160 ExpectCacheUpdate(); | 178 ExpectCacheUpdate(); |
| 161 base::RunLoop().RunUntilIdle(); | 179 base::RunLoop().RunUntilIdle(); |
| 162 } | 180 } |
| 163 | 181 |
| 164 void TearDown() override { | 182 void TearDown() override { |
| 165 if (http_server_props_manager_.get()) | 183 if (http_server_props_manager_.get()) |
| 166 http_server_props_manager_->ShutdownOnPrefThread(); | 184 http_server_props_manager_->ShutdownOnPrefThread(); |
| 167 base::RunLoop().RunUntilIdle(); | 185 base::RunLoop().RunUntilIdle(); |
| 168 http_server_props_manager_.reset(); | 186 http_server_props_manager_.reset(); |
| 169 } | 187 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 bool HasAlternativeService(const url::SchemeHostPort& server) { | 229 bool HasAlternativeService(const url::SchemeHostPort& server) { |
| 212 const AlternativeServiceVector alternative_service_vector = | 230 const AlternativeServiceVector alternative_service_vector = |
| 213 http_server_props_manager_->GetAlternativeServices(server); | 231 http_server_props_manager_->GetAlternativeServices(server); |
| 214 return !alternative_service_vector.empty(); | 232 return !alternative_service_vector.empty(); |
| 215 } | 233 } |
| 216 | 234 |
| 217 MockPrefDelegate* pref_delegate_; // Owned by HttpServerPropertiesManager. | 235 MockPrefDelegate* pref_delegate_; // Owned by HttpServerPropertiesManager. |
| 218 std::unique_ptr<TestingHttpServerPropertiesManager> | 236 std::unique_ptr<TestingHttpServerPropertiesManager> |
| 219 http_server_props_manager_; | 237 http_server_props_manager_; |
| 220 base::Time one_day_from_now_; | 238 base::Time one_day_from_now_; |
| 239 scoped_refptr<TestMockTimeTaskRunner> net_test_task_runner_; | |
| 221 | 240 |
| 222 private: | 241 private: |
| 223 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest); | 242 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest); |
| 224 }; | 243 }; |
| 225 | 244 |
| 226 INSTANTIATE_TEST_CASE_P(Tests, | 245 INSTANTIATE_TEST_CASE_P(Tests, |
| 227 HttpServerPropertiesManagerTest, | 246 HttpServerPropertiesManagerTest, |
| 228 ::testing::ValuesIn(kHttpServerPropertiesVersions)); | 247 ::testing::ValuesIn(kHttpServerPropertiesVersions)); |
| 229 | 248 |
| 230 TEST_P(HttpServerPropertiesManagerTest, | 249 TEST_P(HttpServerPropertiesManagerTest, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 QuicServerId play_quic_server_id("play.google.com", 443); | 368 QuicServerId play_quic_server_id("play.google.com", 443); |
| 350 quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(), | 369 quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(), |
| 351 quic_server_pref_dict3); | 370 quic_server_pref_dict3); |
| 352 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", | 371 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", |
| 353 quic_servers_dict); | 372 quic_servers_dict); |
| 354 | 373 |
| 355 // Set the same value for kHttpServerProperties multiple times. | 374 // Set the same value for kHttpServerProperties multiple times. |
| 356 pref_delegate_->SetPrefs(http_server_properties_dict); | 375 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 357 pref_delegate_->SetPrefs(http_server_properties_dict); | 376 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 358 | 377 |
| 359 base::RunLoop().RunUntilIdle(); | 378 base::RunLoop().RunUntilIdle(); |
|
Ryan Hamilton
2016/12/11 19:36:57
base::RunLoop().RunUntilIdle(); runs the main mess
Zhongyi Shi
2016/12/12 04:38:54
Yup. This is the pref's thread's runner. And in th
| |
| 379 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 380 | |
| 360 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 381 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 361 | 382 |
| 362 // Verify SupportsSpdy. | 383 // Verify SupportsSpdy. |
| 363 EXPECT_TRUE( | 384 EXPECT_TRUE( |
| 364 http_server_props_manager_->SupportsRequestPriority(google_server)); | 385 http_server_props_manager_->SupportsRequestPriority(google_server)); |
| 365 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(mail_server)); | 386 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(mail_server)); |
| 366 HostPortPair foo_host_port_pair = | 387 HostPortPair foo_host_port_pair = |
| 367 HostPortPair::FromString("foo.google.com:1337"); | 388 HostPortPair::FromString("foo.google.com:1337"); |
| 368 url::SchemeHostPort foo_server("http", foo_host_port_pair.host(), | 389 url::SchemeHostPort foo_server("http", foo_host_port_pair.host(), |
| 369 foo_host_port_pair.port()); | 390 foo_host_port_pair.port()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 google_quic_server_id)); | 461 google_quic_server_id)); |
| 441 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( | 462 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( |
| 442 mail_quic_server_id)); | 463 mail_quic_server_id)); |
| 443 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo( | 464 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo( |
| 444 play_quic_server_id)); | 465 play_quic_server_id)); |
| 445 */ | 466 */ |
| 446 } | 467 } |
| 447 | 468 |
| 448 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) { | 469 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) { |
| 449 ExpectCacheUpdate(); | 470 ExpectCacheUpdate(); |
| 450 // The prefs are automaticalls updated in the case corruption is detected. | 471 // The prefs are automatically updated in the case corruption is detected. |
| 451 ExpectPrefsUpdate(); | 472 ExpectPrefsUpdate(); |
| 452 ExpectScheduleUpdatePrefsOnNetworkThread(); | 473 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 453 | 474 |
| 454 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 475 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| 455 | 476 |
| 456 // Set supports_spdy for www.google.com:65536. | 477 // Set supports_spdy for www.google.com:65536. |
| 457 server_pref_dict->SetBoolean("supports_spdy", true); | 478 server_pref_dict->SetBoolean("supports_spdy", true); |
| 458 | 479 |
| 459 // Set up alternative_service for www.google.com:65536. | 480 // Set up alternative_service for www.google.com:65536. |
| 460 std::unique_ptr<base::DictionaryValue> alternative_service_dict( | 481 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", | 523 quic_servers_dict->SetWithoutPathExpansion("http://mail.google.com:65536", |
| 503 quic_server_pref_dict1); | 524 quic_server_pref_dict1); |
| 504 | 525 |
| 505 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", | 526 http_server_properties_dict.SetWithoutPathExpansion("quic_servers", |
| 506 quic_servers_dict); | 527 quic_servers_dict); |
| 507 | 528 |
| 508 // Set up the pref. | 529 // Set up the pref. |
| 509 pref_delegate_->SetPrefs(http_server_properties_dict); | 530 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 510 | 531 |
| 511 base::RunLoop().RunUntilIdle(); | 532 base::RunLoop().RunUntilIdle(); |
| 533 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 512 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 534 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 513 | 535 |
| 514 // Verify that nothing is set. | 536 // Verify that nothing is set. |
| 515 HostPortPair google_host_port_pair = | 537 HostPortPair google_host_port_pair = |
| 516 HostPortPair::FromString("www.google.com:65536"); | 538 HostPortPair::FromString("www.google.com:65536"); |
| 517 url::SchemeHostPort gooler_server("http", google_host_port_pair.host(), | 539 url::SchemeHostPort gooler_server("http", google_host_port_pair.host(), |
| 518 google_host_port_pair.port()); | 540 google_host_port_pair.port()); |
| 519 | 541 |
| 520 EXPECT_FALSE( | 542 EXPECT_FALSE( |
| 521 http_server_props_manager_->SupportsRequestPriority(gooler_server)); | 543 http_server_props_manager_->SupportsRequestPriority(gooler_server)); |
| 522 EXPECT_FALSE(HasAlternativeService(gooler_server)); | 544 EXPECT_FALSE(HasAlternativeService(gooler_server)); |
| 523 const ServerNetworkStats* stats1 = | 545 const ServerNetworkStats* stats1 = |
| 524 http_server_props_manager_->GetServerNetworkStats(gooler_server); | 546 http_server_props_manager_->GetServerNetworkStats(gooler_server); |
| 525 EXPECT_EQ(nullptr, stats1); | 547 EXPECT_EQ(nullptr, stats1); |
| 526 EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size()); | 548 EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size()); |
| 527 } | 549 } |
| 528 | 550 |
| 529 TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) { | 551 TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) { |
| 530 ExpectCacheUpdate(); | 552 ExpectCacheUpdate(); |
| 531 // The prefs are automaticalls updated in the case corruption is detected. | 553 // The prefs are automatically updated in the case corruption is detected. |
| 532 ExpectPrefsUpdate(); | 554 ExpectPrefsUpdate(); |
| 533 ExpectScheduleUpdatePrefsOnNetworkThread(); | 555 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 534 | 556 |
| 535 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 557 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| 536 | 558 |
| 537 // Set supports_spdy for www.google.com:80. | 559 // Set supports_spdy for www.google.com:80. |
| 538 server_pref_dict->SetBoolean("supports_spdy", true); | 560 server_pref_dict->SetBoolean("supports_spdy", true); |
| 539 | 561 |
| 540 // Set up alternative_service for www.google.com:80. | 562 // Set up alternative_service for www.google.com:80. |
| 541 std::unique_ptr<base::DictionaryValue> alternative_service_dict( | 563 std::unique_ptr<base::DictionaryValue> alternative_service_dict( |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 566 HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, | 588 HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, |
| 567 GetParam()); | 589 GetParam()); |
| 568 http_server_properties_dict.SetWithoutPathExpansion( | 590 http_server_properties_dict.SetWithoutPathExpansion( |
| 569 "servers", std::move(servers_dict)); | 591 "servers", std::move(servers_dict)); |
| 570 } | 592 } |
| 571 | 593 |
| 572 // Set up the pref. | 594 // Set up the pref. |
| 573 pref_delegate_->SetPrefs(http_server_properties_dict); | 595 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 574 | 596 |
| 575 base::RunLoop().RunUntilIdle(); | 597 base::RunLoop().RunUntilIdle(); |
| 598 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 576 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 599 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 577 | 600 |
| 578 // Verify alternative service is not set. | 601 // Verify alternative service is not set. |
| 579 EXPECT_FALSE( | 602 EXPECT_FALSE( |
| 580 HasAlternativeService(url::SchemeHostPort("http", "www.google.com", 80))); | 603 HasAlternativeService(url::SchemeHostPort("http", "www.google.com", 80))); |
| 581 } | 604 } |
| 582 | 605 |
| 583 TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) { | 606 TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) { |
| 584 ExpectPrefsUpdate(); | 607 ExpectPrefsUpdate(); |
| 585 ExpectScheduleUpdatePrefsOnNetworkThread(); | 608 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 586 | 609 |
| 587 // Post an update task to the network thread. SetSupportsSpdy calls | 610 // Post an update task to the network thread. SetSupportsSpdy calls |
| 588 // ScheduleUpdatePrefsOnNetworkThread. | 611 // ScheduleUpdatePrefsOnNetworkThread. |
| 589 | 612 |
| 590 // Add mail.google.com:443 as a supporting spdy server. | 613 // Add mail.google.com:443 as a supporting spdy server. |
| 591 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); | 614 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); |
| 592 EXPECT_FALSE( | 615 EXPECT_FALSE( |
| 593 http_server_props_manager_->SupportsRequestPriority(spdy_server)); | 616 http_server_props_manager_->SupportsRequestPriority(spdy_server)); |
| 594 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); | 617 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); |
| 595 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 618 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 596 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); | 619 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); |
| 597 | 620 |
| 598 // Run the task. | 621 // Run the task. |
| 599 base::RunLoop().RunUntilIdle(); | 622 base::RunLoop().RunUntilIdle(); |
| 623 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 600 | 624 |
| 601 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); | 625 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); |
| 602 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 626 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 603 } | 627 } |
| 604 | 628 |
| 605 TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) { | 629 TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) { |
| 606 ExpectPrefsUpdate(); | 630 ExpectPrefsUpdate(); |
| 607 ExpectScheduleUpdatePrefsOnNetworkThread(); | 631 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 608 | 632 |
| 609 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); | 633 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); |
| 610 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | 634 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 611 const AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", | 635 const AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", |
| 612 443); | 636 443); |
| 613 http_server_props_manager_->SetAlternativeService( | 637 http_server_props_manager_->SetAlternativeService( |
| 614 spdy_server_mail, alternative_service, one_day_from_now_); | 638 spdy_server_mail, alternative_service, one_day_from_now_); |
| 615 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 639 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 616 http_server_props_manager_->SetAlternativeService( | 640 http_server_props_manager_->SetAlternativeService( |
| 617 spdy_server_mail, alternative_service, one_day_from_now_); | 641 spdy_server_mail, alternative_service, one_day_from_now_); |
| 618 | 642 |
| 619 // Run the task. | 643 // Run the task. |
| 620 base::RunLoop().RunUntilIdle(); | 644 base::RunLoop().RunUntilIdle(); |
| 645 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 646 | |
| 621 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 647 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 622 | 648 |
| 623 AlternativeServiceVector alternative_service_vector = | 649 AlternativeServiceVector alternative_service_vector = |
| 624 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); | 650 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); |
| 625 ASSERT_EQ(1u, alternative_service_vector.size()); | 651 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 626 EXPECT_EQ(alternative_service, alternative_service_vector[0]); | 652 EXPECT_EQ(alternative_service, alternative_service_vector[0]); |
| 627 } | 653 } |
| 628 | 654 |
| 629 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) { | 655 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) { |
| 630 ExpectPrefsUpdate(); | 656 ExpectPrefsUpdate(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 642 alternative_service_info_vector.push_back( | 668 alternative_service_info_vector.push_back( |
| 643 AlternativeServiceInfo(alternative_service2, one_day_from_now_)); | 669 AlternativeServiceInfo(alternative_service2, one_day_from_now_)); |
| 644 http_server_props_manager_->SetAlternativeServices( | 670 http_server_props_manager_->SetAlternativeServices( |
| 645 spdy_server_mail, alternative_service_info_vector); | 671 spdy_server_mail, alternative_service_info_vector); |
| 646 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 672 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 647 http_server_props_manager_->SetAlternativeServices( | 673 http_server_props_manager_->SetAlternativeServices( |
| 648 spdy_server_mail, alternative_service_info_vector); | 674 spdy_server_mail, alternative_service_info_vector); |
| 649 | 675 |
| 650 // Run the task. | 676 // Run the task. |
| 651 base::RunLoop().RunUntilIdle(); | 677 base::RunLoop().RunUntilIdle(); |
| 678 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 679 | |
| 652 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 680 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 653 | 681 |
| 654 AlternativeServiceVector alternative_service_vector = | 682 AlternativeServiceVector alternative_service_vector = |
| 655 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); | 683 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); |
| 656 ASSERT_EQ(2u, alternative_service_vector.size()); | 684 ASSERT_EQ(2u, alternative_service_vector.size()); |
| 657 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); | 685 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); |
| 658 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); | 686 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); |
| 659 } | 687 } |
| 660 | 688 |
| 661 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) { | 689 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 alternative_service)); | 733 alternative_service)); |
| 706 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 734 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 707 http_server_props_manager_->ConfirmAlternativeService(alternative_service); | 735 http_server_props_manager_->ConfirmAlternativeService(alternative_service); |
| 708 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( | 736 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 709 alternative_service)); | 737 alternative_service)); |
| 710 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( | 738 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 711 alternative_service)); | 739 alternative_service)); |
| 712 | 740 |
| 713 // Run the task. | 741 // Run the task. |
| 714 base::RunLoop().RunUntilIdle(); | 742 base::RunLoop().RunUntilIdle(); |
| 743 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 744 | |
| 715 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 745 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 716 | 746 |
| 717 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( | 747 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 718 alternative_service)); | 748 alternative_service)); |
| 719 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( | 749 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 720 alternative_service)); | 750 alternative_service)); |
| 721 } | 751 } |
| 722 | 752 |
| 723 TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) { | 753 TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) { |
| 724 ExpectPrefsUpdate(); | 754 ExpectPrefsUpdate(); |
| 725 ExpectScheduleUpdatePrefsOnNetworkThread(); | 755 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 726 | 756 |
| 727 IPAddress address; | 757 IPAddress address; |
| 728 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); | 758 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 729 | 759 |
| 730 IPAddress actual_address(127, 0, 0, 1); | 760 IPAddress actual_address(127, 0, 0, 1); |
| 731 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 761 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 732 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 762 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 733 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 763 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 734 | 764 |
| 735 // Run the task. | 765 // Run the task. |
| 736 base::RunLoop().RunUntilIdle(); | 766 base::RunLoop().RunUntilIdle(); |
| 767 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 768 | |
| 737 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 769 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 738 | 770 |
| 739 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); | 771 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 740 EXPECT_EQ(actual_address, address); | 772 EXPECT_EQ(actual_address, address); |
| 741 } | 773 } |
| 742 | 774 |
| 743 TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) { | 775 TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) { |
| 744 ExpectPrefsUpdate(); | 776 ExpectPrefsUpdate(); |
| 745 ExpectScheduleUpdatePrefsOnNetworkThread(); | 777 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 746 | 778 |
| 747 url::SchemeHostPort mail_server("http", "mail.google.com", 80); | 779 url::SchemeHostPort mail_server("http", "mail.google.com", 80); |
| 748 const ServerNetworkStats* stats = | 780 const ServerNetworkStats* stats = |
| 749 http_server_props_manager_->GetServerNetworkStats(mail_server); | 781 http_server_props_manager_->GetServerNetworkStats(mail_server); |
| 750 EXPECT_EQ(nullptr, stats); | 782 EXPECT_EQ(nullptr, stats); |
| 751 ServerNetworkStats stats1; | 783 ServerNetworkStats stats1; |
| 752 stats1.srtt = base::TimeDelta::FromMicroseconds(10); | 784 stats1.srtt = base::TimeDelta::FromMicroseconds(10); |
| 753 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); | 785 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); |
| 754 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 786 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 755 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); | 787 http_server_props_manager_->SetServerNetworkStats(mail_server, stats1); |
| 756 | 788 |
| 757 // Run the task. | 789 // Run the task. |
| 758 base::RunLoop().RunUntilIdle(); | 790 base::RunLoop().RunUntilIdle(); |
| 791 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 792 | |
| 759 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 793 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 760 | 794 |
| 761 const ServerNetworkStats* stats2 = | 795 const ServerNetworkStats* stats2 = |
| 762 http_server_props_manager_->GetServerNetworkStats(mail_server); | 796 http_server_props_manager_->GetServerNetworkStats(mail_server); |
| 763 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); | 797 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); |
| 764 } | 798 } |
| 765 | 799 |
| 766 TEST_P(HttpServerPropertiesManagerTest, QuicServerInfo) { | 800 TEST_P(HttpServerPropertiesManagerTest, QuicServerInfo) { |
| 767 ExpectPrefsUpdate(); | 801 ExpectPrefsUpdate(); |
| 768 ExpectScheduleUpdatePrefsOnNetworkThread(); | 802 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 769 | 803 |
| 770 QuicServerId mail_quic_server_id("mail.google.com", 80); | 804 QuicServerId mail_quic_server_id("mail.google.com", 80); |
| 771 EXPECT_EQ(nullptr, | 805 EXPECT_EQ(nullptr, |
| 772 http_server_props_manager_->GetQuicServerInfo(mail_quic_server_id)); | 806 http_server_props_manager_->GetQuicServerInfo(mail_quic_server_id)); |
| 773 std::string quic_server_info1("quic_server_info1"); | 807 std::string quic_server_info1("quic_server_info1"); |
| 774 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, | 808 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, |
| 775 quic_server_info1); | 809 quic_server_info1); |
| 776 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 810 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 777 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, | 811 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, |
| 778 quic_server_info1); | 812 quic_server_info1); |
| 779 | 813 |
| 780 // Run the task. | 814 // Run the task. |
| 781 base::RunLoop().RunUntilIdle(); | 815 base::RunLoop().RunUntilIdle(); |
| 816 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 782 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 817 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 783 | 818 |
| 784 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( | 819 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( |
| 785 mail_quic_server_id)); | 820 mail_quic_server_id)); |
| 786 } | 821 } |
| 787 | 822 |
| 788 TEST_P(HttpServerPropertiesManagerTest, Clear) { | 823 TEST_P(HttpServerPropertiesManagerTest, Clear) { |
| 789 ExpectPrefsUpdate(); | 824 ExpectPrefsUpdate(); |
| 790 ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(); | 825 ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(); |
| 791 | 826 |
| 792 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); | 827 url::SchemeHostPort spdy_server("https", "mail.google.com", 443); |
| 793 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); | 828 http_server_props_manager_->SetSupportsSpdy(spdy_server, true); |
| 794 AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", 1234); | 829 AlternativeService alternative_service(kProtoHTTP2, "mail.google.com", 1234); |
| 795 http_server_props_manager_->SetAlternativeService( | 830 http_server_props_manager_->SetAlternativeService( |
| 796 spdy_server, alternative_service, one_day_from_now_); | 831 spdy_server, alternative_service, one_day_from_now_); |
| 797 IPAddress actual_address(127, 0, 0, 1); | 832 IPAddress actual_address(127, 0, 0, 1); |
| 798 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 833 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 799 ServerNetworkStats stats; | 834 ServerNetworkStats stats; |
| 800 stats.srtt = base::TimeDelta::FromMicroseconds(10); | 835 stats.srtt = base::TimeDelta::FromMicroseconds(10); |
| 801 http_server_props_manager_->SetServerNetworkStats(spdy_server, stats); | 836 http_server_props_manager_->SetServerNetworkStats(spdy_server, stats); |
| 802 | 837 |
| 803 QuicServerId mail_quic_server_id("mail.google.com", 80); | 838 QuicServerId mail_quic_server_id("mail.google.com", 80); |
| 804 std::string quic_server_info1("quic_server_info1"); | 839 std::string quic_server_info1("quic_server_info1"); |
| 805 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, | 840 http_server_props_manager_->SetQuicServerInfo(mail_quic_server_id, |
| 806 quic_server_info1); | 841 quic_server_info1); |
| 807 | 842 |
| 808 // Run the task. | 843 // Run the task. |
| 809 base::RunLoop().RunUntilIdle(); | 844 base::RunLoop().RunUntilIdle(); |
| 845 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 810 | 846 |
| 811 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); | 847 EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server)); |
| 812 EXPECT_TRUE(HasAlternativeService(spdy_server)); | 848 EXPECT_TRUE(HasAlternativeService(spdy_server)); |
| 813 IPAddress address; | 849 IPAddress address; |
| 814 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); | 850 EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 815 EXPECT_EQ(actual_address, address); | 851 EXPECT_EQ(actual_address, address); |
| 816 const ServerNetworkStats* stats1 = | 852 const ServerNetworkStats* stats1 = |
| 817 http_server_props_manager_->GetServerNetworkStats(spdy_server); | 853 http_server_props_manager_->GetServerNetworkStats(spdy_server); |
| 818 EXPECT_EQ(10, stats1->srtt.ToInternalValue()); | 854 EXPECT_EQ(10, stats1->srtt.ToInternalValue()); |
| 819 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( | 855 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; | 941 base::DictionaryValue* supports_quic = new base::DictionaryValue; |
| 906 supports_quic->SetBoolean("used_quic", true); | 942 supports_quic->SetBoolean("used_quic", true); |
| 907 supports_quic->SetString("address", "127.0.0.1"); | 943 supports_quic->SetString("address", "127.0.0.1"); |
| 908 http_server_properties_dict.SetWithoutPathExpansion("supports_quic", | 944 http_server_properties_dict.SetWithoutPathExpansion("supports_quic", |
| 909 supports_quic); | 945 supports_quic); |
| 910 | 946 |
| 911 // Set up the pref. | 947 // Set up the pref. |
| 912 pref_delegate_->SetPrefs(http_server_properties_dict); | 948 pref_delegate_->SetPrefs(http_server_properties_dict); |
| 913 | 949 |
| 914 base::RunLoop().RunUntilIdle(); | 950 base::RunLoop().RunUntilIdle(); |
| 951 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 915 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 952 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 916 | 953 |
| 917 // Verify alternative service. | 954 // Verify alternative service. |
| 918 for (int i = 1; i <= 200; ++i) { | 955 for (int i = 1; i <= 200; ++i) { |
| 919 GURL server_gurl; | 956 GURL server_gurl; |
| 920 if (GetParam() >= 5) { | 957 if (GetParam() >= 5) { |
| 921 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); | 958 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); |
| 922 } else { | 959 } else { |
| 923 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); | 960 server_gurl = GURL(StringPrintf("https://www.google.com:%d", i)); |
| 924 } | 961 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 quic_server_info1); | 1013 quic_server_info1); |
| 977 | 1014 |
| 978 // Set SupportsQuic. | 1015 // Set SupportsQuic. |
| 979 IPAddress actual_address(127, 0, 0, 1); | 1016 IPAddress actual_address(127, 0, 0, 1); |
| 980 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 1017 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 981 | 1018 |
| 982 // Update cache. | 1019 // Update cache. |
| 983 ExpectPrefsUpdate(); | 1020 ExpectPrefsUpdate(); |
| 984 ExpectCacheUpdate(); | 1021 ExpectCacheUpdate(); |
| 985 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); | 1022 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); |
| 1023 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 986 base::RunLoop().RunUntilIdle(); | 1024 base::RunLoop().RunUntilIdle(); |
| 987 | 1025 |
| 988 // Verify preferences. | 1026 // Verify preferences. |
| 989 const char expected_json[] = | 1027 const char expected_json[] = |
| 990 "{\"quic_servers\":{\"https://" | 1028 "{\"quic_servers\":{\"https://" |
| 991 "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}}," | 1029 "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}}," |
| 992 "\"servers\":[" | 1030 "\"servers\":[" |
| 993 "{\"http://www.google.com\":{" | 1031 "{\"http://www.google.com\":{" |
| 994 "\"alternative_service\":[{\"expiration\":\"13756212000000000\"," | 1032 "\"alternative_service\":[{\"expiration\":\"13756212000000000\"," |
| 995 "\"port\":443,\"protocol_str\":\"h2\"}," | 1033 "\"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)); | 1145 AlternativeServiceInfo(valid_alternative_service, time_one_day_later)); |
| 1108 | 1146 |
| 1109 const url::SchemeHostPort server("https", "www.example.com", 443); | 1147 const url::SchemeHostPort server("https", "www.example.com", 443); |
| 1110 http_server_props_manager_->SetAlternativeServices( | 1148 http_server_props_manager_->SetAlternativeServices( |
| 1111 server, alternative_service_info_vector); | 1149 server, alternative_service_info_vector); |
| 1112 | 1150 |
| 1113 // Update cache. | 1151 // Update cache. |
| 1114 ExpectPrefsUpdate(); | 1152 ExpectPrefsUpdate(); |
| 1115 ExpectCacheUpdate(); | 1153 ExpectCacheUpdate(); |
| 1116 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); | 1154 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); |
| 1155 | |
| 1156 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 1117 base::RunLoop().RunUntilIdle(); | 1157 base::RunLoop().RunUntilIdle(); |
| 1118 | 1158 |
| 1119 const base::DictionaryValue& pref_dict = | 1159 const base::DictionaryValue& pref_dict = |
| 1120 pref_delegate_->GetServerProperties(); | 1160 pref_delegate_->GetServerProperties(); |
| 1121 | 1161 |
| 1122 const base::ListValue* servers_list = nullptr; | 1162 const base::ListValue* servers_list = nullptr; |
| 1123 ASSERT_TRUE(pref_dict.GetListWithoutPathExpansion("servers", &servers_list)); | 1163 ASSERT_TRUE(pref_dict.GetListWithoutPathExpansion("servers", &servers_list)); |
| 1124 base::ListValue::const_iterator it = servers_list->begin(); | 1164 base::ListValue::const_iterator it = servers_list->begin(); |
| 1125 const base::DictionaryValue* server_pref_dict; | 1165 const base::DictionaryValue* server_pref_dict; |
| 1126 ASSERT_TRUE((*it)->GetAsDictionary(&server_pref_dict)); | 1166 ASSERT_TRUE((*it)->GetAsDictionary(&server_pref_dict)); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 base::RunLoop().RunUntilIdle(); | 1274 base::RunLoop().RunUntilIdle(); |
| 1235 } | 1275 } |
| 1236 | 1276 |
| 1237 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { | 1277 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { |
| 1238 ExpectPrefsUpdate(); | 1278 ExpectPrefsUpdate(); |
| 1239 // Post an update task. | 1279 // Post an update task. |
| 1240 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); | 1280 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); |
| 1241 // Shutdown comes before the task is executed. | 1281 // Shutdown comes before the task is executed. |
| 1242 http_server_props_manager_->ShutdownOnPrefThread(); | 1282 http_server_props_manager_->ShutdownOnPrefThread(); |
| 1243 // Run the task after shutdown, but before deletion. | 1283 // Run the task after shutdown, but before deletion. |
| 1284 net_test_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 1244 base::RunLoop().RunUntilIdle(); | 1285 base::RunLoop().RunUntilIdle(); |
| 1245 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 1286 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 1246 http_server_props_manager_.reset(); | 1287 http_server_props_manager_.reset(); |
| 1247 base::RunLoop().RunUntilIdle(); | 1288 base::RunLoop().RunUntilIdle(); |
| 1248 } | 1289 } |
| 1249 | 1290 |
| 1250 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { | 1291 TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { |
| 1251 // This posts a task to the UI thread. | 1292 // This posts a task to the UI thread. |
| 1252 http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete( | 1293 http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete( |
| 1253 base::Closure()); | 1294 base::Closure()); |
| 1254 // Shutdown comes before the task is executed. | 1295 // Shutdown comes before the task is executed. |
| 1255 http_server_props_manager_->ShutdownOnPrefThread(); | 1296 http_server_props_manager_->ShutdownOnPrefThread(); |
| 1256 // Run the task after shutdown, but before deletion. | 1297 // Run the task after shutdown, but before deletion. |
| 1257 base::RunLoop().RunUntilIdle(); | 1298 base::RunLoop().RunUntilIdle(); |
| 1258 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 1299 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 1259 http_server_props_manager_.reset(); | 1300 http_server_props_manager_.reset(); |
| 1260 base::RunLoop().RunUntilIdle(); | 1301 base::RunLoop().RunUntilIdle(); |
| 1261 } | 1302 } |
| 1262 | 1303 |
| 1263 } // namespace net | 1304 } // namespace net |
| OLD | NEW |