Change WeakPtr<SpdyStream> to raw pointer in SpdyHttpStream.
This allows for more explicit expression of lifetime expectations.
SpdyStream instances are created in SpdySession::CreateStream() and in
SpdySession::TryCreatePushStream(), and are owned by SpdySession in its
|created_streams_| and |active_streams_| members. They are destroyed in
SpdySession::CloseActiveStreamIterator() and in
SpdySession::CloseCreatedStreamIterator(),
and SpdySession::DeleteStream() is always called by these methods.
This always calls SpdyStream::OnClose() before deleting the stream,
which in turn calls SpdyStream::Delegate::OnClose().
Every time SpdyHttpStream grabs a handle of a SpdyStream, it immediately
registers itself as a delegate. That means that every time a SpdyStream
instance is destroyed, if a SpdyHttpStream instance has a handle of it,
it will get notified. That is, SpdyHttpStream does not actually need to
keep a WeakPtr<SpdyStream>: a raw pointer suffices.
Review-Url: https://codereview.chromium.org/2642133002
Cr-Commit-Position: refs/heads/master@{#445302}
diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc
index 9f60908..495b7d4 100644
--- a/net/spdy/spdy_stream_unittest.cc
+++ b/net/spdy/spdy_stream_unittest.cc
@@ -343,7 +343,7 @@
data.RunUntilPaused();
- base::WeakPtr<SpdyStream> push_stream;
+ SpdyStream* push_stream;
EXPECT_THAT(session->GetPushStream(GURL(kPushUrl), IDLE, &push_stream,
NetLogWithSource()),
IsOk());
@@ -355,7 +355,7 @@
EXPECT_EQ(g_time_now, load_timing_info.push_start);
EXPECT_TRUE(load_timing_info.push_end.is_null());
- StreamDelegateDoNothing push_delegate(push_stream);
+ StreamDelegateDoNothing push_delegate(push_stream->GetWeakPtr());
push_stream->SetDelegate(&push_delegate);
data.Resume();
@@ -656,7 +656,7 @@
data.RunUntilPaused();
- base::WeakPtr<SpdyStream> push_stream;
+ SpdyStream* push_stream;
EXPECT_THAT(session->GetPushStream(GURL(kPushUrl), IDLE, &push_stream,
NetLogWithSource()),
IsOk());