Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / remoting / protocol / host_control_dispatcher.h
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.
4
5 #ifndef REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_
6 #define REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_
7
8 #include "remoting/protocol/buffered_socket_writer.h"
9 #include "remoting/protocol/channel_dispatcher_base.h"
10 #include "remoting/protocol/client_stub.h"
11 #include "remoting/protocol/clipboard_stub.h"
12 #include "remoting/protocol/cursor_shape_stub.h"
13 #include "remoting/protocol/message_reader.h"
14
15 namespace net {
16 class StreamSocket;
17 }  // namespace net
18
19 namespace remoting {
20 namespace protocol {
21
22 class ControlMessage;
23 class HostStub;
24 class PairingResponse;
25 class Session;
26
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   ~HostControlDispatcher() override;
35
36   // ClientStub implementation.
37   void SetCapabilities(const Capabilities& capabilities) override;
38   void SetPairingResponse(const PairingResponse& pairing_response) override;
39   void DeliverHostMessage(const ExtensionMessage& message) override;
40
41   // ClipboardStub implementation for sending clipboard data to client.
42   void InjectClipboardEvent(const ClipboardEvent& event) override;
43
44   // CursorShapeStub implementation for sending cursor shape to client.
45   void SetCursorShape(const CursorShapeInfo& cursor_shape) override;
46
47   // Sets the ClipboardStub that will be called for each incoming clipboard
48   // message. |clipboard_stub| must outlive this object.
49   void set_clipboard_stub(ClipboardStub* clipboard_stub) {
50     clipboard_stub_ = clipboard_stub;
51   }
52
53   // Sets the HostStub that will be called for each incoming control
54   // message. |host_stub| must outlive this object.
55   void set_host_stub(HostStub* host_stub) { host_stub_ = host_stub; }
56
57  protected:
58   // ChannelDispatcherBase overrides.
59   void OnInitialized() override;
60
61  private:
62   void OnMessageReceived(scoped_ptr<ControlMessage> message,
63                          const base::Closure& done_task);
64
65   ClipboardStub* clipboard_stub_;
66   HostStub* host_stub_;
67
68   ProtobufMessageReader<ControlMessage> reader_;
69   BufferedSocketWriter writer_;
70
71   DISALLOW_COPY_AND_ASSIGN(HostControlDispatcher);
72 };
73
74 }  // namespace protocol
75 }  // namespace remoting
76
77 #endif  // REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_