1 // Copyright (c) 2011 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.
5 #ifndef CONTENT_COMMON_SOCKET_STREAM_DISPATCHER_H_
6 #define CONTENT_COMMON_SOCKET_STREAM_DISPATCHER_H_
11 #include "base/basictypes.h"
12 #include "ipc/ipc_channel.h"
15 class WebSocketStreamHandle
;
18 namespace webkit_glue
{
19 class WebSocketStreamHandleBridge
;
20 class WebSocketStreamHandleDelegate
;
23 // Dispatches socket stream related messages sent to a child process from the
24 // main browser process. There is one instance per child process. Messages
25 // are dispatched on the main child thread. The RenderThread class
26 // creates an instance of SocketStreamDispatcher and delegates calls to it.
27 class SocketStreamDispatcher
: public IPC::Channel::Listener
{
29 SocketStreamDispatcher();
30 virtual ~SocketStreamDispatcher() {}
32 static webkit_glue::WebSocketStreamHandleBridge
* CreateBridge(
33 WebKit::WebSocketStreamHandle
* handle
,
34 webkit_glue::WebSocketStreamHandleDelegate
* delegate
);
36 // IPC::Channel::Listener implementation.
37 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
40 void OnConnected(int socket_id
, int max_amount_send_allowed
);
41 void OnSentData(int socket_id
, int amount_sent
);
42 void OnReceivedData(int socket_id
, const std::vector
<char>& data
);
43 void OnClosed(int socket_id
);
45 DISALLOW_COPY_AND_ASSIGN(SocketStreamDispatcher
);
48 #endif // CONTENT_COMMON_SOCKET_STREAM_DISPATCHER_H_