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

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: Created 10 years, 1 month 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 a6f8ddd3e43b0e75303578d23019799432488aba..ed7555610aa938598f88ef6962fd320136819483 100644
--- a/chrome/browser/renderer_host/socket_stream_host.cc
+++ b/chrome/browser/renderer_host/socket_stream_host.cc
@@ -6,11 +6,14 @@
#include "base/logging.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/net/chrome_url_request_context.h"
#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"
+
static const char* kSocketHostKey = "socketHost";
class SocketStreamInfo : public net::SocketStream::UserData {
@@ -55,9 +58,25 @@ 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::GetReuqestContext() doesn't check request_id
eroman 2010/12/03 06:16:39 typo: RequestContext
ukai 2010/12/07 02:21:04 Done.
+ // 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.
Randy Smith (Not in Mondays) 2010/11/30 18:17:47 So the problem I have with this approach is that,
+ ViewHostMsg_Resource_Request request_data;
+ request_data.resource_type = ResourceType::LAST_TYPE;
+ ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>(
Randy Smith (Not in Mondays) 2010/11/30 18:17:47 Why make context of type ChromeURLRequestContext r
ukai 2010/12/07 02:21:04 Done.
+ receiver_->GetRequestContext(0, request_data));
+ if (!context) {
+ URLRequestContextGetter* context_getter =
+ Profile::GetDefaultRequestContext();
+ if (context_getter)
+ context = static_cast<ChromeURLRequestContext*>(
+ 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