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

Side by Side Diff: content/browser/renderer_host/socket_stream_dispatcher_host.cc

Issue 9369009: Make content::ResourceContext be a real interface like the rest of the Content API (i.e. don't ha... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" 5 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/socket_stream_host.h" 8 #include "content/browser/renderer_host/socket_stream_host.h"
9 #include "content/common/socket_stream.h" 9 #include "content/common/socket_stream.h"
10 #include "content/common/socket_stream_messages.h" 10 #include "content/common/socket_stream_messages.h"
11 #include "content/common/resource_messages.h" 11 #include "content/common/resource_messages.h"
12 #include "content/public/browser/content_browser_client.h" 12 #include "content/public/browser/content_browser_client.h"
13 #include "net/base/cookie_monster.h" 13 #include "net/base/cookie_monster.h"
14 #include "net/url_request/url_request_context_getter.h" 14 #include "net/url_request/url_request_context_getter.h"
15 #include "net/websockets/websocket_job.h" 15 #include "net/websockets/websocket_job.h"
16 #include "net/websockets/websocket_throttle.h" 16 #include "net/websockets/websocket_throttle.h"
17 17
18 SocketStreamDispatcherHost::SocketStreamDispatcherHost( 18 SocketStreamDispatcherHost::SocketStreamDispatcherHost(
19 ResourceMessageFilter::URLRequestContextSelector* selector, 19 ResourceMessageFilter::URLRequestContextSelector* selector,
20 const content::ResourceContext* resource_context) 20 content::ResourceContext* resource_context)
21 : url_request_context_selector_(selector), 21 : url_request_context_selector_(selector),
22 resource_context_(resource_context) { 22 resource_context_(resource_context) {
23 DCHECK(selector); 23 DCHECK(selector);
24 net::WebSocketJob::EnsureInit(); 24 net::WebSocketJob::EnsureInit();
25 } 25 }
26 26
27 SocketStreamDispatcherHost::~SocketStreamDispatcherHost() { 27 SocketStreamDispatcherHost::~SocketStreamDispatcherHost() {
28 // TODO(ukai): Implement IDMap::RemoveAll(). 28 // TODO(ukai): Implement IDMap::RemoveAll().
29 for (IDMap<SocketStreamHost>::const_iterator iter(&hosts_); 29 for (IDMap<SocketStreamHost>::const_iterator iter(&hosts_);
30 !iter.IsAtEnd(); 30 !iter.IsAtEnd();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (socket_id == content_common::kNoSocketId) { 102 if (socket_id == content_common::kNoSocketId) {
103 LOG(ERROR) << "NoSocketId in OnClose"; 103 LOG(ERROR) << "NoSocketId in OnClose";
104 return; 104 return;
105 } 105 }
106 DeleteSocketStreamHost(socket_id); 106 DeleteSocketStreamHost(socket_id);
107 } 107 }
108 108
109 bool SocketStreamDispatcherHost::CanGetCookies(net::SocketStream* socket, 109 bool SocketStreamDispatcherHost::CanGetCookies(net::SocketStream* socket,
110 const GURL& url) { 110 const GURL& url) {
111 return content::GetContentClient()->browser()->AllowGetCookie( 111 return content::GetContentClient()->browser()->AllowGetCookie(
112 url, url, net::CookieList(), *resource_context_, 0, MSG_ROUTING_NONE); 112 url, url, net::CookieList(), resource_context_, 0, MSG_ROUTING_NONE);
113 } 113 }
114 114
115 bool SocketStreamDispatcherHost::CanSetCookie(net::SocketStream* request, 115 bool SocketStreamDispatcherHost::CanSetCookie(net::SocketStream* request,
116 const GURL& url, 116 const GURL& url,
117 const std::string& cookie_line, 117 const std::string& cookie_line,
118 net::CookieOptions* options) { 118 net::CookieOptions* options) {
119 return content::GetContentClient()->browser()->AllowSetCookie( 119 return content::GetContentClient()->browser()->AllowSetCookie(
120 url, url, cookie_line, *resource_context_, 0, MSG_ROUTING_NONE, options); 120 url, url, cookie_line, resource_context_, 0, MSG_ROUTING_NONE, options);
121 } 121 }
122 122
123 // Message handlers called by OnMessageReceived. 123 // Message handlers called by OnMessageReceived.
124 void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) { 124 void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) {
125 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect url=" << url 125 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect url=" << url
126 << " socket_id=" << socket_id; 126 << " socket_id=" << socket_id;
127 DCHECK_NE(content_common::kNoSocketId, socket_id); 127 DCHECK_NE(content_common::kNoSocketId, socket_id);
128 if (hosts_.Lookup(socket_id)) { 128 if (hosts_.Lookup(socket_id)) {
129 LOG(ERROR) << "socket_id=" << socket_id << " already registered."; 129 LOG(ERROR) << "socket_id=" << socket_id << " already registered.";
130 return; 130 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 hosts_.Remove(socket_id); 164 hosts_.Remove(socket_id);
165 if (!Send(new SocketStreamMsg_Closed(socket_id))) { 165 if (!Send(new SocketStreamMsg_Closed(socket_id))) {
166 LOG(ERROR) << "SocketStreamMsg_Closed failed."; 166 LOG(ERROR) << "SocketStreamMsg_Closed failed.";
167 } 167 }
168 } 168 }
169 169
170 net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() { 170 net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() {
171 return url_request_context_selector_->GetRequestContext( 171 return url_request_context_selector_->GetRequestContext(
172 ResourceType::SUB_RESOURCE); 172 ResourceType::SUB_RESOURCE);
173 } 173 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/socket_stream_dispatcher_host.h ('k') | content/browser/resource_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698