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

Side by Side Diff: net/websockets/websocket_job_spdy2_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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 explicit MockURLRequestContext(net::CookieStore* cookie_store) 251 explicit MockURLRequestContext(net::CookieStore* cookie_store)
252 : transport_security_state_() { 252 : transport_security_state_() {
253 set_cookie_store(cookie_store); 253 set_cookie_store(cookie_store);
254 set_transport_security_state(&transport_security_state_); 254 set_transport_security_state(&transport_security_state_);
255 net::TransportSecurityState::DomainState state; 255 net::TransportSecurityState::DomainState state;
256 state.upgrade_expiry = base::Time::Now() + 256 state.upgrade_expiry = base::Time::Now() +
257 base::TimeDelta::FromSeconds(1000); 257 base::TimeDelta::FromSeconds(1000);
258 transport_security_state_.EnableHost("upgrademe.com", state); 258 transport_security_state_.EnableHost("upgrademe.com", state);
259 } 259 }
260 260
261 protected:
262 friend class base::RefCountedThreadSafe<MockURLRequestContext>;
263 virtual ~MockURLRequestContext() {} 261 virtual ~MockURLRequestContext() {}
264 262
265 private: 263 private:
266 net::TransportSecurityState transport_security_state_; 264 net::TransportSecurityState transport_security_state_;
267 }; 265 };
268 266
269 class MockHttpTransactionFactory : public net::HttpTransactionFactory { 267 class MockHttpTransactionFactory : public net::HttpTransactionFactory {
270 public: 268 public:
271 explicit MockHttpTransactionFactory(net::OrderedSocketData* data) { 269 explicit MockHttpTransactionFactory(net::OrderedSocketData* data) {
272 data_ = data; 270 data_ = data;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } // namespace 328 } // namespace
331 329
332 namespace net { 330 namespace net {
333 331
334 class WebSocketJobSpdy2Test : public PlatformTest { 332 class WebSocketJobSpdy2Test : public PlatformTest {
335 public: 333 public:
336 virtual void SetUp() OVERRIDE { 334 virtual void SetUp() OVERRIDE {
337 SpdySession::set_default_protocol(kProtoSPDY2); 335 SpdySession::set_default_protocol(kProtoSPDY2);
338 stream_type_ = STREAM_INVALID; 336 stream_type_ = STREAM_INVALID;
339 cookie_store_ = new MockCookieStore; 337 cookie_store_ = new MockCookieStore;
340 context_ = new MockURLRequestContext(cookie_store_.get()); 338 context_.reset(new MockURLRequestContext(cookie_store_.get()));
341 } 339 }
342 virtual void TearDown() OVERRIDE { 340 virtual void TearDown() OVERRIDE {
343 cookie_store_ = NULL; 341 cookie_store_ = NULL;
344 context_ = NULL; 342 context_.reset();
345 websocket_ = NULL; 343 websocket_ = NULL;
346 socket_ = NULL; 344 socket_ = NULL;
347 } 345 }
348 void DoSendRequest() { 346 void DoSendRequest() {
349 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie, 347 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie,
350 kHandshakeRequestWithoutCookieLength)); 348 kHandshakeRequestWithoutCookieLength));
351 } 349 }
352 void DoSendData() { 350 void DoSendData() {
353 if (received_data().size() == kHandshakeResponseWithoutCookieLength) 351 if (received_data().size() == kHandshakeResponseWithoutCookieLength)
354 websocket_->SendData(kDataHello, kDataHelloLength); 352 websocket_->SendData(kDataHello, kDataHelloLength);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 void TestSlowHandshake(); 446 void TestSlowHandshake();
449 void TestHandshakeWithCookie(); 447 void TestHandshakeWithCookie();
450 void TestHandshakeWithCookieButNotAllowed(); 448 void TestHandshakeWithCookieButNotAllowed();
451 void TestHSTSUpgrade(); 449 void TestHSTSUpgrade();
452 void TestInvalidSendData(); 450 void TestInvalidSendData();
453 void TestConnectByWebSocket(ThrottlingOption throttling); 451 void TestConnectByWebSocket(ThrottlingOption throttling);
454 void TestConnectBySpdy(SpdyOption spdy, ThrottlingOption throttling); 452 void TestConnectBySpdy(SpdyOption spdy, ThrottlingOption throttling);
455 453
456 StreamType stream_type_; 454 StreamType stream_type_;
457 scoped_refptr<MockCookieStore> cookie_store_; 455 scoped_refptr<MockCookieStore> cookie_store_;
458 scoped_refptr<MockURLRequestContext> context_; 456 scoped_ptr<MockURLRequestContext> context_;
459 scoped_refptr<WebSocketJob> websocket_; 457 scoped_refptr<WebSocketJob> websocket_;
460 scoped_refptr<SocketStream> socket_; 458 scoped_refptr<SocketStream> socket_;
461 scoped_ptr<MockClientSocketFactory> socket_factory_; 459 scoped_ptr<MockClientSocketFactory> socket_factory_;
462 scoped_ptr<OrderedSocketData> data_; 460 scoped_ptr<OrderedSocketData> data_;
463 TestCompletionCallback sync_test_callback_; 461 TestCompletionCallback sync_test_callback_;
464 scoped_refptr<MockSSLConfigService> ssl_config_service_; 462 scoped_refptr<MockSSLConfigService> ssl_config_service_;
465 scoped_ptr<net::ProxyService> proxy_service_; 463 scoped_ptr<net::ProxyService> proxy_service_;
466 scoped_ptr<net::MockHostResolver> host_resolver_; 464 scoped_ptr<net::MockHostResolver> host_resolver_;
467 scoped_ptr<MockHttpTransactionFactory> http_factory_; 465 scoped_ptr<MockHttpTransactionFactory> http_factory_;
468 466
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1100
1103 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { 1101 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) {
1104 WebSocketJob::set_websocket_over_spdy_enabled(true); 1102 WebSocketJob::set_websocket_over_spdy_enabled(true);
1105 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); 1103 TestConnectBySpdy(SPDY_ON, THROTTLING_ON);
1106 } 1104 }
1107 1105
1108 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. 1106 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation.
1109 // TODO(toyoshim,yutak): Add tests to verify closing handshake. 1107 // TODO(toyoshim,yutak): Add tests to verify closing handshake.
1110 1108
1111 } // namespace net 1109 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/view_cache_helper_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