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

Unified Diff: chrome/browser/renderer_host/socket_stream_host.cc

Issue 5406002: Use proper URLRequestContext for WebSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for review comments Created 10 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/socket_stream_host.cc
diff --git a/chrome/browser/renderer_host/socket_stream_host.cc b/chrome/browser/renderer_host/socket_stream_host.cc
index 211064f332a3fa6d3d1a64b1b0fa768b4e30b306..89379d1873c5b53711f218e43a95a67c644b2f53 100644
--- a/chrome/browser/renderer_host/socket_stream_host.cc
+++ b/chrome/browser/renderer_host/socket_stream_host.cc
@@ -9,8 +9,10 @@
#include "chrome/common/net/socket_stream.h"
#include "chrome/common/net/url_request_context_getter.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/render_messages_params.h"
#include "net/socket_stream/socket_stream_job.h"
Randy Smith (Not in Mondays) 2010/12/26 19:44:28 Nit: Remove extra blank line.
+
static const char* kSocketHostKey = "socketHost";
class SocketStreamInfo : public net::SocketStream::UserData {
@@ -55,9 +57,23 @@ SocketStreamHost::~SocketStreamHost() {
void SocketStreamHost::Connect(const GURL& url) {
VLOG(1) << "SocketStreamHost::Connect url=" << url;
socket_ = net::SocketStreamJob::CreateSocketStreamJob(url, delegate_);
- URLRequestContextGetter* context_getter = Profile::GetDefaultRequestContext();
- if (context_getter)
- socket_->set_context(context_getter->GetURLRequestContext());
+
+ // We use request_id==0 and request_data.resource_type=ResourceType::LAST_TYPE
+ // here.
+ // ResourceMessageFilter::GetRequestContext() doesn't check request_id
+ // and only checks request_data.resource_type is ResourceType::MEDIA or not.
+ // TODO(ukai): merge WebSocketStreamHandleBridge into ResourceLoaderBridge,
+ // so that we can use the same request_id.
+ ViewHostMsg_Resource_Request request_data;
+ request_data.resource_type = ResourceType::LAST_TYPE;
+ URLRequestContext* context = receiver_->GetRequestContext(0, request_data);
+ if (!context) {
+ URLRequestContextGetter* context_getter =
+ Profile::GetDefaultRequestContext();
+ if (context_getter)
+ context = context_getter->GetURLRequestContext();
+ }
+ socket_->set_context(context);
socket_->SetUserData(kSocketHostKey, new SocketStreamInfo(this));
socket_->Connect();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698