| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/resource_messages.h" | 9 #include "content/common/resource_messages.h" |
| 10 #include "content/common/socket_stream.h" | 10 #include "content/common/socket_stream.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 bool SocketStreamDispatcherHost::CanSetCookie(net::SocketStream* request, | 128 bool SocketStreamDispatcherHost::CanSetCookie(net::SocketStream* request, |
| 129 const GURL& url, | 129 const GURL& url, |
| 130 const std::string& cookie_line, | 130 const std::string& cookie_line, |
| 131 net::CookieOptions* options) { | 131 net::CookieOptions* options) { |
| 132 return content::GetContentClient()->browser()->AllowSetCookie( | 132 return content::GetContentClient()->browser()->AllowSetCookie( |
| 133 url, url, cookie_line, resource_context_, 0, MSG_ROUTING_NONE, options); | 133 url, url, cookie_line, resource_context_, 0, MSG_ROUTING_NONE, options); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Message handlers called by OnMessageReceived. | 136 // Message handlers called by OnMessageReceived. |
| 137 void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) { | 137 void SocketStreamDispatcherHost::OnConnect(int render_view_id, |
| 138 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect url=" << url | 138 const GURL& url, |
| 139 int socket_id) { |
| 140 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect" |
| 141 << " render_view_id=" << render_view_id |
| 142 << " url=" << url |
| 139 << " socket_id=" << socket_id; | 143 << " socket_id=" << socket_id; |
| 140 DCHECK_NE(content::kNoSocketId, socket_id); | 144 DCHECK_NE(content::kNoSocketId, socket_id); |
| 141 if (hosts_.Lookup(socket_id)) { | 145 if (hosts_.Lookup(socket_id)) { |
| 142 LOG(ERROR) << "socket_id=" << socket_id << " already registered."; | 146 LOG(ERROR) << "socket_id=" << socket_id << " already registered."; |
| 143 return; | 147 return; |
| 144 } | 148 } |
| 145 SocketStreamHost* socket_stream_host = new SocketStreamHost(this, socket_id); | 149 SocketStreamHost* socket_stream_host = |
| 150 new SocketStreamHost(this, render_view_id, socket_id); |
| 146 hosts_.AddWithID(socket_stream_host, socket_id); | 151 hosts_.AddWithID(socket_stream_host, socket_id); |
| 147 socket_stream_host->Connect(url, GetURLRequestContext()); | 152 socket_stream_host->Connect(url, GetURLRequestContext()); |
| 148 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect -> " << socket_id; | 153 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect -> " << socket_id; |
| 149 } | 154 } |
| 150 | 155 |
| 151 void SocketStreamDispatcherHost::OnSendData( | 156 void SocketStreamDispatcherHost::OnSendData( |
| 152 int socket_id, const std::vector<char>& data) { | 157 int socket_id, const std::vector<char>& data) { |
| 153 DVLOG(1) << "SocketStreamDispatcherHost::OnSendData socket_id=" << socket_id; | 158 DVLOG(1) << "SocketStreamDispatcherHost::OnSendData socket_id=" << socket_id; |
| 154 SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id); | 159 SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id); |
| 155 if (!socket_stream_host) { | 160 if (!socket_stream_host) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 177 hosts_.Remove(socket_id); | 182 hosts_.Remove(socket_id); |
| 178 if (!Send(new SocketStreamMsg_Closed(socket_id))) { | 183 if (!Send(new SocketStreamMsg_Closed(socket_id))) { |
| 179 LOG(ERROR) << "SocketStreamMsg_Closed failed."; | 184 LOG(ERROR) << "SocketStreamMsg_Closed failed."; |
| 180 } | 185 } |
| 181 } | 186 } |
| 182 | 187 |
| 183 net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() { | 188 net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() { |
| 184 return url_request_context_selector_->GetRequestContext( | 189 return url_request_context_selector_->GetRequestContext( |
| 185 ResourceType::SUB_RESOURCE); | 190 ResourceType::SUB_RESOURCE); |
| 186 } | 191 } |
| OLD | NEW |