Chromium Code Reviews| 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 "net/http/http_server_properties_manager.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
| 11 #include "base/run_loop.h" | |
| 12 #include "base/test/test_simple_task_runner.h" | |
| 11 #include "base/values.h" | 13 #include "base/values.h" |
| 12 #include "chrome/common/pref_names.h" | |
| 13 #include "content/public/test/test_browser_thread.h" | |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace chrome_browser_net { | 18 namespace net { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 using ::testing::_; | 22 using ::testing::_; |
| 23 using ::testing::Invoke; | 23 using ::testing::Invoke; |
| 24 using ::testing::Mock; | 24 using ::testing::Mock; |
| 25 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
| 26 using content::BrowserThread; | 26 |
| 27 const char kTestHttpServerProperties[] = "TestHttpServerProperties"; | |
| 27 | 28 |
| 28 class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager { | 29 class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager { |
| 29 public: | 30 public: |
| 30 explicit TestingHttpServerPropertiesManager(PrefService* pref_service) | 31 TestingHttpServerPropertiesManager( |
| 31 : HttpServerPropertiesManager(pref_service) { | 32 PrefService* pref_service, |
| 32 InitializeOnIOThread(); | 33 const char* pref_path, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) | |
| 35 : HttpServerPropertiesManager(pref_service, pref_path, io_task_runner) { | |
| 36 InitializeOnNetworkThread(); | |
| 33 } | 37 } |
| 34 | 38 |
| 35 virtual ~TestingHttpServerPropertiesManager() { | 39 virtual ~TestingHttpServerPropertiesManager() {} |
| 36 } | |
| 37 | 40 |
| 38 // Make these methods public for testing. | 41 // Make these methods public for testing. |
| 39 using HttpServerPropertiesManager::ScheduleUpdateCacheOnUI; | 42 using HttpServerPropertiesManager::ScheduleUpdateCacheOnPrefThread; |
| 40 using HttpServerPropertiesManager::ScheduleUpdatePrefsOnIO; | 43 using HttpServerPropertiesManager::ScheduleUpdatePrefsOnNetworkThread; |
| 41 | 44 |
| 42 // Post tasks without a delay during tests. | 45 // Post tasks without a delay during tests. |
| 43 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay) OVERRIDE { | 46 virtual void StartPrefsUpdateTimerOnNetworkThread( |
| 44 HttpServerPropertiesManager::StartPrefsUpdateTimerOnIO( | 47 base::TimeDelta delay) OVERRIDE { |
| 48 HttpServerPropertiesManager::StartPrefsUpdateTimerOnNetworkThread( | |
| 45 base::TimeDelta()); | 49 base::TimeDelta()); |
| 46 } | 50 } |
| 47 | 51 |
| 48 void UpdateCacheFromPrefsOnUIConcrete() { | 52 void UpdateCacheFromPrefsOnUIConcrete() { |
| 49 HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI(); | 53 HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread(); |
| 50 } | 54 } |
| 51 | 55 |
| 52 // Post tasks without a delay during tests. | 56 // Post tasks without a delay during tests. |
| 53 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay) OVERRIDE { | 57 virtual void StartCacheUpdateTimerOnPrefThread( |
| 54 HttpServerPropertiesManager::StartCacheUpdateTimerOnUI( | 58 base::TimeDelta delay) OVERRIDE { |
| 59 HttpServerPropertiesManager::StartCacheUpdateTimerOnPrefThread( | |
| 55 base::TimeDelta()); | 60 base::TimeDelta()); |
| 56 } | 61 } |
| 57 | 62 |
| 58 void UpdatePrefsFromCacheOnIOConcrete(const base::Closure& callback) { | 63 void UpdatePrefsFromCacheOnNetworkThreadConcrete( |
| 59 HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO(callback); | 64 const base::Closure& callback) { |
| 65 HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread(callback); | |
| 60 } | 66 } |
| 61 | 67 |
| 62 MOCK_METHOD0(UpdateCacheFromPrefsOnUI, void()); | 68 MOCK_METHOD0(UpdateCacheFromPrefsOnPrefThread, void()); |
| 63 MOCK_METHOD1(UpdatePrefsFromCacheOnIO, void(const base::Closure&)); | 69 MOCK_METHOD1(UpdatePrefsFromCacheOnNetworkThread, void(const base::Closure&)); |
| 64 MOCK_METHOD5(UpdateCacheFromPrefsOnIO, | 70 MOCK_METHOD5(UpdateCacheFromPrefsOnNetworkThread, |
| 65 void(std::vector<std::string>* spdy_servers, | 71 void(std::vector<std::string>* spdy_servers, |
| 66 net::SpdySettingsMap* spdy_settings_map, | 72 net::SpdySettingsMap* spdy_settings_map, |
| 67 net::AlternateProtocolMap* alternate_protocol_map, | 73 net::AlternateProtocolMap* alternate_protocol_map, |
| 68 net::AlternateProtocolExperiment experiment, | 74 net::AlternateProtocolExperiment experiment, |
| 69 bool detected_corrupted_prefs)); | 75 bool detected_corrupted_prefs)); |
| 70 MOCK_METHOD3(UpdatePrefsOnUI, | 76 MOCK_METHOD3(UpdatePrefsOnPref, |
| 71 void(base::ListValue* spdy_server_list, | 77 void(base::ListValue* spdy_server_list, |
| 72 net::SpdySettingsMap* spdy_settings_map, | 78 net::SpdySettingsMap* spdy_settings_map, |
| 73 net::AlternateProtocolMap* alternate_protocol_map)); | 79 net::AlternateProtocolMap* alternate_protocol_map)); |
| 74 | 80 |
| 75 private: | 81 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(TestingHttpServerPropertiesManager); | 82 DISALLOW_COPY_AND_ASSIGN(TestingHttpServerPropertiesManager); |
| 77 }; | 83 }; |
| 78 | 84 |
| 79 class HttpServerPropertiesManagerTest : public testing::Test { | 85 class HttpServerPropertiesManagerTest : public testing::Test { |
| 80 protected: | 86 protected: |
| 81 HttpServerPropertiesManagerTest() | 87 HttpServerPropertiesManagerTest() {} |
| 82 : ui_thread_(BrowserThread::UI, &loop_), | |
| 83 io_thread_(BrowserThread::IO, &loop_) { | |
| 84 } | |
| 85 | 88 |
| 86 virtual void SetUp() OVERRIDE { | 89 virtual void SetUp() OVERRIDE { |
| 87 pref_service_.registry()->RegisterDictionaryPref( | 90 pref_service_.registry()->RegisterDictionaryPref(kTestHttpServerProperties); |
| 88 prefs::kHttpServerProperties); | |
| 89 http_server_props_manager_.reset( | 91 http_server_props_manager_.reset( |
| 90 new StrictMock<TestingHttpServerPropertiesManager>(&pref_service_)); | 92 new StrictMock<TestingHttpServerPropertiesManager>( |
| 93 &pref_service_, | |
| 94 kTestHttpServerProperties, | |
| 95 base::MessageLoop::current()->message_loop_proxy())); | |
| 91 ExpectCacheUpdate(); | 96 ExpectCacheUpdate(); |
| 92 loop_.RunUntilIdle(); | 97 base::MessageLoop::current()->RunUntilIdle(); |
| 93 } | 98 } |
| 94 | 99 |
| 95 virtual void TearDown() OVERRIDE { | 100 virtual void TearDown() OVERRIDE { |
| 96 if (http_server_props_manager_.get()) | 101 if (http_server_props_manager_.get()) |
| 97 http_server_props_manager_->ShutdownOnUIThread(); | 102 http_server_props_manager_->ShutdownOnPrefThread(); |
| 98 loop_.RunUntilIdle(); | 103 base::MessageLoop::current()->RunUntilIdle(); |
| 99 // Delete |http_server_props_manager_| while |io_thread_| is mapping IO to | |
| 100 // |loop_|. | |
| 101 http_server_props_manager_.reset(); | 104 http_server_props_manager_.reset(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 void ExpectCacheUpdate() { | 107 void ExpectCacheUpdate() { |
| 105 EXPECT_CALL(*http_server_props_manager_, UpdateCacheFromPrefsOnUI()) | 108 EXPECT_CALL(*http_server_props_manager_, UpdateCacheFromPrefsOnPrefThread()) |
| 106 .WillOnce( | 109 .WillOnce(Invoke(http_server_props_manager_.get(), |
| 107 Invoke(http_server_props_manager_.get(), | 110 &TestingHttpServerPropertiesManager:: |
| 108 &TestingHttpServerPropertiesManager:: | 111 UpdateCacheFromPrefsOnUIConcrete)); |
| 109 UpdateCacheFromPrefsOnUIConcrete)); | |
| 110 } | 112 } |
| 111 | 113 |
| 112 void ExpectPrefsUpdate() { | 114 void ExpectPrefsUpdate() { |
| 113 EXPECT_CALL(*http_server_props_manager_, UpdatePrefsFromCacheOnIO(_)) | 115 EXPECT_CALL(*http_server_props_manager_, |
| 114 .WillOnce( | 116 UpdatePrefsFromCacheOnNetworkThread(_)) |
| 115 Invoke(http_server_props_manager_.get(), | 117 .WillOnce(Invoke(http_server_props_manager_.get(), |
| 116 &TestingHttpServerPropertiesManager:: | 118 &TestingHttpServerPropertiesManager:: |
| 117 UpdatePrefsFromCacheOnIOConcrete)); | 119 UpdatePrefsFromCacheOnNetworkThreadConcrete)); |
| 118 } | 120 } |
| 119 | 121 |
| 120 void ExpectPrefsUpdateRepeatedly() { | 122 void ExpectPrefsUpdateRepeatedly() { |
| 121 EXPECT_CALL(*http_server_props_manager_, UpdatePrefsFromCacheOnIO(_)) | 123 EXPECT_CALL(*http_server_props_manager_, |
| 124 UpdatePrefsFromCacheOnNetworkThread(_)) | |
| 122 .WillRepeatedly( | 125 .WillRepeatedly( |
| 123 Invoke(http_server_props_manager_.get(), | 126 Invoke(http_server_props_manager_.get(), |
| 124 &TestingHttpServerPropertiesManager:: | 127 &TestingHttpServerPropertiesManager:: |
| 125 UpdatePrefsFromCacheOnIOConcrete)); | 128 UpdatePrefsFromCacheOnNetworkThreadConcrete)); |
| 126 } | 129 } |
| 127 | 130 |
| 128 base::MessageLoop loop_; | 131 base::RunLoop loop_; |
| 129 TestingPrefServiceSimple pref_service_; | 132 TestingPrefServiceSimple pref_service_; |
| 130 scoped_ptr<TestingHttpServerPropertiesManager> http_server_props_manager_; | 133 scoped_ptr<TestingHttpServerPropertiesManager> http_server_props_manager_; |
| 131 | 134 |
| 132 private: | 135 private: |
| 133 content::TestBrowserThread ui_thread_; | |
| 134 content::TestBrowserThread io_thread_; | |
| 135 | |
| 136 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest); | 136 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest); |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 TEST_F(HttpServerPropertiesManagerTest, | 139 TEST_F(HttpServerPropertiesManagerTest, |
| 140 SingleUpdateForTwoSpdyServerPrefChanges) { | 140 SingleUpdateForTwoSpdyServerPrefChanges) { |
| 141 ExpectCacheUpdate(); | 141 ExpectCacheUpdate(); |
| 142 | 142 |
| 143 // Set up the prefs for www.google.com:80 and mail.google.com:80 and then set | 143 // Set up the prefs for www.google.com:80 and mail.google.com:80 and then set |
| 144 // it twice. Only expect a single cache update. | 144 // it twice. Only expect a single cache update. |
| 145 | 145 |
| 146 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 146 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| 147 | 147 |
| 148 // Set supports_spdy for www.google.com:80. | 148 // Set supports_spdy for www.google.com:80. |
| 149 server_pref_dict->SetBoolean("supports_spdy", true); | 149 server_pref_dict->SetBoolean("supports_spdy", true); |
| 150 | 150 |
| 151 // Set up alternate_protocol for www.google.com:80. | 151 // Set up alternate_protocol for www.google.com:80. |
| 152 base::DictionaryValue* alternate_protocol = new base::DictionaryValue; | 152 base::DictionaryValue* alternate_protocol = new base::DictionaryValue; |
| 153 alternate_protocol->SetInteger("port", 443); | 153 alternate_protocol->SetInteger("port", 443); |
| 154 alternate_protocol->SetString("protocol_str", "npn-spdy/3"); | 154 alternate_protocol->SetString("protocol_str", "npn-spdy/3"); |
| 155 server_pref_dict->SetWithoutPathExpansion( | 155 server_pref_dict->SetWithoutPathExpansion("alternate_protocol", |
| 156 "alternate_protocol", alternate_protocol); | 156 alternate_protocol); |
| 157 | 157 |
| 158 // Set the server preference for www.google.com:80. | 158 // Set the server preference for www.google.com:80. |
| 159 base::DictionaryValue* servers_dict = new base::DictionaryValue; | 159 base::DictionaryValue* servers_dict = new base::DictionaryValue; |
| 160 servers_dict->SetWithoutPathExpansion( | 160 servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict); |
| 161 "www.google.com:80", server_pref_dict); | |
| 162 | 161 |
| 163 // Set the preference for mail.google.com server. | 162 // Set the preference for mail.google.com server. |
| 164 base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue; | 163 base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue; |
| 165 | 164 |
| 166 // Set supports_spdy for mail.google.com:80 | 165 // Set supports_spdy for mail.google.com:80 |
| 167 server_pref_dict1->SetBoolean("supports_spdy", true); | 166 server_pref_dict1->SetBoolean("supports_spdy", true); |
| 168 | 167 |
| 169 // Set up alternate_protocol for mail.google.com:80 | 168 // Set up alternate_protocol for mail.google.com:80 |
| 170 base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue; | 169 base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue; |
| 171 alternate_protocol1->SetInteger("port", 444); | 170 alternate_protocol1->SetInteger("port", 444); |
| 172 alternate_protocol1->SetString("protocol_str", "npn-spdy/3.1"); | 171 alternate_protocol1->SetString("protocol_str", "npn-spdy/3.1"); |
| 173 | 172 |
| 174 server_pref_dict1->SetWithoutPathExpansion( | 173 server_pref_dict1->SetWithoutPathExpansion("alternate_protocol", |
| 175 "alternate_protocol", alternate_protocol1); | 174 alternate_protocol1); |
| 176 | 175 |
| 177 // Set the server preference for mail.google.com:80. | 176 // Set the server preference for mail.google.com:80. |
| 178 servers_dict->SetWithoutPathExpansion( | 177 servers_dict->SetWithoutPathExpansion("mail.google.com:80", |
| 179 "mail.google.com:80", server_pref_dict1); | 178 server_pref_dict1); |
| 180 | 179 |
| 181 base::DictionaryValue* http_server_properties_dict = | 180 base::DictionaryValue* http_server_properties_dict = |
| 182 new base::DictionaryValue; | 181 new base::DictionaryValue; |
| 183 HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1); | 182 HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1); |
| 184 http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict); | 183 http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict); |
| 185 | 184 |
| 186 // Set the same value for kHttpServerProperties multiple times. | 185 // Set the same value for kHttpServerProperties multiple times. |
| 187 pref_service_.SetManagedPref(prefs::kHttpServerProperties, | 186 pref_service_.SetManagedPref(kTestHttpServerProperties, |
| 188 http_server_properties_dict); | 187 http_server_properties_dict); |
| 189 base::DictionaryValue* http_server_properties_dict2 = | 188 base::DictionaryValue* http_server_properties_dict2 = |
| 190 http_server_properties_dict->DeepCopy(); | 189 http_server_properties_dict->DeepCopy(); |
| 191 pref_service_.SetManagedPref(prefs::kHttpServerProperties, | 190 pref_service_.SetManagedPref(kTestHttpServerProperties, |
| 192 http_server_properties_dict2); | 191 http_server_properties_dict2); |
| 193 | 192 |
| 194 loop_.RunUntilIdle(); | 193 base::MessageLoop::current()->RunUntilIdle(); |
| 195 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 194 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 196 | 195 |
| 197 // Verify SupportsSpdy. | 196 // Verify SupportsSpdy. |
| 198 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( | 197 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( |
| 199 net::HostPortPair::FromString("www.google.com:80"))); | 198 net::HostPortPair::FromString("www.google.com:80"))); |
| 200 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( | 199 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( |
| 201 net::HostPortPair::FromString("mail.google.com:80"))); | 200 net::HostPortPair::FromString("mail.google.com:80"))); |
| 202 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( | 201 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( |
| 203 net::HostPortPair::FromString("foo.google.com:1337"))); | 202 net::HostPortPair::FromString("foo.google.com:1337"))); |
| 204 | 203 |
| 205 // Verify AlternateProtocol. | 204 // Verify AlternateProtocol. |
| 206 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 205 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
| 207 net::HostPortPair::FromString("www.google.com:80"))); | 206 net::HostPortPair::FromString("www.google.com:80"))); |
| 208 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 207 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
| 209 net::HostPortPair::FromString("mail.google.com:80"))); | 208 net::HostPortPair::FromString("mail.google.com:80"))); |
| 210 net::PortAlternateProtocolPair port_alternate_protocol = | 209 net::PortAlternateProtocolPair port_alternate_protocol = |
| 211 http_server_props_manager_->GetAlternateProtocol( | 210 http_server_props_manager_->GetAlternateProtocol( |
| 212 net::HostPortPair::FromString("www.google.com:80")); | 211 net::HostPortPair::FromString("www.google.com:80")); |
| 213 EXPECT_EQ(443, port_alternate_protocol.port); | 212 EXPECT_EQ(443, port_alternate_protocol.port); |
| 214 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); | 213 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); |
| 215 port_alternate_protocol = | 214 port_alternate_protocol = http_server_props_manager_->GetAlternateProtocol( |
| 216 http_server_props_manager_->GetAlternateProtocol( | 215 net::HostPortPair::FromString("mail.google.com:80")); |
| 217 net::HostPortPair::FromString("mail.google.com:80")); | |
| 218 EXPECT_EQ(444, port_alternate_protocol.port); | 216 EXPECT_EQ(444, port_alternate_protocol.port); |
| 219 EXPECT_EQ(net::NPN_SPDY_3_1, port_alternate_protocol.protocol); | 217 EXPECT_EQ(net::NPN_SPDY_3_1, port_alternate_protocol.protocol); |
| 220 } | 218 } |
| 221 | 219 |
| 222 TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) { | 220 TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) { |
| 223 ExpectPrefsUpdate(); | 221 ExpectPrefsUpdate(); |
| 224 | 222 |
| 225 // Post an update task to the IO thread. SetSupportsSpdy calls | 223 // Post an update task to the IO thread. SetSupportsSpdy calls |
| 226 // ScheduleUpdatePrefsOnIO. | 224 // ScheduleUpdatePrefsOnNetworkThread. |
| 227 | 225 |
| 228 // Add mail.google.com:443 as a supporting spdy server. | 226 // Add mail.google.com:443 as a supporting spdy server. |
| 229 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 227 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
| 230 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); | 228 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); |
| 231 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); | 229 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); |
| 232 | 230 |
| 233 // Run the task. | 231 // Run the task. |
| 234 loop_.RunUntilIdle(); | 232 base::MessageLoop::current()->RunUntilIdle(); |
| 235 | 233 |
| 236 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); | 234 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); |
| 237 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 235 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 238 } | 236 } |
| 239 | 237 |
| 240 TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) { | 238 TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) { |
| 241 ExpectPrefsUpdate(); | 239 ExpectPrefsUpdate(); |
| 242 | 240 |
| 243 // Add SpdySetting for mail.google.com:443. | 241 // Add SpdySetting for mail.google.com:443. |
| 244 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 242 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
| 245 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 243 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
| 246 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 244 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
| 247 const uint32 value1 = 31337; | 245 const uint32 value1 = 31337; |
| 248 http_server_props_manager_->SetSpdySetting( | 246 http_server_props_manager_->SetSpdySetting( |
| 249 spdy_server_mail, id1, flags1, value1); | 247 spdy_server_mail, id1, flags1, value1); |
| 250 | 248 |
| 251 // Run the task. | 249 // Run the task. |
| 252 loop_.RunUntilIdle(); | 250 base::MessageLoop::current()->RunUntilIdle(); |
| 253 | 251 |
| 254 const net::SettingsMap& settings_map1_ret = | 252 const net::SettingsMap& settings_map1_ret = |
| 255 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 253 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
| 256 ASSERT_EQ(1U, settings_map1_ret.size()); | 254 ASSERT_EQ(1U, settings_map1_ret.size()); |
| 257 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); | 255 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); |
| 258 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); | 256 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); |
| 259 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; | 257 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; |
| 260 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); | 258 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); |
| 261 EXPECT_EQ(value1, flags_and_value1_ret.second); | 259 EXPECT_EQ(value1, flags_and_value1_ret.second); |
| 262 | 260 |
| 263 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 261 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 264 } | 262 } |
| 265 | 263 |
| 266 TEST_F(HttpServerPropertiesManagerTest, ClearSpdySetting) { | 264 TEST_F(HttpServerPropertiesManagerTest, ClearSpdySetting) { |
| 267 ExpectPrefsUpdateRepeatedly(); | 265 ExpectPrefsUpdateRepeatedly(); |
| 268 | 266 |
| 269 // Add SpdySetting for mail.google.com:443. | 267 // Add SpdySetting for mail.google.com:443. |
| 270 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 268 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
| 271 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 269 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
| 272 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 270 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
| 273 const uint32 value1 = 31337; | 271 const uint32 value1 = 31337; |
| 274 http_server_props_manager_->SetSpdySetting( | 272 http_server_props_manager_->SetSpdySetting( |
| 275 spdy_server_mail, id1, flags1, value1); | 273 spdy_server_mail, id1, flags1, value1); |
| 276 | 274 |
| 277 // Run the task. | 275 // Run the task. |
| 278 loop_.RunUntilIdle(); | 276 base::MessageLoop::current()->RunUntilIdle(); |
| 279 | 277 |
| 280 const net::SettingsMap& settings_map1_ret = | 278 const net::SettingsMap& settings_map1_ret = |
| 281 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 279 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
| 282 ASSERT_EQ(1U, settings_map1_ret.size()); | 280 ASSERT_EQ(1U, settings_map1_ret.size()); |
| 283 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); | 281 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); |
| 284 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); | 282 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); |
| 285 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; | 283 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; |
| 286 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); | 284 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); |
| 287 EXPECT_EQ(value1, flags_and_value1_ret.second); | 285 EXPECT_EQ(value1, flags_and_value1_ret.second); |
| 288 | 286 |
| 289 // Clear SpdySetting for mail.google.com:443. | 287 // Clear SpdySetting for mail.google.com:443. |
| 290 http_server_props_manager_->ClearSpdySettings(spdy_server_mail); | 288 http_server_props_manager_->ClearSpdySettings(spdy_server_mail); |
| 291 | 289 |
| 292 // Run the task. | 290 // Run the task. |
| 293 loop_.RunUntilIdle(); | 291 base::MessageLoop::current()->RunUntilIdle(); |
| 294 | 292 |
| 295 // Verify that there are no entries in the settings map for | 293 // Verify that there are no entries in the settings map for |
| 296 // mail.google.com:443. | 294 // mail.google.com:443. |
| 297 const net::SettingsMap& settings_map2_ret = | 295 const net::SettingsMap& settings_map2_ret = |
| 298 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 296 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
| 299 ASSERT_EQ(0U, settings_map2_ret.size()); | 297 ASSERT_EQ(0U, settings_map2_ret.size()); |
| 300 | 298 |
| 301 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 299 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 302 } | 300 } |
| 303 | 301 |
| 304 TEST_F(HttpServerPropertiesManagerTest, ClearAllSpdySetting) { | 302 TEST_F(HttpServerPropertiesManagerTest, ClearAllSpdySetting) { |
| 305 ExpectPrefsUpdateRepeatedly(); | 303 ExpectPrefsUpdateRepeatedly(); |
| 306 | 304 |
| 307 // Add SpdySetting for mail.google.com:443. | 305 // Add SpdySetting for mail.google.com:443. |
| 308 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 306 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
| 309 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 307 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
| 310 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 308 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
| 311 const uint32 value1 = 31337; | 309 const uint32 value1 = 31337; |
| 312 http_server_props_manager_->SetSpdySetting( | 310 http_server_props_manager_->SetSpdySetting( |
| 313 spdy_server_mail, id1, flags1, value1); | 311 spdy_server_mail, id1, flags1, value1); |
| 314 | 312 |
| 315 // Run the task. | 313 // Run the task. |
| 316 loop_.RunUntilIdle(); | 314 base::MessageLoop::current()->RunUntilIdle(); |
| 317 | 315 |
| 318 const net::SettingsMap& settings_map1_ret = | 316 const net::SettingsMap& settings_map1_ret = |
| 319 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 317 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
| 320 ASSERT_EQ(1U, settings_map1_ret.size()); | 318 ASSERT_EQ(1U, settings_map1_ret.size()); |
| 321 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); | 319 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); |
| 322 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); | 320 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); |
| 323 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; | 321 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; |
| 324 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); | 322 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); |
| 325 EXPECT_EQ(value1, flags_and_value1_ret.second); | 323 EXPECT_EQ(value1, flags_and_value1_ret.second); |
| 326 | 324 |
| 327 // Clear All SpdySettings. | 325 // Clear All SpdySettings. |
| 328 http_server_props_manager_->ClearAllSpdySettings(); | 326 http_server_props_manager_->ClearAllSpdySettings(); |
| 329 | 327 |
| 330 // Run the task. | 328 // Run the task. |
| 331 loop_.RunUntilIdle(); | 329 base::MessageLoop::current()->RunUntilIdle(); |
| 332 | 330 |
| 333 // Verify that there are no entries in the settings map. | 331 // Verify that there are no entries in the settings map. |
| 334 const net::SpdySettingsMap& spdy_settings_map2_ret = | 332 const net::SpdySettingsMap& spdy_settings_map2_ret = |
| 335 http_server_props_manager_->spdy_settings_map(); | 333 http_server_props_manager_->spdy_settings_map(); |
| 336 ASSERT_EQ(0U, spdy_settings_map2_ret.size()); | 334 ASSERT_EQ(0U, spdy_settings_map2_ret.size()); |
| 337 | 335 |
| 338 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 336 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 339 } | 337 } |
| 340 | 338 |
| 341 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { | 339 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { |
| 342 ExpectPrefsUpdate(); | 340 ExpectPrefsUpdate(); |
| 343 | 341 |
| 344 net::HostPortPair spdy_server_mail("mail.google.com", 80); | 342 net::HostPortPair spdy_server_mail("mail.google.com", 80); |
| 345 EXPECT_FALSE( | 343 EXPECT_FALSE( |
| 346 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 344 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
| 347 http_server_props_manager_->SetAlternateProtocol( | 345 http_server_props_manager_->SetAlternateProtocol( |
| 348 spdy_server_mail, 443, net::NPN_SPDY_3); | 346 spdy_server_mail, 443, net::NPN_SPDY_3); |
| 349 | 347 |
| 350 // Run the task. | 348 // Run the task. |
| 351 loop_.RunUntilIdle(); | 349 base::MessageLoop::current()->RunUntilIdle(); |
| 352 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 350 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 353 | 351 |
| 354 ASSERT_TRUE( | 352 ASSERT_TRUE( |
| 355 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 353 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
| 356 net::PortAlternateProtocolPair port_alternate_protocol = | 354 net::PortAlternateProtocolPair port_alternate_protocol = |
| 357 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); | 355 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); |
| 358 EXPECT_EQ(443, port_alternate_protocol.port); | 356 EXPECT_EQ(443, port_alternate_protocol.port); |
| 359 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); | 357 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); |
| 360 } | 358 } |
| 361 | 359 |
| 362 TEST_F(HttpServerPropertiesManagerTest, Clear) { | 360 TEST_F(HttpServerPropertiesManagerTest, Clear) { |
| 363 ExpectPrefsUpdate(); | 361 ExpectPrefsUpdate(); |
| 364 | 362 |
| 365 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 363 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
| 366 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); | 364 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); |
| 367 http_server_props_manager_->SetAlternateProtocol( | 365 http_server_props_manager_->SetAlternateProtocol( |
| 368 spdy_server_mail, 443, net::NPN_SPDY_3); | 366 spdy_server_mail, 443, net::NPN_SPDY_3); |
| 369 | 367 |
| 370 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 368 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
| 371 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 369 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
| 372 const uint32 value1 = 31337; | 370 const uint32 value1 = 31337; |
| 373 http_server_props_manager_->SetSpdySetting( | 371 http_server_props_manager_->SetSpdySetting( |
| 374 spdy_server_mail, id1, flags1, value1); | 372 spdy_server_mail, id1, flags1, value1); |
| 375 | 373 |
| 376 // Run the task. | 374 // Run the task. |
| 377 loop_.RunUntilIdle(); | 375 base::MessageLoop::current()->RunUntilIdle(); |
| 378 | 376 |
| 379 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); | 377 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); |
| 380 EXPECT_TRUE( | 378 EXPECT_TRUE( |
| 381 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 379 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
| 382 | 380 |
| 383 // Check SPDY settings values. | 381 // Check SPDY settings values. |
| 384 const net::SettingsMap& settings_map1_ret = | 382 const net::SettingsMap& settings_map1_ret = |
| 385 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 383 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
| 386 ASSERT_EQ(1U, settings_map1_ret.size()); | 384 ASSERT_EQ(1U, settings_map1_ret.size()); |
| 387 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); | 385 net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); |
| 388 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); | 386 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); |
| 389 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; | 387 net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; |
| 390 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); | 388 EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); |
| 391 EXPECT_EQ(value1, flags_and_value1_ret.second); | 389 EXPECT_EQ(value1, flags_and_value1_ret.second); |
| 392 | 390 |
| 393 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 391 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 394 | 392 |
| 395 ExpectPrefsUpdate(); | 393 ExpectPrefsUpdate(); |
| 396 | 394 |
| 397 // Clear http server data, time out if we do not get a completion callback. | 395 // Clear http server data, time out if we do not get a completion callback. |
| 398 http_server_props_manager_->Clear(base::MessageLoop::QuitClosure()); | 396 http_server_props_manager_->Clear(base::MessageLoop::QuitClosure()); |
| 399 loop_.Run(); | 397 base::MessageLoop::current()->Run(); |
| 400 | 398 |
| 401 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); | 399 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); |
| 402 EXPECT_FALSE( | 400 EXPECT_FALSE( |
| 403 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 401 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
| 404 | 402 |
| 405 const net::SettingsMap& settings_map2_ret = | 403 const net::SettingsMap& settings_map2_ret = |
| 406 http_server_props_manager_->GetSpdySettings(spdy_server_mail); | 404 http_server_props_manager_->GetSpdySettings(spdy_server_mail); |
| 407 EXPECT_EQ(0U, settings_map2_ret.size()); | 405 EXPECT_EQ(0U, settings_map2_ret.size()); |
| 408 | 406 |
| 409 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 407 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 410 } | 408 } |
| 411 | 409 |
| 412 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) { | 410 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) { |
| 413 // Post an update task to the UI thread. | 411 // Post an update task to the UI thread. |
| 414 http_server_props_manager_->ScheduleUpdateCacheOnUI(); | 412 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); |
| 415 // Shutdown comes before the task is executed. | 413 // Shutdown comes before the task is executed. |
| 416 http_server_props_manager_->ShutdownOnUIThread(); | 414 http_server_props_manager_->ShutdownOnPrefThread(); |
| 417 http_server_props_manager_.reset(); | 415 http_server_props_manager_.reset(); |
| 418 // Run the task after shutdown and deletion. | 416 // Run the task after shutdown and deletion. |
| 419 loop_.RunUntilIdle(); | 417 base::MessageLoop::current()->RunUntilIdle(); |
| 420 } | 418 } |
| 421 | 419 |
| 422 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) { | 420 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) { |
| 423 // Post an update task. | 421 // Post an update task. |
| 424 http_server_props_manager_->ScheduleUpdateCacheOnUI(); | 422 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); |
| 425 // Shutdown comes before the task is executed. | 423 // Shutdown comes before the task is executed. |
| 426 http_server_props_manager_->ShutdownOnUIThread(); | 424 http_server_props_manager_->ShutdownOnPrefThread(); |
| 427 // Run the task after shutdown, but before deletion. | 425 // Run the task after shutdown, but before deletion. |
| 428 loop_.RunUntilIdle(); | 426 base::MessageLoop::current()->RunUntilIdle(); |
| 429 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 427 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 430 http_server_props_manager_.reset(); | 428 http_server_props_manager_.reset(); |
| 431 loop_.RunUntilIdle(); | 429 base::MessageLoop::current()->RunUntilIdle(); |
| 432 } | 430 } |
| 433 | 431 |
| 434 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) { | 432 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) { |
| 435 http_server_props_manager_->UpdateCacheFromPrefsOnUIConcrete(); | 433 http_server_props_manager_->UpdateCacheFromPrefsOnUIConcrete(); |
| 436 // Shutdown comes before the task is executed. | 434 // Shutdown comes before the task is executed. |
| 437 http_server_props_manager_->ShutdownOnUIThread(); | 435 http_server_props_manager_->ShutdownOnPrefThread(); |
| 438 // Run the task after shutdown, but before deletion. | 436 // Run the task after shutdown, but before deletion. |
| 439 loop_.RunUntilIdle(); | 437 base::MessageLoop::current()->RunUntilIdle(); |
| 440 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 438 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 441 http_server_props_manager_.reset(); | 439 http_server_props_manager_.reset(); |
| 442 loop_.RunUntilIdle(); | 440 base::MessageLoop::current()->RunUntilIdle(); |
| 443 } | 441 } |
| 444 | 442 |
| 445 // | 443 // |
| 446 // Tests for shutdown when updating prefs. | 444 // Tests for shutdown when updating prefs. |
| 447 // | 445 // |
| 448 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) { | 446 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) { |
| 449 // Post an update task to the IO thread. | 447 // Post an update task to the IO thread. |
| 450 http_server_props_manager_->ScheduleUpdatePrefsOnIO(); | 448 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); |
| 451 // Shutdown comes before the task is executed. | 449 // Shutdown comes before the task is executed. |
| 452 http_server_props_manager_->ShutdownOnUIThread(); | 450 http_server_props_manager_->ShutdownOnPrefThread(); |
| 453 http_server_props_manager_.reset(); | 451 http_server_props_manager_.reset(); |
| 454 // Run the task after shutdown and deletion. | 452 // Run the task after shutdown and deletion. |
| 455 loop_.RunUntilIdle(); | 453 base::MessageLoop::current()->RunUntilIdle(); |
| 456 } | 454 } |
| 457 | 455 |
| 458 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { | 456 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { |
| 459 ExpectPrefsUpdate(); | 457 ExpectPrefsUpdate(); |
| 460 // Post an update task. | 458 // Post an update task. |
| 461 http_server_props_manager_->ScheduleUpdatePrefsOnIO(); | 459 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); |
| 462 // Shutdown comes before the task is executed. | 460 // Shutdown comes before the task is executed. |
| 463 http_server_props_manager_->ShutdownOnUIThread(); | 461 http_server_props_manager_->ShutdownOnPrefThread(); |
| 464 // Run the task after shutdown, but before deletion. | 462 // Run the task after shutdown, but before deletion. |
| 465 loop_.RunUntilIdle(); | 463 base::MessageLoop::current()->RunUntilIdle(); |
| 466 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 464 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 467 http_server_props_manager_.reset(); | 465 http_server_props_manager_.reset(); |
| 468 loop_.RunUntilIdle(); | 466 base::MessageLoop::current()->RunUntilIdle(); |
| 469 } | 467 } |
| 470 | 468 |
| 471 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { | 469 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { |
| 472 // This posts a task to the UI thread. | 470 // This posts a task to the UI thread. |
| 473 http_server_props_manager_->UpdatePrefsFromCacheOnIOConcrete(base::Closure()); | 471 http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete( |
| 472 base::Closure()); | |
| 474 // Shutdown comes before the task is executed. | 473 // Shutdown comes before the task is executed. |
| 475 http_server_props_manager_->ShutdownOnUIThread(); | 474 http_server_props_manager_->ShutdownOnPrefThread(); |
| 476 // Run the task after shutdown, but before deletion. | 475 // Run the task after shutdown, but before deletion. |
| 477 loop_.RunUntilIdle(); | 476 base::MessageLoop::current()->RunUntilIdle(); |
| 478 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 477 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 479 http_server_props_manager_.reset(); | 478 http_server_props_manager_.reset(); |
| 480 loop_.RunUntilIdle(); | 479 base::MessageLoop::current()->RunUntilIdle(); |
| 481 } | 480 } |
| 482 | 481 |
| 483 } // namespace | 482 } // namespace |
| 484 | 483 |
| 485 } // namespace chrome_browser_net | 484 } // namespace chrome_browser_net |
|
droger
2014/07/09 12:26:08
Fix the comment.
mef
2014/07/09 12:44:50
Done.
| |
| OLD | NEW |