OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_ |
| 6 #define CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
| 14 #include "ipc/ipc_listener.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class WebSocketBridge; |
| 19 |
| 20 // Dispatches WebSocket related messages sent to a child process from the |
| 21 // main browser process. There is one instance per child process. Messages |
| 22 // are dispatched on the main child thread. The ChildThread class |
| 23 // creates an instance of WebSocketDispatcher and delegates calls to it. |
| 24 class WebSocketDispatcher : public IPC::Listener { |
| 25 public: |
| 26 WebSocketDispatcher(); |
| 27 virtual ~WebSocketDispatcher(); |
| 28 |
| 29 // Returns a unique channel id |
| 30 int AddBridge(WebSocketBridge* bridge); |
| 31 void RemoveBridge(int channel_id); |
| 32 |
| 33 // IPC::Listener implementation. |
| 34 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 35 |
| 36 private: |
| 37 WebSocketBridge* GetBridge(int channel_id, uint32 type); |
| 38 |
| 39 std::map<int, WebSocketBridge*> bridges_; |
| 40 int channel_id_max_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(WebSocketDispatcher); |
| 43 }; |
| 44 |
| 45 } // namespace content |
| 46 |
| 47 #endif // CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_ |
OLD | NEW |