| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/net/http_server_properties_manager.h" | 5 #include "chrome/browser/net/http_server_properties_manager.h" |
| 6 | 6 |
| 7 #include "base/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" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // it twice. Only expect a single cache update. | 145 // it twice. Only expect a single cache update. |
| 146 | 146 |
| 147 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 147 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
| 148 | 148 |
| 149 // Set supports_spdy for www.google.com:80. | 149 // Set supports_spdy for www.google.com:80. |
| 150 server_pref_dict->SetBoolean("supports_spdy", true); | 150 server_pref_dict->SetBoolean("supports_spdy", true); |
| 151 | 151 |
| 152 // Set up alternate_protocol for www.google.com:80. | 152 // Set up alternate_protocol for www.google.com:80. |
| 153 base::DictionaryValue* alternate_protocol = new base::DictionaryValue; | 153 base::DictionaryValue* alternate_protocol = new base::DictionaryValue; |
| 154 alternate_protocol->SetInteger("port", 443); | 154 alternate_protocol->SetInteger("port", 443); |
| 155 alternate_protocol->SetString("protocol_str", "npn-spdy/1"); | 155 alternate_protocol->SetString("protocol_str", "npn-spdy/2"); |
| 156 server_pref_dict->SetWithoutPathExpansion( | 156 server_pref_dict->SetWithoutPathExpansion( |
| 157 "alternate_protocol", alternate_protocol); | 157 "alternate_protocol", alternate_protocol); |
| 158 | 158 |
| 159 // Set pipeline capability for www.google.com:80. | 159 // Set pipeline capability for www.google.com:80. |
| 160 server_pref_dict->SetInteger("pipeline_capability", net::PIPELINE_CAPABLE); | 160 server_pref_dict->SetInteger("pipeline_capability", net::PIPELINE_CAPABLE); |
| 161 | 161 |
| 162 // Set the server preference for www.google.com:80. | 162 // Set the server preference for www.google.com:80. |
| 163 base::DictionaryValue* servers_dict = new base::DictionaryValue; | 163 base::DictionaryValue* servers_dict = new base::DictionaryValue; |
| 164 servers_dict->SetWithoutPathExpansion( | 164 servers_dict->SetWithoutPathExpansion( |
| 165 "www.google.com:80", server_pref_dict); | 165 "www.google.com:80", server_pref_dict); |
| 166 | 166 |
| 167 // Set the preference for mail.google.com server. | 167 // Set the preference for mail.google.com server. |
| 168 base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue; | 168 base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue; |
| 169 | 169 |
| 170 // Set supports_spdy for mail.google.com:80 | 170 // Set supports_spdy for mail.google.com:80 |
| 171 server_pref_dict1->SetBoolean("supports_spdy", true); | 171 server_pref_dict1->SetBoolean("supports_spdy", true); |
| 172 | 172 |
| 173 // Set up alternate_protocol for mail.google.com:80 | 173 // Set up alternate_protocol for mail.google.com:80 |
| 174 base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue; | 174 base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue; |
| 175 alternate_protocol1->SetInteger("port", 444); | 175 alternate_protocol1->SetInteger("port", 444); |
| 176 alternate_protocol1->SetString("protocol_str", "npn-spdy/2"); | 176 alternate_protocol1->SetString("protocol_str", "npn-spdy/3"); |
| 177 | 177 |
| 178 server_pref_dict1->SetWithoutPathExpansion( | 178 server_pref_dict1->SetWithoutPathExpansion( |
| 179 "alternate_protocol", alternate_protocol1); | 179 "alternate_protocol", alternate_protocol1); |
| 180 | 180 |
| 181 // Set pipelining capability for mail.google.com:80 | 181 // Set pipelining capability for mail.google.com:80 |
| 182 server_pref_dict1->SetInteger("pipeline_capability", net::PIPELINE_INCAPABLE); | 182 server_pref_dict1->SetInteger("pipeline_capability", net::PIPELINE_INCAPABLE); |
| 183 | 183 |
| 184 // Set the server preference for mail.google.com:80. | 184 // Set the server preference for mail.google.com:80. |
| 185 servers_dict->SetWithoutPathExpansion( | 185 servers_dict->SetWithoutPathExpansion( |
| 186 "mail.google.com:80", server_pref_dict1); | 186 "mail.google.com:80", server_pref_dict1); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 211 | 211 |
| 212 // Verify AlternateProtocol. | 212 // Verify AlternateProtocol. |
| 213 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 213 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
| 214 net::HostPortPair::FromString("www.google.com:80"))); | 214 net::HostPortPair::FromString("www.google.com:80"))); |
| 215 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 215 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
| 216 net::HostPortPair::FromString("mail.google.com:80"))); | 216 net::HostPortPair::FromString("mail.google.com:80"))); |
| 217 net::PortAlternateProtocolPair port_alternate_protocol = | 217 net::PortAlternateProtocolPair port_alternate_protocol = |
| 218 http_server_props_manager_->GetAlternateProtocol( | 218 http_server_props_manager_->GetAlternateProtocol( |
| 219 net::HostPortPair::FromString("www.google.com:80")); | 219 net::HostPortPair::FromString("www.google.com:80")); |
| 220 EXPECT_EQ(443, port_alternate_protocol.port); | 220 EXPECT_EQ(443, port_alternate_protocol.port); |
| 221 EXPECT_EQ(net::NPN_SPDY_1, port_alternate_protocol.protocol); | 221 EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol); |
| 222 port_alternate_protocol = | 222 port_alternate_protocol = |
| 223 http_server_props_manager_->GetAlternateProtocol( | 223 http_server_props_manager_->GetAlternateProtocol( |
| 224 net::HostPortPair::FromString("mail.google.com:80")); | 224 net::HostPortPair::FromString("mail.google.com:80")); |
| 225 EXPECT_EQ(444, port_alternate_protocol.port); | 225 EXPECT_EQ(444, port_alternate_protocol.port); |
| 226 EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol); | 226 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); |
| 227 | 227 |
| 228 // Verify pipeline capability. | 228 // Verify pipeline capability. |
| 229 EXPECT_EQ(net::PIPELINE_CAPABLE, | 229 EXPECT_EQ(net::PIPELINE_CAPABLE, |
| 230 http_server_props_manager_->GetPipelineCapability( | 230 http_server_props_manager_->GetPipelineCapability( |
| 231 net::HostPortPair::FromString("www.google.com:80"))); | 231 net::HostPortPair::FromString("www.google.com:80"))); |
| 232 EXPECT_EQ(net::PIPELINE_INCAPABLE, | 232 EXPECT_EQ(net::PIPELINE_INCAPABLE, |
| 233 http_server_props_manager_->GetPipelineCapability( | 233 http_server_props_manager_->GetPipelineCapability( |
| 234 net::HostPortPair::FromString("mail.google.com:80"))); | 234 net::HostPortPair::FromString("mail.google.com:80"))); |
| 235 } | 235 } |
| 236 | 236 |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 // Run the task after shutdown, but before deletion. | 528 // Run the task after shutdown, but before deletion. |
| 529 loop_.RunUntilIdle(); | 529 loop_.RunUntilIdle(); |
| 530 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 530 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 531 http_server_props_manager_.reset(); | 531 http_server_props_manager_.reset(); |
| 532 loop_.RunUntilIdle(); | 532 loop_.RunUntilIdle(); |
| 533 } | 533 } |
| 534 | 534 |
| 535 } // namespace | 535 } // namespace |
| 536 | 536 |
| 537 } // namespace chrome_browser_net | 537 } // namespace chrome_browser_net |
| OLD | NEW |