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