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 "net/websockets/websocket_job.h" | 5 #include "net/websockets/websocket_job.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 const SetCookiesCallback& callback) { | 171 const SetCookiesCallback& callback) { |
172 bool result = SetCookieWithOptions(url, cookie_line, options); | 172 bool result = SetCookieWithOptions(url, cookie_line, options); |
173 if (!callback.is_null()) | 173 if (!callback.is_null()) |
174 callback.Run(result); | 174 callback.Run(result); |
175 } | 175 } |
176 virtual std::string GetCookiesWithOptions( | 176 virtual std::string GetCookiesWithOptions( |
177 const GURL& url, | 177 const GURL& url, |
178 const net::CookieOptions& options) { | 178 const net::CookieOptions& options) { |
179 std::string result; | 179 std::string result; |
180 for (size_t i = 0; i < entries_.size(); i++) { | 180 for (size_t i = 0; i < entries_.size(); i++) { |
181 Entry &entry = entries_[i]; | 181 Entry& entry = entries_[i]; |
182 if (url == entry.url) { | 182 if (url == entry.url) { |
183 if (!result.empty()) { | 183 if (!result.empty()) { |
184 result += "; "; | 184 result += "; "; |
185 } | 185 } |
186 result += entry.cookie_line; | 186 result += entry.cookie_line; |
187 } | 187 } |
188 } | 188 } |
189 return result; | 189 return result; |
190 } | 190 } |
191 virtual void GetCookiesWithOptionsAsync( | 191 virtual void GetCookiesWithOptionsAsync( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 private: | 232 private: |
233 friend class base::RefCountedThreadSafe<MockCookieStore>; | 233 friend class base::RefCountedThreadSafe<MockCookieStore>; |
234 virtual ~MockCookieStore() {} | 234 virtual ~MockCookieStore() {} |
235 | 235 |
236 std::vector<Entry> entries_; | 236 std::vector<Entry> entries_; |
237 }; | 237 }; |
238 | 238 |
239 class MockSSLConfigService : public net::SSLConfigService { | 239 class MockSSLConfigService : public net::SSLConfigService { |
240 public: | 240 public: |
241 virtual void GetSSLConfig(net::SSLConfig* config) {}; | 241 virtual void GetSSLConfig(net::SSLConfig* config) {} |
242 }; | 242 }; |
243 | 243 |
244 class MockURLRequestContext : public net::URLRequestContext { | 244 class MockURLRequestContext : public net::URLRequestContext { |
245 public: | 245 public: |
246 explicit MockURLRequestContext(net::CookieStore* cookie_store) | 246 explicit MockURLRequestContext(net::CookieStore* cookie_store) |
247 : transport_security_state_(std::string()) { | 247 : transport_security_state_() { |
248 set_cookie_store(cookie_store); | 248 set_cookie_store(cookie_store); |
249 set_transport_security_state(&transport_security_state_); | 249 set_transport_security_state(&transport_security_state_); |
250 net::TransportSecurityState::DomainState state; | 250 net::TransportSecurityState::DomainState state; |
251 state.expiry = base::Time::Now() + base::TimeDelta::FromSeconds(1000); | 251 state.upgrade_expiry = base::Time::Now() + |
| 252 base::TimeDelta::FromSeconds(1000); |
252 transport_security_state_.EnableHost("upgrademe.com", state); | 253 transport_security_state_.EnableHost("upgrademe.com", state); |
253 } | 254 } |
254 | 255 |
255 private: | 256 private: |
256 friend class base::RefCountedThreadSafe<MockURLRequestContext>; | 257 friend class base::RefCountedThreadSafe<MockURLRequestContext>; |
257 virtual ~MockURLRequestContext() {} | 258 virtual ~MockURLRequestContext() {} |
258 | 259 |
259 net::TransportSecurityState transport_security_state_; | 260 net::TransportSecurityState transport_security_state_; |
260 }; | 261 }; |
261 | 262 |
262 class MockHttpTransactionFactory : public net::HttpTransactionFactory { | 263 class MockHttpTransactionFactory : public net::HttpTransactionFactory { |
263 public: | 264 public: |
264 MockHttpTransactionFactory(net::OrderedSocketData* data) { | 265 explicit MockHttpTransactionFactory(net::OrderedSocketData* data) { |
265 data_ = data; | 266 data_ = data; |
266 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK); | 267 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK); |
267 data_->set_connect_data(connect_data); | 268 data_->set_connect_data(connect_data); |
268 session_deps_.reset(new SpdySessionDependencies); | 269 session_deps_.reset(new SpdySessionDependencies); |
269 session_deps_->socket_factory->AddSocketDataProvider(data_); | 270 session_deps_->socket_factory->AddSocketDataProvider(data_); |
270 http_session_ = | 271 http_session_ = |
271 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); | 272 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); |
272 host_port_pair_.set_host("example.com"); | 273 host_port_pair_.set_host("example.com"); |
273 host_port_pair_.set_port(80); | 274 host_port_pair_.set_port(80); |
274 host_port_proxy_pair_.first = host_port_pair_; | 275 host_port_proxy_pair_.first = host_port_pair_; |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 | 1098 |
1098 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { | 1099 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { |
1099 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1100 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1100 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1101 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
1101 } | 1102 } |
1102 | 1103 |
1103 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1104 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
1104 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1105 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
1105 | 1106 |
1106 } // namespace net | 1107 } // namespace net |
OLD | NEW |