Revert 187554 "Implement IPC::ChannelFactory, a class that accep..."
[chromium-blink-merge.git] / remoting / protocol / host_control_dispatcher.h
blob080d6dd71924ee7a9127ae5cedd760e65b4e181e
1 // Copyright (c) 2012 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 REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_
6 #define REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_
8 #include "base/memory/ref_counted.h"
9 #include "remoting/protocol/buffered_socket_writer.h"
10 #include "remoting/protocol/channel_dispatcher_base.h"
11 #include "remoting/protocol/client_stub.h"
12 #include "remoting/protocol/clipboard_stub.h"
13 #include "remoting/protocol/cursor_shape_stub.h"
14 #include "remoting/protocol/message_reader.h"
16 namespace net {
17 class StreamSocket;
18 } // namespace net
20 namespace remoting {
21 namespace protocol {
23 class ControlMessage;
24 class HostStub;
25 class Session;
27 // HostControlDispatcher dispatches incoming messages on the control
28 // channel to HostStub or ClipboardStub, and also implements ClientStub and
29 // CursorShapeStub for outgoing messages.
30 class HostControlDispatcher : public ChannelDispatcherBase,
31 public ClientStub {
32 public:
33 HostControlDispatcher();
34 virtual ~HostControlDispatcher();
36 // ClipboardStub implementation for sending clipboard data to client.
37 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE;
39 // CursorShapeStub implementation for sending cursor shape to client.
40 virtual void SetCursorShape(const CursorShapeInfo& cursor_shape) OVERRIDE;
42 // Sets the ClipboardStub that will be called for each incoming clipboard
43 // message. |clipboard_stub| must outlive this object.
44 void set_clipboard_stub(ClipboardStub* clipboard_stub) {
45 clipboard_stub_ = clipboard_stub;
48 // Sets the HostStub that will be called for each incoming control
49 // message. |host_stub| must outlive this object.
50 void set_host_stub(HostStub* host_stub) { host_stub_ = host_stub; }
52 protected:
53 // ChannelDispatcherBase overrides.
54 virtual void OnInitialized() OVERRIDE;
56 private:
57 void OnMessageReceived(scoped_ptr<ControlMessage> message,
58 const base::Closure& done_task);
60 ClipboardStub* clipboard_stub_;
61 HostStub* host_stub_;
63 ProtobufMessageReader<ControlMessage> reader_;
64 BufferedSocketWriter writer_;
66 DISALLOW_COPY_AND_ASSIGN(HostControlDispatcher);
69 } // namespace protocol
70 } // namespace remoting
72 #endif // REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_