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

Unified Diff: net/spdy/spdy_session.cc

Issue 18546008: [SPDY] Use WeakPtr<SpdySession> everywhere but SpdySessionPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test, other minor formatting/comment changes Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_session.cc
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 3a56a90186e2810d12cde4c3deaa6571d87fc3ae..e80a938343d30421d29bb50ca53988a9f989173d 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -240,7 +240,7 @@ SpdyStreamRequest::~SpdyStreamRequest() {
int SpdyStreamRequest::StartRequest(
SpdyStreamType type,
- const scoped_refptr<SpdySession>& session,
+ const base::WeakPtr<SpdySession>& session,
const GURL& url,
RequestPriority priority,
const BoundNetLog& net_log,
@@ -304,7 +304,7 @@ void SpdyStreamRequest::OnRequestCompleteFailure(int rv) {
void SpdyStreamRequest::Reset() {
type_ = SPDY_BIDIRECTIONAL_STREAM;
- session_ = NULL;
+ session_.reset();
stream_.reset();
url_ = GURL();
priority_ = MINIMUM_PRIORITY;
@@ -632,7 +632,8 @@ int SpdySession::CreateStream(const SpdyStreamRequest& request,
}
scoped_ptr<SpdyStream> new_stream(
- new SpdyStream(request.type(), this, request.url(), request.priority(),
+ new SpdyStream(request.type(), GetWeakPtr(), request.url(),
+ request.priority(),
stream_initial_send_window_size_,
stream_initial_recv_window_size_,
request.net_log()));
@@ -723,6 +724,10 @@ int SpdySession::GetProtocolVersion() const {
return buffered_spdy_framer_->protocol_version();
}
+base::WeakPtr<SpdySession> SpdySession::GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+}
+
bool SpdySession::CloseOneIdleConnection() {
CHECK(!in_io_loop_);
DCHECK(pool_);
@@ -1325,7 +1330,7 @@ int SpdySession::DoWrite() {
int SpdySession::DoWriteComplete(int result) {
CHECK(in_io_loop_);
DCHECK_NE(availability_state_, STATE_CLOSED);
-
+ DCHECK_NE(result, ERR_IO_PENDING);
DCHECK_GT(in_flight_write_->GetRemainingSize(), 0u);
last_activity_time_ = time_func_();
@@ -1466,7 +1471,7 @@ SpdySession::CloseSessionResult SpdySession::DoCloseSession(
// |pool_| will be NULL when |InitializeWithSocket()| is in the
// call stack.
if (pool_ && availability_state_ != STATE_GOING_AWAY)
- pool_->MakeSessionUnavailable(make_scoped_refptr(this));
+ pool_->MakeSessionUnavailable(GetWeakPtr());
availability_state_ = STATE_CLOSED;
error_on_close_ = err;
@@ -1489,7 +1494,7 @@ void SpdySession::RemoveFromPool() {
SpdySessionPool* pool = pool_;
pool_ = NULL;
- pool->RemoveUnavailableSession(make_scoped_refptr(this));
+ pool->RemoveUnavailableSession(GetWeakPtr());
}
void SpdySession::LogAbandonedStream(SpdyStream* stream, Error status) {
@@ -2028,7 +2033,7 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id,
}
scoped_ptr<SpdyStream> stream(
- new SpdyStream(SPDY_PUSH_STREAM, this, gurl,
+ new SpdyStream(SPDY_PUSH_STREAM, GetWeakPtr(), gurl,
request_priority,
stream_initial_send_window_size_,
stream_initial_recv_window_size_,
@@ -2225,7 +2230,7 @@ void SpdySession::OnGoAway(SpdyStreamId last_accepted_stream_id,
// |pool_| will be NULL when |InitializeWithSocket()| is in the
// call stack.
if (pool_)
- pool_->MakeSessionUnavailable(make_scoped_refptr(this));
+ pool_->MakeSessionUnavailable(GetWeakPtr());
}
StartGoingAway(last_accepted_stream_id, ERR_ABORTED);
// This is to handle the case when we already don't have any active
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698