| 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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "content/browser/renderer_host/websocket_host.h" | 12 #include "content/browser/renderer_host/websocket_host.h" |
| 13 #include "content/common/websocket_messages.h" | 13 #include "content/common/websocket_messages.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Many methods defined in this file return a WebSocketHostState enum | 19 // Many methods defined in this file return a WebSocketHostState enum |
| 20 // value. Make WebSocketHostState visible at file scope so it doesn't have to be | 20 // value. Make WebSocketHostState visible at file scope so it doesn't have to be |
| 21 // fully-qualified every time. | 21 // fully-qualified every time. |
| 22 typedef WebSocketDispatcherHost::WebSocketHostState WebSocketHostState; | 22 typedef WebSocketDispatcherHost::WebSocketHostState WebSocketHostState; |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 WebSocketDispatcherHost::WebSocketDispatcherHost( | 26 WebSocketDispatcherHost::WebSocketDispatcherHost( |
| 27 const GetRequestContextCallback& get_context_callback) | 27 const GetRequestContextCallback& get_context_callback) |
| 28 : get_context_callback_(get_context_callback), | 28 : BrowserMessageFilter(WebSocketMsgStart), |
| 29 get_context_callback_(get_context_callback), |
| 29 websocket_host_factory_( | 30 websocket_host_factory_( |
| 30 base::Bind(&WebSocketDispatcherHost::CreateWebSocketHost, | 31 base::Bind(&WebSocketDispatcherHost::CreateWebSocketHost, |
| 31 base::Unretained(this))) {} | 32 base::Unretained(this))) {} |
| 32 | 33 |
| 33 WebSocketDispatcherHost::WebSocketDispatcherHost( | 34 WebSocketDispatcherHost::WebSocketDispatcherHost( |
| 34 const GetRequestContextCallback& get_context_callback, | 35 const GetRequestContextCallback& get_context_callback, |
| 35 const WebSocketHostFactory& websocket_host_factory) | 36 const WebSocketHostFactory& websocket_host_factory) |
| 36 : get_context_callback_(get_context_callback), | 37 : BrowserMessageFilter(WebSocketMsgStart), |
| 38 get_context_callback_(get_context_callback), |
| 37 websocket_host_factory_(websocket_host_factory) {} | 39 websocket_host_factory_(websocket_host_factory) {} |
| 38 | 40 |
| 39 WebSocketHost* WebSocketDispatcherHost::CreateWebSocketHost(int routing_id) { | 41 WebSocketHost* WebSocketDispatcherHost::CreateWebSocketHost(int routing_id) { |
| 40 return new WebSocketHost(routing_id, this, get_context_callback_.Run()); | 42 return new WebSocketHost(routing_id, this, get_context_callback_.Run()); |
| 41 } | 43 } |
| 42 | 44 |
| 43 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message, | 45 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 44 bool* message_was_ok) { | 46 bool* message_was_ok) { |
| 45 switch (message.type()) { | 47 switch (message.type()) { |
| 46 case WebSocketHostMsg_AddChannelRequest::ID: | 48 case WebSocketHostMsg_AddChannelRequest::ID: |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 171 } |
| 170 | 172 |
| 171 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { | 173 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { |
| 172 WebSocketHostTable::iterator it = hosts_.find(routing_id); | 174 WebSocketHostTable::iterator it = hosts_.find(routing_id); |
| 173 DCHECK(it != hosts_.end()); | 175 DCHECK(it != hosts_.end()); |
| 174 delete it->second; | 176 delete it->second; |
| 175 hosts_.erase(it); | 177 hosts_.erase(it); |
| 176 } | 178 } |
| 177 | 179 |
| 178 } // namespace content | 180 } // namespace content |
| OLD | NEW |