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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 private: | 229 private: |
230 friend class base::RefCountedThreadSafe<MockCookieStore>; | 230 friend class base::RefCountedThreadSafe<MockCookieStore>; |
231 virtual ~MockCookieStore() {} | 231 virtual ~MockCookieStore() {} |
232 | 232 |
233 std::vector<Entry> entries_; | 233 std::vector<Entry> entries_; |
234 }; | 234 }; |
235 | 235 |
236 class MockSSLConfigService : public net::SSLConfigService { | 236 class MockSSLConfigService : public net::SSLConfigService { |
237 public: | 237 public: |
238 virtual void GetSSLConfig(net::SSLConfig* config) {}; | 238 virtual void GetSSLConfig(net::SSLConfig* config) {} |
239 }; | 239 }; |
240 | 240 |
241 class MockURLRequestContext : public net::URLRequestContext { | 241 class MockURLRequestContext : public net::URLRequestContext { |
242 public: | 242 public: |
243 explicit MockURLRequestContext(net::CookieStore* cookie_store) | 243 explicit MockURLRequestContext(net::CookieStore* cookie_store) |
244 : transport_security_state_(std::string()) { | 244 : transport_security_state_() { |
245 set_cookie_store(cookie_store); | 245 set_cookie_store(cookie_store); |
246 set_transport_security_state(&transport_security_state_); | 246 set_transport_security_state(&transport_security_state_); |
247 net::TransportSecurityState::DomainState state; | 247 net::TransportSecurityState::DomainState state; |
248 state.expiry = base::Time::Now() + base::TimeDelta::FromSeconds(1000); | 248 state.upgrade_expiry = base::Time::Now() + |
| 249 base::TimeDelta::FromSeconds(1000); |
249 transport_security_state_.EnableHost("upgrademe.com", state); | 250 transport_security_state_.EnableHost("upgrademe.com", state); |
250 } | 251 } |
251 | 252 |
252 private: | 253 private: |
253 friend class base::RefCountedThreadSafe<MockURLRequestContext>; | 254 friend class base::RefCountedThreadSafe<MockURLRequestContext>; |
254 virtual ~MockURLRequestContext() {} | 255 virtual ~MockURLRequestContext() {} |
255 | 256 |
256 net::TransportSecurityState transport_security_state_; | 257 net::TransportSecurityState transport_security_state_; |
257 }; | 258 }; |
258 | 259 |
259 class MockHttpTransactionFactory : public net::HttpTransactionFactory { | 260 class MockHttpTransactionFactory : public net::HttpTransactionFactory { |
260 public: | 261 public: |
261 MockHttpTransactionFactory(net::OrderedSocketData* data) { | 262 explicit MockHttpTransactionFactory(net::OrderedSocketData* data) { |
262 data_ = data; | 263 data_ = data; |
263 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK); | 264 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK); |
264 data_->set_connect_data(connect_data); | 265 data_->set_connect_data(connect_data); |
265 session_deps_.reset(new SpdySessionDependencies); | 266 session_deps_.reset(new SpdySessionDependencies); |
266 session_deps_->socket_factory->AddSocketDataProvider(data_); | 267 session_deps_->socket_factory->AddSocketDataProvider(data_); |
267 http_session_ = | 268 http_session_ = |
268 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); | 269 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); |
269 host_port_pair_.set_host("example.com"); | 270 host_port_pair_.set_host("example.com"); |
270 host_port_pair_.set_port(80); | 271 host_port_pair_.set_port(80); |
271 host_port_proxy_pair_.first = host_port_pair_; | 272 host_port_proxy_pair_.first = host_port_pair_; |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 | 1095 |
1095 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { | 1096 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { |
1096 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1097 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1097 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1098 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
1098 } | 1099 } |
1099 | 1100 |
1100 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1101 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
1101 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1102 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
1102 | 1103 |
1103 } // namespace net | 1104 } // namespace net |
OLD | NEW |