| 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/browser/ssl/ssl_manager.h" | 9 #include "content/browser/ssl/ssl_manager.h" |
| 10 #include "content/common/resource_messages.h" | 10 #include "content/common/resource_messages.h" |
| 11 #include "content/common/socket_stream.h" | 11 #include "content/common/socket_stream.h" |
| 12 #include "content/common/socket_stream_messages.h" | 12 #include "content/common/socket_stream_messages.h" |
| 13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
| 14 #include "content/public/browser/global_request_id.h" | 14 #include "content/public/browser/global_request_id.h" |
| 15 #include "net/cookies/cookie_monster.h" | 15 #include "net/cookies/cookie_monster.h" |
| 16 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
| 17 #include "net/websockets/websocket_job.h" | 17 #include "net/websockets/websocket_job.h" |
| 18 #include "net/websockets/websocket_throttle.h" | 18 #include "net/websockets/websocket_throttle.h" |
| 19 | 19 |
| 20 SocketStreamDispatcherHost::SocketStreamDispatcherHost( | 20 SocketStreamDispatcherHost::SocketStreamDispatcherHost( |
| 21 int render_process_id, | 21 int render_process_id, |
| 22 ResourceMessageFilter::URLRequestContextSelector* selector, | 22 ResourceMessageFilter::URLRequestContextSelector* selector, |
| 23 content::ResourceContext* resource_context) | 23 content::ResourceContext* resource_context) |
| 24 : ALLOW_THIS_IN_INITIALIZER_LIST(ssl_delegate_weak_factory_(this)), | 24 : render_process_id_(render_process_id), |
| 25 render_process_id_(render_process_id), | |
| 26 url_request_context_selector_(selector), | 25 url_request_context_selector_(selector), |
| 27 resource_context_(resource_context) { | 26 resource_context_(resource_context) { |
| 28 DCHECK(selector); | 27 DCHECK(selector); |
| 29 net::WebSocketJob::EnsureInit(); | 28 net::WebSocketJob::EnsureInit(); |
| 30 } | 29 } |
| 31 | 30 |
| 32 bool SocketStreamDispatcherHost::OnMessageReceived(const IPC::Message& message, | 31 bool SocketStreamDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 33 bool* message_was_ok) { | 32 bool* message_was_ok) { |
| 34 bool handled = true; | 33 bool handled = true; |
| 35 IPC_BEGIN_MESSAGE_MAP_EX(SocketStreamDispatcherHost, message, *message_was_ok) | 34 IPC_BEGIN_MESSAGE_MAP_EX(SocketStreamDispatcherHost, message, *message_was_ok) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket); | 103 int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket); |
| 105 DVLOG(1) << "SocketStreamDispatcherHost::OnSSLCertificateError socket_id=" | 104 DVLOG(1) << "SocketStreamDispatcherHost::OnSSLCertificateError socket_id=" |
| 106 << socket_id; | 105 << socket_id; |
| 107 if (socket_id == content::kNoSocketId) { | 106 if (socket_id == content::kNoSocketId) { |
| 108 LOG(ERROR) << "NoSocketId in OnSSLCertificateError"; | 107 LOG(ERROR) << "NoSocketId in OnSSLCertificateError"; |
| 109 return; | 108 return; |
| 110 } | 109 } |
| 111 SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id); | 110 SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id); |
| 112 DCHECK(socket_stream_host); | 111 DCHECK(socket_stream_host); |
| 113 content::GlobalRequestID request_id(-1, socket_id); | 112 content::GlobalRequestID request_id(-1, socket_id); |
| 114 SSLManager::OnSSLCertificateError(ssl_delegate_weak_factory_.GetWeakPtr(), | 113 SSLManager::OnSSLCertificateError( |
| 115 request_id, ResourceType::SUB_RESOURCE, socket->url(), | 114 AsWeakPtr(), request_id, ResourceType::SUB_RESOURCE, socket->url(), |
| 116 render_process_id_, socket_stream_host->render_view_id(), ssl_info, | 115 render_process_id_, socket_stream_host->render_view_id(), ssl_info, |
| 117 fatal); | 116 fatal); |
| 118 } | 117 } |
| 119 | 118 |
| 120 bool SocketStreamDispatcherHost::CanGetCookies(net::SocketStream* socket, | 119 bool SocketStreamDispatcherHost::CanGetCookies(net::SocketStream* socket, |
| 121 const GURL& url) { | 120 const GURL& url) { |
| 122 return content::GetContentClient()->browser()->AllowGetCookie( | 121 return content::GetContentClient()->browser()->AllowGetCookie( |
| 123 url, url, net::CookieList(), resource_context_, 0, MSG_ROUTING_NONE); | 122 url, url, net::CookieList(), resource_context_, 0, MSG_ROUTING_NONE); |
| 124 } | 123 } |
| 125 | 124 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 hosts_.Remove(socket_id); | 218 hosts_.Remove(socket_id); |
| 220 if (!Send(new SocketStreamMsg_Closed(socket_id))) { | 219 if (!Send(new SocketStreamMsg_Closed(socket_id))) { |
| 221 LOG(ERROR) << "SocketStreamMsg_Closed failed."; | 220 LOG(ERROR) << "SocketStreamMsg_Closed failed."; |
| 222 } | 221 } |
| 223 } | 222 } |
| 224 | 223 |
| 225 net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() { | 224 net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() { |
| 226 return url_request_context_selector_->GetRequestContext( | 225 return url_request_context_selector_->GetRequestContext( |
| 227 ResourceType::SUB_RESOURCE); | 226 ResourceType::SUB_RESOURCE); |
| 228 } | 227 } |
| OLD | NEW |