diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 03:27:09 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 03:27:09 +0000 |
commit | ef2bf421b04de3134cd7c02aac40a5565ef24dd9 (patch) | |
tree | 5bf90cca0bd015c23e843614ebf2e9f99cb8cd99 /net/websockets | |
parent | 280e9b5d4b2fb0fe14824e526521710a658bce56 (diff) | |
download | chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.zip chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.tar.gz chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.tar.bz2 |
Stop refcounting URLRequestContext.
While doing so, fix a few issues with the code like ordering of URLRequestContext to ensure correct destruction order. Also fix const correctness in some places.
BUG=58859
TEST=none
TBR=willchan
Review URL: https://chromiumcodereview.appspot.com/10299002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets')
-rw-r--r-- | net/websockets/websocket_job_spdy2_unittest.cc | 8 | ||||
-rw-r--r-- | net/websockets/websocket_job_spdy3_unittest.cc | 8 | ||||
-rw-r--r-- | net/websockets/websocket_throttle_unittest.cc | 18 |
3 files changed, 15 insertions, 19 deletions
diff --git a/net/websockets/websocket_job_spdy2_unittest.cc b/net/websockets/websocket_job_spdy2_unittest.cc index 506056b..0aea40f 100644 --- a/net/websockets/websocket_job_spdy2_unittest.cc +++ b/net/websockets/websocket_job_spdy2_unittest.cc @@ -258,8 +258,6 @@ class MockURLRequestContext : public net::URLRequestContext { transport_security_state_.EnableHost("upgrademe.com", state); } - protected: - friend class base::RefCountedThreadSafe<MockURLRequestContext>; virtual ~MockURLRequestContext() {} private: @@ -337,11 +335,11 @@ class WebSocketJobSpdy2Test : public PlatformTest { SpdySession::set_default_protocol(kProtoSPDY2); stream_type_ = STREAM_INVALID; cookie_store_ = new MockCookieStore; - context_ = new MockURLRequestContext(cookie_store_.get()); + context_.reset(new MockURLRequestContext(cookie_store_.get())); } virtual void TearDown() OVERRIDE { cookie_store_ = NULL; - context_ = NULL; + context_.reset(); websocket_ = NULL; socket_ = NULL; } @@ -455,7 +453,7 @@ class WebSocketJobSpdy2Test : public PlatformTest { StreamType stream_type_; scoped_refptr<MockCookieStore> cookie_store_; - scoped_refptr<MockURLRequestContext> context_; + scoped_ptr<MockURLRequestContext> context_; scoped_refptr<WebSocketJob> websocket_; scoped_refptr<SocketStream> socket_; scoped_ptr<MockClientSocketFactory> socket_factory_; diff --git a/net/websockets/websocket_job_spdy3_unittest.cc b/net/websockets/websocket_job_spdy3_unittest.cc index e993289..c40ac79 100644 --- a/net/websockets/websocket_job_spdy3_unittest.cc +++ b/net/websockets/websocket_job_spdy3_unittest.cc @@ -262,8 +262,6 @@ class MockURLRequestContext : public net::URLRequestContext { transport_security_state_.EnableHost("upgrademe.com", state); } - protected: - friend class base::RefCountedThreadSafe<MockURLRequestContext>; virtual ~MockURLRequestContext() {} private: @@ -336,11 +334,11 @@ class WebSocketJobSpdy3Test : public PlatformTest { SpdySession::set_default_protocol(kProtoSPDY3); stream_type_ = STREAM_INVALID; cookie_store_ = new MockCookieStore; - context_ = new MockURLRequestContext(cookie_store_.get()); + context_.reset(new MockURLRequestContext(cookie_store_.get())); } virtual void TearDown() { cookie_store_ = NULL; - context_ = NULL; + context_.reset(); websocket_ = NULL; socket_ = NULL; } @@ -454,7 +452,6 @@ class WebSocketJobSpdy3Test : public PlatformTest { StreamType stream_type_; scoped_refptr<MockCookieStore> cookie_store_; - scoped_refptr<MockURLRequestContext> context_; scoped_refptr<WebSocketJob> websocket_; scoped_refptr<SocketStream> socket_; scoped_ptr<MockClientSocketFactory> socket_factory_; @@ -464,6 +461,7 @@ class WebSocketJobSpdy3Test : public PlatformTest { scoped_ptr<net::ProxyService> proxy_service_; scoped_ptr<net::MockHostResolver> host_resolver_; scoped_ptr<MockHttpTransactionFactory> http_factory_; + scoped_ptr<MockURLRequestContext> context_; static const char kHandshakeRequestWithoutCookie[]; static const char kHandshakeRequestWithCookie[]; diff --git a/net/websockets/websocket_throttle_unittest.cc b/net/websockets/websocket_throttle_unittest.cc index 734a9f9..af3e022 100644 --- a/net/websockets/websocket_throttle_unittest.cc +++ b/net/websockets/websocket_throttle_unittest.cc @@ -59,7 +59,7 @@ class WebSocketThrottleTest : public PlatformTest { }; TEST_F(WebSocketThrottleTest, Throttle) { - scoped_refptr<URLRequestContext> context(new TestURLRequestContext); + TestURLRequestContext context; DummySocketStreamDelegate delegate; // TODO(toyoshim): We need to consider both spdy-enabled and spdy-disabled // configuration. @@ -73,7 +73,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { scoped_refptr<WebSocketJob> w1(new WebSocketJob(&delegate)); scoped_refptr<SocketStream> s1( new SocketStream(GURL("ws://host1/"), w1.get())); - s1->set_context(context.get()); + s1->set_context(&context); w1->InitSocketStream(s1.get()); WebSocketThrottleTest::MockSocketStreamConnect(s1, addr); @@ -94,7 +94,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { scoped_refptr<WebSocketJob> w2(new WebSocketJob(&delegate)); scoped_refptr<SocketStream> s2( new SocketStream(GURL("ws://host2/"), w2.get())); - s2->set_context(context.get()); + s2->set_context(&context); w2->InitSocketStream(s2.get()); WebSocketThrottleTest::MockSocketStreamConnect(s2, addr); @@ -115,7 +115,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { scoped_refptr<WebSocketJob> w3(new WebSocketJob(&delegate)); scoped_refptr<SocketStream> s3( new SocketStream(GURL("ws://host3/"), w3.get())); - s3->set_context(context.get()); + s3->set_context(&context); w3->InitSocketStream(s3.get()); WebSocketThrottleTest::MockSocketStreamConnect(s3, addr); @@ -136,7 +136,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { scoped_refptr<WebSocketJob> w4(new WebSocketJob(&delegate)); scoped_refptr<SocketStream> s4( new SocketStream(GURL("ws://host4/"), w4.get())); - s4->set_context(context.get()); + s4->set_context(&context); w4->InitSocketStream(s4.get()); WebSocketThrottleTest::MockSocketStreamConnect(s4, addr); @@ -156,7 +156,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { scoped_refptr<WebSocketJob> w5(new WebSocketJob(&delegate)); scoped_refptr<SocketStream> s5( new SocketStream(GURL("ws://host5/"), w5.get())); - s5->set_context(context.get()); + s5->set_context(&context); w5->InitSocketStream(s5.get()); WebSocketThrottleTest::MockSocketStreamConnect(s5, addr); @@ -176,7 +176,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { scoped_refptr<WebSocketJob> w6(new WebSocketJob(&delegate)); scoped_refptr<SocketStream> s6( new SocketStream(GURL("ws://host6/"), w6.get())); - s6->set_context(context.get()); + s6->set_context(&context); w6->InitSocketStream(s6.get()); WebSocketThrottleTest::MockSocketStreamConnect(s6, addr); @@ -278,7 +278,7 @@ TEST_F(WebSocketThrottleTest, Throttle) { } TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) { - scoped_refptr<URLRequestContext> context(new TestURLRequestContext); + TestURLRequestContext context; DummySocketStreamDelegate delegate; WebSocketJob::set_websocket_over_spdy_enabled(true); @@ -289,7 +289,7 @@ TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) { scoped_refptr<WebSocketJob> w1(new WebSocketJob(&delegate)); scoped_refptr<SocketStream> s1( new SocketStream(GURL("ws://localhost/"), w1.get())); - s1->set_context(context.get()); + s1->set_context(&context); w1->InitSocketStream(s1.get()); WebSocketThrottleTest::MockSocketStreamConnect(s1, addr); |