Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: net/websockets/websocket_job_spdy2_unittest.cc

Issue 9415040: Refactor TransportSecurityState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | net/websockets/websocket_job_spdy3_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 entry.cookie_line = cookie_line; 167 entry.cookie_line = cookie_line;
168 entry.options = options; 168 entry.options = options;
169 entries_.push_back(entry); 169 entries_.push_back(entry);
170 return true; 170 return true;
171 } 171 }
172 172
173 std::string GetCookiesWithOptions(const GURL& url, 173 std::string GetCookiesWithOptions(const GURL& url,
174 const net::CookieOptions& options) { 174 const net::CookieOptions& options) {
175 std::string result; 175 std::string result;
176 for (size_t i = 0; i < entries_.size(); i++) { 176 for (size_t i = 0; i < entries_.size(); i++) {
177 Entry &entry = entries_[i]; 177 Entry& entry = entries_[i];
178 if (url == entry.url) { 178 if (url == entry.url) {
179 if (!result.empty()) { 179 if (!result.empty()) {
180 result += "; "; 180 result += "; ";
181 } 181 }
182 result += entry.cookie_line; 182 result += entry.cookie_line;
183 } 183 }
184 } 184 }
185 return result; 185 return result;
186 } 186 }
187 187
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 public: 243 public:
244 virtual void GetSSLConfig(net::SSLConfig* config) OVERRIDE {} 244 virtual void GetSSLConfig(net::SSLConfig* config) OVERRIDE {}
245 245
246 protected: 246 protected:
247 virtual ~MockSSLConfigService() {} 247 virtual ~MockSSLConfigService() {}
248 }; 248 };
249 249
250 class MockURLRequestContext : public net::URLRequestContext { 250 class MockURLRequestContext : public net::URLRequestContext {
251 public: 251 public:
252 explicit MockURLRequestContext(net::CookieStore* cookie_store) 252 explicit MockURLRequestContext(net::CookieStore* cookie_store)
253 : transport_security_state_(std::string()) { 253 : transport_security_state_() {
254 set_cookie_store(cookie_store); 254 set_cookie_store(cookie_store);
255 set_transport_security_state(&transport_security_state_); 255 set_transport_security_state(&transport_security_state_);
256 net::TransportSecurityState::DomainState state; 256 net::TransportSecurityState::DomainState state;
257 state.expiry = base::Time::Now() + base::TimeDelta::FromSeconds(1000); 257 state.upgrade_expiry = base::Time::Now() +
258 base::TimeDelta::FromSeconds(1000);
258 transport_security_state_.EnableHost("upgrademe.com", state); 259 transport_security_state_.EnableHost("upgrademe.com", state);
259 } 260 }
260 261
261 protected: 262 protected:
262 friend class base::RefCountedThreadSafe<MockURLRequestContext>; 263 friend class base::RefCountedThreadSafe<MockURLRequestContext>;
263 virtual ~MockURLRequestContext() {} 264 virtual ~MockURLRequestContext() {}
264 265
265 private: 266 private:
266 net::TransportSecurityState transport_security_state_; 267 net::TransportSecurityState transport_security_state_;
267 }; 268 };
268 269
269 class MockHttpTransactionFactory : public net::HttpTransactionFactory { 270 class MockHttpTransactionFactory : public net::HttpTransactionFactory {
270 public: 271 public:
271 MockHttpTransactionFactory(net::OrderedSocketData* data) { 272 explicit MockHttpTransactionFactory(net::OrderedSocketData* data) {
272 data_ = data; 273 data_ = data;
273 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK); 274 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK);
274 data_->set_connect_data(connect_data); 275 data_->set_connect_data(connect_data);
275 session_deps_.reset(new SpdySessionDependencies); 276 session_deps_.reset(new SpdySessionDependencies);
276 session_deps_->socket_factory->AddSocketDataProvider(data_); 277 session_deps_->socket_factory->AddSocketDataProvider(data_);
277 http_session_ = 278 http_session_ =
278 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); 279 SpdySessionDependencies::SpdyCreateSession(session_deps_.get());
279 host_port_pair_.set_host("example.com"); 280 host_port_pair_.set_host("example.com");
280 host_port_pair_.set_port(80); 281 host_port_pair_.set_port(80);
281 host_port_proxy_pair_.first = host_port_pair_; 282 host_port_proxy_pair_.first = host_port_pair_;
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 1110
1110 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { 1111 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) {
1111 WebSocketJob::set_websocket_over_spdy_enabled(true); 1112 WebSocketJob::set_websocket_over_spdy_enabled(true);
1112 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); 1113 TestConnectBySpdy(SPDY_ON, THROTTLING_ON);
1113 } 1114 }
1114 1115
1115 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. 1116 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation.
1116 // TODO(toyoshim,yutak): Add tests to verify closing handshake. 1117 // TODO(toyoshim,yutak): Add tests to verify closing handshake.
1117 1118
1118 } // namespace net 1119 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | net/websockets/websocket_job_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698