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

Unified Diff: net/http/http_stream_factory_impl_job.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/http/http_stream_factory_impl_job.h ('k') | net/http/http_stream_factory_impl_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_impl_job.cc
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index 937d7db54dbae7240cc6e8b446a74bb3a6fc3d8c..b2eee3b0fbeff565005298301ccca985025b8467 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -4,6 +4,7 @@
#include "net/http/http_stream_factory_impl_job.h"
+#include <algorithm>
#include <string>
#include "base/bind.h"
@@ -330,9 +331,10 @@ void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() {
DCHECK(!stream_.get());
DCHECK(!IsPreconnecting());
DCHECK(using_spdy());
- DCHECK(new_spdy_session_.get());
- scoped_refptr<SpdySession> spdy_session = new_spdy_session_;
- new_spdy_session_ = NULL;
+ if (!new_spdy_session_)
+ return;
+ base::WeakPtr<SpdySession> spdy_session = new_spdy_session_;
+ new_spdy_session_.reset();
if (IsOrphaned()) {
stream_factory_->OnNewSpdySessionReady(
spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_,
@@ -762,7 +764,7 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
// Check first if we have a spdy session for this group. If so, then go
// straight to using that.
SpdySessionKey spdy_session_key = GetSpdySessionKey();
- scoped_refptr<SpdySession> spdy_session =
+ base::WeakPtr<SpdySession> spdy_session =
session_->spdy_session_pool()->FindAvailableSession(
spdy_session_key, net_log_);
if (spdy_session && CanUseExistingSpdySession()) {
@@ -1097,13 +1099,13 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
direct = false;
}
- scoped_refptr<SpdySession> spdy_session;
+ base::WeakPtr<SpdySession> spdy_session;
if (existing_spdy_session_.get()) {
// We picked up an existing session, so we don't need our socket.
if (connection_->socket())
connection_->socket()->Disconnect();
connection_->Reset();
- spdy_session.swap(existing_spdy_session_);
+ std::swap(spdy_session, existing_spdy_session_);
} else {
SpdySessionPool* spdy_pool = session_->spdy_session_pool();
spdy_session = spdy_pool->FindAvailableSession(spdy_session_key, net_log_);
@@ -1127,7 +1129,7 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
}
}
- if (spdy_session->IsClosed())
+ if (!spdy_session)
return ERR_CONNECTION_CLOSED;
// TODO(willchan): Delete this code, because eventually, the
@@ -1140,10 +1142,10 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
bool use_relative_url = direct || request_info_.url.SchemeIs("wss");
websocket_stream_.reset(
request_->websocket_stream_factory()->CreateSpdyStream(
- spdy_session.get(), use_relative_url));
+ spdy_session, use_relative_url));
} else {
bool use_relative_url = direct || request_info_.url.SchemeIs("https");
- stream_.reset(new SpdyHttpStream(spdy_session.get(), use_relative_url));
+ stream_.reset(new SpdyHttpStream(spdy_session, use_relative_url));
}
return OK;
}
« no previous file with comments | « net/http/http_stream_factory_impl_job.h ('k') | net/http/http_stream_factory_impl_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698