| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/websocket_dispatcher_host.h" | 5 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 const WebSocketHostFactory& websocket_host_factory) | 40 const WebSocketHostFactory& websocket_host_factory) |
| 41 : BrowserMessageFilter(WebSocketMsgStart), | 41 : BrowserMessageFilter(WebSocketMsgStart), |
| 42 process_id_(process_id), | 42 process_id_(process_id), |
| 43 get_context_callback_(get_context_callback), | 43 get_context_callback_(get_context_callback), |
| 44 websocket_host_factory_(websocket_host_factory) {} | 44 websocket_host_factory_(websocket_host_factory) {} |
| 45 | 45 |
| 46 WebSocketHost* WebSocketDispatcherHost::CreateWebSocketHost(int routing_id) { | 46 WebSocketHost* WebSocketDispatcherHost::CreateWebSocketHost(int routing_id) { |
| 47 return new WebSocketHost(routing_id, this, get_context_callback_.Run()); | 47 return new WebSocketHost(routing_id, this, get_context_callback_.Run()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message, | 50 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
| 51 bool* message_was_ok) { | |
| 52 switch (message.type()) { | 51 switch (message.type()) { |
| 53 case WebSocketHostMsg_AddChannelRequest::ID: | 52 case WebSocketHostMsg_AddChannelRequest::ID: |
| 54 case WebSocketMsg_SendFrame::ID: | 53 case WebSocketMsg_SendFrame::ID: |
| 55 case WebSocketMsg_FlowControl::ID: | 54 case WebSocketMsg_FlowControl::ID: |
| 56 case WebSocketMsg_DropChannel::ID: | 55 case WebSocketMsg_DropChannel::ID: |
| 57 break; | 56 break; |
| 58 | 57 |
| 59 default: | 58 default: |
| 60 // Every message that has not been handled by a previous filter passes | 59 // Every message that has not been handled by a previous filter passes |
| 61 // through here, so it is good to pass them on as efficiently as possible. | 60 // through here, so it is good to pass them on as efficiently as possible. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 return true; // We handled the message (by ignoring it). | 73 return true; // We handled the message (by ignoring it). |
| 75 } | 74 } |
| 76 host = websocket_host_factory_.Run(routing_id); | 75 host = websocket_host_factory_.Run(routing_id); |
| 77 hosts_.insert(WebSocketHostTable::value_type(routing_id, host)); | 76 hosts_.insert(WebSocketHostTable::value_type(routing_id, host)); |
| 78 } | 77 } |
| 79 if (!host) { | 78 if (!host) { |
| 80 DVLOG(1) << "Received invalid routing ID " << routing_id | 79 DVLOG(1) << "Received invalid routing ID " << routing_id |
| 81 << " from renderer."; | 80 << " from renderer."; |
| 82 return true; // We handled the message (by ignoring it). | 81 return true; // We handled the message (by ignoring it). |
| 83 } | 82 } |
| 84 return host->OnMessageReceived(message, message_was_ok); | 83 return host->OnMessageReceived(message); |
| 85 } | 84 } |
| 86 | 85 |
| 87 bool WebSocketDispatcherHost::CanReadRawCookies() const { | 86 bool WebSocketDispatcherHost::CanReadRawCookies() const { |
| 88 ChildProcessSecurityPolicyImpl* policy = | 87 ChildProcessSecurityPolicyImpl* policy = |
| 89 ChildProcessSecurityPolicyImpl::GetInstance(); | 88 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 90 return policy->CanReadRawCookies(process_id_); | 89 return policy->CanReadRawCookies(process_id_); |
| 91 } | 90 } |
| 92 | 91 |
| 93 WebSocketHost* WebSocketDispatcherHost::GetHost(int routing_id) const { | 92 WebSocketHost* WebSocketDispatcherHost::GetHost(int routing_id) const { |
| 94 WebSocketHostTable::const_iterator it = hosts_.find(routing_id); | 93 WebSocketHostTable::const_iterator it = hosts_.find(routing_id); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 182 } |
| 184 | 183 |
| 185 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { | 184 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { |
| 186 WebSocketHostTable::iterator it = hosts_.find(routing_id); | 185 WebSocketHostTable::iterator it = hosts_.find(routing_id); |
| 187 DCHECK(it != hosts_.end()); | 186 DCHECK(it != hosts_.end()); |
| 188 delete it->second; | 187 delete it->second; |
| 189 hosts_.erase(it); | 188 hosts_.erase(it); |
| 190 } | 189 } |
| 191 | 190 |
| 192 } // namespace content | 191 } // namespace content |
| OLD | NEW |