| 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 : BrowserMessageFilter(WebSocketMsgStart), | 28 : get_context_callback_(get_context_callback), |
| 29 get_context_callback_(get_context_callback), | |
| 30 websocket_host_factory_( | 29 websocket_host_factory_( |
| 31 base::Bind(&WebSocketDispatcherHost::CreateWebSocketHost, | 30 base::Bind(&WebSocketDispatcherHost::CreateWebSocketHost, |
| 32 base::Unretained(this))) {} | 31 base::Unretained(this))) {} |
| 33 | 32 |
| 34 WebSocketDispatcherHost::WebSocketDispatcherHost( | 33 WebSocketDispatcherHost::WebSocketDispatcherHost( |
| 35 const GetRequestContextCallback& get_context_callback, | 34 const GetRequestContextCallback& get_context_callback, |
| 36 const WebSocketHostFactory& websocket_host_factory) | 35 const WebSocketHostFactory& websocket_host_factory) |
| 37 : BrowserMessageFilter(WebSocketMsgStart), | 36 : get_context_callback_(get_context_callback), |
| 38 get_context_callback_(get_context_callback), | |
| 39 websocket_host_factory_(websocket_host_factory) {} | 37 websocket_host_factory_(websocket_host_factory) {} |
| 40 | 38 |
| 41 WebSocketHost* WebSocketDispatcherHost::CreateWebSocketHost(int routing_id) { | 39 WebSocketHost* WebSocketDispatcherHost::CreateWebSocketHost(int routing_id) { |
| 42 return new WebSocketHost(routing_id, this, get_context_callback_.Run()); | 40 return new WebSocketHost(routing_id, this, get_context_callback_.Run()); |
| 43 } | 41 } |
| 44 | 42 |
| 45 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message, | 43 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 46 bool* message_was_ok) { | 44 bool* message_was_ok) { |
| 47 switch (message.type()) { | 45 switch (message.type()) { |
| 48 case WebSocketHostMsg_AddChannelRequest::ID: | 46 case WebSocketHostMsg_AddChannelRequest::ID: |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 169 } |
| 172 | 170 |
| 173 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { | 171 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { |
| 174 WebSocketHostTable::iterator it = hosts_.find(routing_id); | 172 WebSocketHostTable::iterator it = hosts_.find(routing_id); |
| 175 DCHECK(it != hosts_.end()); | 173 DCHECK(it != hosts_.end()); |
| 176 delete it->second; | 174 delete it->second; |
| 177 hosts_.erase(it); | 175 hosts_.erase(it); |
| 178 } | 176 } |
| 179 | 177 |
| 180 } // namespace content | 178 } // namespace content |
| OLD | NEW |