OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ | 5 #ifndef CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ |
6 #define CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ | 6 #define CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 | 12 #include "ipc/ipc_channel.h" |
13 namespace IPC { | |
14 class Message; | |
15 } | |
16 | 13 |
17 namespace WebKit { | 14 namespace WebKit { |
18 class WebSocketStreamHandle; | 15 class WebSocketStreamHandle; |
19 } | 16 } |
20 | 17 |
21 namespace webkit_glue { | 18 namespace webkit_glue { |
22 class WebSocketStreamHandleBridge; | 19 class WebSocketStreamHandleBridge; |
23 class WebSocketStreamHandleDelegate; | 20 class WebSocketStreamHandleDelegate; |
24 } | 21 } |
25 | 22 |
26 // Dispatches socket stream related messages sent to a child process from the | 23 // Dispatches socket stream related messages sent to a child process from the |
27 // main browser process. There is one instance per child process. Messages | 24 // main browser process. There is one instance per child process. Messages |
28 // are dispatched on the main child thread. The RenderThread class | 25 // are dispatched on the main child thread. The RenderThread class |
29 // creates an instance of SocketStreamDispatcher and delegates calls to it. | 26 // creates an instance of SocketStreamDispatcher and delegates calls to it. |
30 class SocketStreamDispatcher { | 27 class SocketStreamDispatcher : public IPC::Channel::Listener { |
31 public: | 28 public: |
32 SocketStreamDispatcher(); | 29 SocketStreamDispatcher(); |
33 ~SocketStreamDispatcher() {} | 30 ~SocketStreamDispatcher() {} |
34 | 31 |
35 static webkit_glue::WebSocketStreamHandleBridge* CreateBridge( | 32 static webkit_glue::WebSocketStreamHandleBridge* CreateBridge( |
36 WebKit::WebSocketStreamHandle* handle, | 33 WebKit::WebSocketStreamHandle* handle, |
37 webkit_glue::WebSocketStreamHandleDelegate* delegate); | 34 webkit_glue::WebSocketStreamHandleDelegate* delegate); |
| 35 |
| 36 // IPC::Channel::Listener implementation. |
38 bool OnMessageReceived(const IPC::Message& msg); | 37 bool OnMessageReceived(const IPC::Message& msg); |
39 | 38 |
40 private: | 39 private: |
41 void OnConnected(int socket_id, int max_amount_send_allowed); | 40 void OnConnected(int socket_id, int max_amount_send_allowed); |
42 void OnSentData(int socket_id, int amount_sent); | 41 void OnSentData(int socket_id, int amount_sent); |
43 void OnReceivedData(int socket_id, const std::vector<char>& data); | 42 void OnReceivedData(int socket_id, const std::vector<char>& data); |
44 void OnClosed(int socket_id); | 43 void OnClosed(int socket_id); |
45 | 44 |
46 DISALLOW_COPY_AND_ASSIGN(SocketStreamDispatcher); | 45 DISALLOW_COPY_AND_ASSIGN(SocketStreamDispatcher); |
47 }; | 46 }; |
48 | 47 |
49 #endif // CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ | 48 #endif // CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ |
OLD | NEW |