OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ | 5 #ifndef REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ |
6 #define REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ | 6 #define REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "remoting/proto/internal.pb.h" | 12 #include "remoting/proto/internal.pb.h" |
13 #include "remoting/protocol/message_decoder.h" | 13 #include "remoting/protocol/message_decoder.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
| 16 |
| 17 class ChromotocolConfig; |
| 18 |
16 namespace protocol { | 19 namespace protocol { |
17 | 20 |
18 class VideoStub; | 21 class VideoStub; |
19 | 22 |
20 class ConnectionToHost { | 23 class ConnectionToHost { |
21 public: | 24 public: |
22 class HostEventCallback { | 25 class HostEventCallback { |
23 public: | 26 public: |
24 virtual ~HostEventCallback() {} | 27 virtual ~HostEventCallback() {} |
25 | 28 |
26 // Handles an event received by the protocol::ConnectionToHost. Ownership | |
27 // of the message is passed to the callee. | |
28 virtual void HandleMessage(ConnectionToHost* conn, | |
29 ChromotingHostMessage* message) = 0; | |
30 | |
31 // Called when the network connection is opened. | 29 // Called when the network connection is opened. |
32 virtual void OnConnectionOpened(ConnectionToHost* conn) = 0; | 30 virtual void OnConnectionOpened(ConnectionToHost* conn) = 0; |
33 | 31 |
34 // Called when the network connection is closed. | 32 // Called when the network connection is closed. |
35 virtual void OnConnectionClosed(ConnectionToHost* conn) = 0; | 33 virtual void OnConnectionClosed(ConnectionToHost* conn) = 0; |
36 | 34 |
37 // Called when the network connection has failed. | 35 // Called when the network connection has failed. |
38 virtual void OnConnectionFailed(ConnectionToHost* conn) = 0; | 36 virtual void OnConnectionFailed(ConnectionToHost* conn) = 0; |
39 }; | 37 }; |
40 | 38 |
41 virtual ~ConnectionToHost() {} | 39 virtual ~ConnectionToHost() {} |
42 | 40 |
43 // TODO(ajwong): We need to generalize this API. | 41 // TODO(ajwong): We need to generalize this API. |
44 virtual void Connect(const std::string& username, | 42 virtual void Connect(const std::string& username, |
45 const std::string& auth_token, | 43 const std::string& auth_token, |
46 const std::string& host_jid, | 44 const std::string& host_jid, |
47 HostEventCallback* event_callback, | 45 HostEventCallback* event_callback, |
48 VideoStub* video_stub) = 0; | 46 VideoStub* video_stub) = 0; |
49 virtual void Disconnect() = 0; | 47 virtual void Disconnect() = 0; |
50 | 48 |
| 49 virtual const ChromotocolConfig* config() = 0; |
| 50 |
51 // Send an input event to the host. | 51 // Send an input event to the host. |
52 virtual void SendEvent(const ChromotingClientMessage& msg) = 0; | 52 virtual void SendEvent(const ChromotingClientMessage& msg) = 0; |
53 | 53 |
54 protected: | 54 protected: |
55 ConnectionToHost() {} | 55 ConnectionToHost() {} |
56 | 56 |
57 private: | 57 private: |
58 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost); | 58 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost); |
59 }; | 59 }; |
60 | 60 |
61 } // namespace protocol | 61 } // namespace protocol |
62 } // namespace remoting | 62 } // namespace remoting |
63 | 63 |
64 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ | 64 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ |
OLD | NEW |