| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef REMOTING_PROTOCOL_CLIENT_MESSAGE_DISPATCHER_H_ | |
| 6 #define REMOTING_PROTOCOL_CLIENT_MESSAGE_DISPATCHER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "remoting/protocol/message_reader.h" | |
| 11 | |
| 12 namespace remoting { | |
| 13 | |
| 14 namespace protocol { | |
| 15 | |
| 16 class ClientStub; | |
| 17 class ControlMessage; | |
| 18 class Session; | |
| 19 | |
| 20 // A message dispatcher used to listen for messages received in | |
| 21 // protocol::Session. It dispatches messages to the corresponding | |
| 22 // handler. | |
| 23 // | |
| 24 // Internally it contains an EventStreamReader that decodes data on | |
| 25 // communications channels into protocol buffer messages. | |
| 26 // EventStreamReader is registered with protocol::Session given to it. | |
| 27 // | |
| 28 // Object of this class is owned by ConnectionToHost. | |
| 29 class ClientMessageDispatcher { | |
| 30 public: | |
| 31 // Construct a message dispatcher. | |
| 32 ClientMessageDispatcher(); | |
| 33 virtual ~ClientMessageDispatcher(); | |
| 34 | |
| 35 // Initialize the message dispatcher with the given connection and | |
| 36 // message handlers. | |
| 37 void Initialize(protocol::Session* session, ClientStub* client_stub); | |
| 38 | |
| 39 private: | |
| 40 void OnControlMessageReceived(ControlMessage* message, | |
| 41 const base::Closure& done_task); | |
| 42 | |
| 43 // MessageReader that runs on the control channel. It runs a loop | |
| 44 // that parses data on the channel and then calls the corresponding handler | |
| 45 // in this class. | |
| 46 scoped_ptr<ProtobufMessageReader<ControlMessage> > control_message_reader_; | |
| 47 | |
| 48 // Stubs for client and input. These objects are not owned. | |
| 49 // They are called on the thread there data is received, i.e. jingle thread. | |
| 50 ClientStub* client_stub_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(ClientMessageDispatcher); | |
| 53 }; | |
| 54 | |
| 55 } // namespace protocol | |
| 56 } // namespace remoting | |
| 57 | |
| 58 #endif // REMOTING_PROTOCOL_CLIENT_MESSAGE_DISPATCHER_H_ | |
| OLD | NEW |