[SPDY] Use WeakPtr<SpdySession> everywhere but SpdySessionPool
Make SpdyHttpStream cache it's SPDY stream's LoadTimingInfo
on close. Also, make SpdyHttpStream query SpdySession::IsReused()
when it's constructed and cache the value, as that's closer to the
intent of its use.
Avoid uses of SpdySession::IsClosed() in non-test code and add
TODO to remove uses from test code. This is more correct since
testing the WeakPtr is a stronger condition than testing openness
and SpdySession functions already do the right thing if the
SpdySession is already closed.
Tweak some tests that implicitly depended on
having refs to SpdySession.
BUG=255701
[email protected]
Review URL: https://codereview.chromium.org/18546008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212858 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/spdy/spdy_http_stream_unittest.cc b/net/spdy/spdy_http_stream_unittest.cc
index c6703fc..26d87d85 100644
--- a/net/spdy/spdy_http_stream_unittest.cc
+++ b/net/spdy/spdy_http_stream_unittest.cc
@@ -121,7 +121,7 @@
scoped_ptr<OrderedSocketData> data_;
scoped_ptr<DeterministicSocketData> deterministic_data_;
scoped_refptr<HttpNetworkSession> http_session_;
- scoped_refptr<SpdySession> session_;
+ base::WeakPtr<SpdySession> session_;
private:
MockECSignatureCreatorFactory ec_signature_creator_factory_;
@@ -144,7 +144,7 @@
kPrivacyModeDisabled);
InitSession(reads, arraysize(reads), NULL, 0, key);
- SpdyHttpStream stream(session_.get(), false);
+ SpdyHttpStream stream(session_, false);
UploadProgress progress = stream.GetUploadProgress();
EXPECT_EQ(0u, progress.size());
EXPECT_EQ(0u, progress.position());
@@ -174,8 +174,7 @@
HttpResponseInfo response;
HttpRequestHeaders headers;
BoundNetLog net_log;
- scoped_ptr<SpdyHttpStream> http_stream(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_, true));
// Make sure getting load timing information the stream early does not crash.
LoadTimingInfo load_timing_info;
EXPECT_FALSE(http_stream->GetLoadTimingInfo(&load_timing_info));
@@ -251,8 +250,7 @@
TestCompletionCallback callback1;
HttpResponseInfo response1;
HttpRequestHeaders headers1;
- scoped_ptr<SpdyHttpStream> http_stream1(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream1(new SpdyHttpStream(session_, true));
HttpRequestInfo request2;
request2.method = "GET";
@@ -260,8 +258,7 @@
TestCompletionCallback callback2;
HttpResponseInfo response2;
HttpRequestHeaders headers2;
- scoped_ptr<SpdyHttpStream> http_stream2(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream2(new SpdyHttpStream(session_, true));
// First write.
ASSERT_EQ(OK,
@@ -354,7 +351,7 @@
HttpResponseInfo response;
HttpRequestHeaders headers;
BoundNetLog net_log;
- SpdyHttpStream http_stream(session_.get(), true);
+ SpdyHttpStream http_stream(session_, true);
ASSERT_EQ(
OK,
http_stream.InitializeStream(&request, DEFAULT_PRIORITY,
@@ -423,8 +420,7 @@
upload_stream.AppendChunk(kUploadData, kUploadDataSize, false);
BoundNetLog net_log;
- scoped_ptr<SpdyHttpStream> http_stream(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_, true));
ASSERT_EQ(OK, http_stream->InitializeStream(&request, DEFAULT_PRIORITY,
net_log, CompletionCallback()));
@@ -512,8 +508,7 @@
HttpResponseInfo response;
HttpRequestHeaders headers;
BoundNetLog net_log;
- scoped_ptr<SpdyHttpStream> http_stream(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_, true));
ASSERT_EQ(OK,
http_stream->InitializeStream(
&request, DEFAULT_PRIORITY, net_log, CompletionCallback()));
@@ -656,8 +651,7 @@
HttpResponseInfo response;
HttpRequestHeaders headers;
BoundNetLog net_log;
- scoped_ptr<SpdyHttpStream> http_stream(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_, true));
ASSERT_EQ(
OK,
http_stream->InitializeStream(&request, DEFAULT_PRIORITY,
@@ -676,8 +670,7 @@
callback.WaitForResult();
// Start up second request for resource on a new origin.
- scoped_ptr<SpdyHttpStream> http_stream2(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream2(new SpdyHttpStream(session_, true));
request.url = GURL(kUrl2);
ASSERT_EQ(
OK,
@@ -739,8 +732,7 @@
upload_stream.AppendChunk(kUploadData, kUploadDataSize, true);
BoundNetLog net_log;
- scoped_ptr<SpdyHttpStream> http_stream(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_, true));
ASSERT_EQ(OK, http_stream->InitializeStream(&request, DEFAULT_PRIORITY,
net_log, CompletionCallback()));
@@ -866,8 +858,7 @@
HttpResponseInfo response;
HttpRequestHeaders headers;
BoundNetLog net_log;
- scoped_ptr<SpdyHttpStream> http_stream(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_, true));
ASSERT_EQ(
OK,
http_stream->InitializeStream(&request, DEFAULT_PRIORITY,
@@ -882,8 +873,7 @@
EXPECT_EQ(OK, callback.WaitForResult());
// Start up second request for resource on a new origin.
- scoped_ptr<SpdyHttpStream> http_stream2(
- new SpdyHttpStream(session_.get(), true));
+ scoped_ptr<SpdyHttpStream> http_stream2(new SpdyHttpStream(session_, true));
request.url = GURL(kUrl2);
ASSERT_EQ(
OK,