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

Unified Diff: net/socket_stream/socket_stream.cc

Issue 197043005: original change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix other build error Created 6 years, 9 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/socket_stream/socket_stream.h ('k') | net/socket_stream/socket_stream_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket_stream/socket_stream.cc
===================================================================
--- net/socket_stream/socket_stream.cc (revision 256594)
+++ net/socket_stream/socket_stream.cc (working copy)
@@ -87,11 +87,13 @@
SocketStream::ResponseHeaders::~ResponseHeaders() { data_ = NULL; }
-SocketStream::SocketStream(const GURL& url, Delegate* delegate)
+SocketStream::SocketStream(const GURL& url, Delegate* delegate,
+ URLRequestContext* context,
+ CookieStore* cookie_store)
: delegate_(delegate),
url_(url),
max_pending_send_allowed_(kMaxPendingSendAllowed),
- context_(NULL),
+ context_(context),
next_state_(STATE_NONE),
factory_(ClientSocketFactory::GetDefaultFactory()),
proxy_mode_(kDirectConnection),
@@ -108,12 +110,24 @@
waiting_for_write_completion_(false),
closing_(false),
server_closed_(false),
- metrics_(new SocketStreamMetrics(url)) {
+ metrics_(new SocketStreamMetrics(url)),
+ cookie_store_(cookie_store) {
DCHECK(base::MessageLoop::current())
<< "The current base::MessageLoop must exist";
DCHECK(base::MessageLoopForIO::IsCurrent())
<< "The current base::MessageLoop must be TYPE_IO";
DCHECK(delegate_);
+
+ if (context_) {
+ if (!cookie_store_)
+ cookie_store_ = context_->cookie_store();
+
+ net_log_ = BoundNetLog::Make(
+ context->net_log(),
+ NetLog::SOURCE_SOCKET_STREAM);
+
+ net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE);
+ }
}
SocketStream::UserData* SocketStream::GetUserData(
@@ -132,28 +146,20 @@
return url_.SchemeIs("wss");
}
-void SocketStream::set_context(URLRequestContext* context) {
- const URLRequestContext* prev_context = context_;
+void SocketStream::DetachContext() {
+ if (!context_)
+ return;
- context_ = context;
+ if (pac_request_) {
+ context_->proxy_service()->CancelPacRequest(pac_request_);
+ pac_request_ = NULL;
+ }
- if (prev_context != context) {
- if (prev_context && pac_request_) {
- prev_context->proxy_service()->CancelPacRequest(pac_request_);
- pac_request_ = NULL;
- }
+ net_log_.EndEvent(NetLog::TYPE_REQUEST_ALIVE);
+ net_log_ = BoundNetLog();
- net_log_.EndEvent(NetLog::TYPE_REQUEST_ALIVE);
- net_log_ = BoundNetLog();
-
- if (context) {
- net_log_ = BoundNetLog::Make(
- context->net_log(),
- NetLog::SOURCE_SOCKET_STREAM);
-
- net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE);
- }
- }
+ context_ = NULL;
+ cookie_store_ = NULL;
}
void SocketStream::CheckPrivacyMode() {
@@ -318,7 +324,7 @@
}
SocketStream::~SocketStream() {
- set_context(NULL);
+ DetachContext();
DCHECK(!delegate_);
DCHECK(!pac_request_);
}
@@ -1342,4 +1348,8 @@
return ERR_IO_PENDING;
}
+CookieStore* SocketStream::cookie_store() const {
+ return cookie_store_;
+}
+
} // namespace net
« no previous file with comments | « net/socket_stream/socket_stream.h ('k') | net/socket_stream/socket_stream_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698