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

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

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize to NULL 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
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 explicit MockURLRequestContext(net::CookieStore* cookie_store) 255 explicit MockURLRequestContext(net::CookieStore* cookie_store)
256 : transport_security_state_() { 256 : transport_security_state_() {
257 set_cookie_store(cookie_store); 257 set_cookie_store(cookie_store);
258 set_transport_security_state(&transport_security_state_); 258 set_transport_security_state(&transport_security_state_);
259 net::TransportSecurityState::DomainState state; 259 net::TransportSecurityState::DomainState state;
260 state.upgrade_expiry = base::Time::Now() + 260 state.upgrade_expiry = base::Time::Now() +
261 base::TimeDelta::FromSeconds(1000); 261 base::TimeDelta::FromSeconds(1000);
262 transport_security_state_.EnableHost("upgrademe.com", state); 262 transport_security_state_.EnableHost("upgrademe.com", state);
263 } 263 }
264 264
265 protected:
266 friend class base::RefCountedThreadSafe<MockURLRequestContext>;
267 virtual ~MockURLRequestContext() {} 265 virtual ~MockURLRequestContext() {}
268 266
269 private: 267 private:
270 net::TransportSecurityState transport_security_state_; 268 net::TransportSecurityState transport_security_state_;
271 }; 269 };
272 270
273 class MockHttpTransactionFactory : public net::HttpTransactionFactory { 271 class MockHttpTransactionFactory : public net::HttpTransactionFactory {
274 public: 272 public:
275 explicit MockHttpTransactionFactory(net::OrderedSocketData* data) { 273 explicit MockHttpTransactionFactory(net::OrderedSocketData* data) {
276 data_ = data; 274 data_ = data;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } // namespace 327 } // namespace
330 328
331 namespace net { 329 namespace net {
332 330
333 class WebSocketJobSpdy3Test : public PlatformTest { 331 class WebSocketJobSpdy3Test : public PlatformTest {
334 public: 332 public:
335 virtual void SetUp() { 333 virtual void SetUp() {
336 SpdySession::set_default_protocol(kProtoSPDY3); 334 SpdySession::set_default_protocol(kProtoSPDY3);
337 stream_type_ = STREAM_INVALID; 335 stream_type_ = STREAM_INVALID;
338 cookie_store_ = new MockCookieStore; 336 cookie_store_ = new MockCookieStore;
339 context_ = new MockURLRequestContext(cookie_store_.get()); 337 context_.reset(new MockURLRequestContext(cookie_store_.get()));
340 } 338 }
341 virtual void TearDown() { 339 virtual void TearDown() {
342 cookie_store_ = NULL; 340 cookie_store_ = NULL;
343 context_ = NULL; 341 context_.reset();
344 websocket_ = NULL; 342 websocket_ = NULL;
345 socket_ = NULL; 343 socket_ = NULL;
346 } 344 }
347 void DoSendRequest() { 345 void DoSendRequest() {
348 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie, 346 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie,
349 kHandshakeRequestWithoutCookieLength)); 347 kHandshakeRequestWithoutCookieLength));
350 } 348 }
351 void DoSendData() { 349 void DoSendData() {
352 if (received_data().size() == kHandshakeResponseWithoutCookieLength) 350 if (received_data().size() == kHandshakeResponseWithoutCookieLength)
353 websocket_->SendData(kDataHello, kDataHelloLength); 351 websocket_->SendData(kDataHello, kDataHelloLength);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 void TestSlowHandshake(); 445 void TestSlowHandshake();
448 void TestHandshakeWithCookie(); 446 void TestHandshakeWithCookie();
449 void TestHandshakeWithCookieButNotAllowed(); 447 void TestHandshakeWithCookieButNotAllowed();
450 void TestHSTSUpgrade(); 448 void TestHSTSUpgrade();
451 void TestInvalidSendData(); 449 void TestInvalidSendData();
452 void TestConnectByWebSocket(ThrottlingOption throttling); 450 void TestConnectByWebSocket(ThrottlingOption throttling);
453 void TestConnectBySpdy(SpdyOption spdy, ThrottlingOption throttling); 451 void TestConnectBySpdy(SpdyOption spdy, ThrottlingOption throttling);
454 452
455 StreamType stream_type_; 453 StreamType stream_type_;
456 scoped_refptr<MockCookieStore> cookie_store_; 454 scoped_refptr<MockCookieStore> cookie_store_;
457 scoped_refptr<MockURLRequestContext> context_;
458 scoped_refptr<WebSocketJob> websocket_; 455 scoped_refptr<WebSocketJob> websocket_;
459 scoped_refptr<SocketStream> socket_; 456 scoped_refptr<SocketStream> socket_;
460 scoped_ptr<MockClientSocketFactory> socket_factory_; 457 scoped_ptr<MockClientSocketFactory> socket_factory_;
461 scoped_ptr<OrderedSocketData> data_; 458 scoped_ptr<OrderedSocketData> data_;
462 TestCompletionCallback sync_test_callback_; 459 TestCompletionCallback sync_test_callback_;
463 scoped_refptr<MockSSLConfigService> ssl_config_service_; 460 scoped_refptr<MockSSLConfigService> ssl_config_service_;
464 scoped_ptr<net::ProxyService> proxy_service_; 461 scoped_ptr<net::ProxyService> proxy_service_;
465 scoped_ptr<net::MockHostResolver> host_resolver_; 462 scoped_ptr<net::MockHostResolver> host_resolver_;
466 scoped_ptr<MockHttpTransactionFactory> http_factory_; 463 scoped_ptr<MockHttpTransactionFactory> http_factory_;
464 scoped_ptr<MockURLRequestContext> context_;
467 465
468 static const char kHandshakeRequestWithoutCookie[]; 466 static const char kHandshakeRequestWithoutCookie[];
469 static const char kHandshakeRequestWithCookie[]; 467 static const char kHandshakeRequestWithCookie[];
470 static const char kHandshakeRequestWithFilteredCookie[]; 468 static const char kHandshakeRequestWithFilteredCookie[];
471 static const char kHandshakeResponseWithoutCookie[]; 469 static const char kHandshakeResponseWithoutCookie[];
472 static const char kHandshakeResponseWithCookie[]; 470 static const char kHandshakeResponseWithCookie[];
473 static const char kDataHello[]; 471 static const char kDataHello[];
474 static const char kDataWorld[]; 472 static const char kDataWorld[];
475 static const char* const kHandshakeRequestForSpdy[]; 473 static const char* const kHandshakeRequestForSpdy[];
476 static const char* const kHandshakeResponseForSpdy[]; 474 static const char* const kHandshakeResponseForSpdy[];
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1099
1102 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdySpdyEnabled) { 1100 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdySpdyEnabled) {
1103 WebSocketJob::set_websocket_over_spdy_enabled(true); 1101 WebSocketJob::set_websocket_over_spdy_enabled(true);
1104 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); 1102 TestConnectBySpdy(SPDY_ON, THROTTLING_ON);
1105 } 1103 }
1106 1104
1107 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. 1105 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation.
1108 // TODO(toyoshim,yutak): Add tests to verify closing handshake. 1106 // TODO(toyoshim,yutak): Add tests to verify closing handshake.
1109 1107
1110 } // namespace net 1108 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_job_spdy2_unittest.cc ('k') | net/websockets/websocket_throttle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698