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_CLIENT_HOST_CONNECTION_H_ | 5 #ifndef REMOTING_CLIENT_HOST_CONNECTION_H_ |
6 #define REMOTING_CLIENT_HOST_CONNECTION_H_ | 6 #define REMOTING_CLIENT_HOST_CONNECTION_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "remoting/base/protocol_decoder.h" | 10 #include "remoting/base/protocol_decoder.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 | 13 |
| 14 class ClientConfig; |
| 15 |
14 class HostConnection { | 16 class HostConnection { |
15 public: | 17 public: |
16 class HostEventCallback { | 18 class HostEventCallback { |
17 public: | 19 public: |
18 virtual ~HostEventCallback() {} | 20 virtual ~HostEventCallback() {} |
19 | 21 |
20 // Handles an event received by the HostConnection. Receiver will own the | 22 // Handles an event received by the HostConnection. Receiver will own the |
21 // HostMessages in HostMessageList and needs to delete them. | 23 // HostMessages in HostMessageList and needs to delete them. |
22 // Note that the sender of messages will not reference messages | 24 // Note that the sender of messages will not reference messages |
23 // again so it is okay to clear |messages| in this method. | 25 // again so it is okay to clear |messages| in this method. |
24 virtual void HandleMessages(HostConnection* conn, | 26 virtual void HandleMessages(HostConnection* conn, |
25 HostMessageList* messages) = 0; | 27 HostMessageList* messages) = 0; |
26 | 28 |
27 // Called when the network connection is opened. | 29 // Called when the network connection is opened. |
28 virtual void OnConnectionOpened(HostConnection* conn) = 0; | 30 virtual void OnConnectionOpened(HostConnection* conn) = 0; |
29 | 31 |
30 // Called when the network connection is closed. | 32 // Called when the network connection is closed. |
31 virtual void OnConnectionClosed(HostConnection* conn) = 0; | 33 virtual void OnConnectionClosed(HostConnection* conn) = 0; |
32 | 34 |
33 // Called when the network connection has failed. | 35 // Called when the network connection has failed. |
34 virtual void OnConnectionFailed(HostConnection* conn) = 0; | 36 virtual void OnConnectionFailed(HostConnection* conn) = 0; |
35 }; | 37 }; |
36 | 38 |
37 virtual ~HostConnection() {} | 39 virtual ~HostConnection() {} |
38 | 40 |
39 // TODO(ajwong): We need to generalize this API. | 41 // TODO(ajwong): We need to generalize this API. |
40 virtual void Connect(const std::string& username, | 42 virtual void Connect(ClientConfig* config, |
41 const std::string& auth_token, | |
42 const std::string& host_jid, | |
43 HostEventCallback* event_callback) = 0; | 43 HostEventCallback* event_callback) = 0; |
44 virtual void Disconnect() = 0; | 44 virtual void Disconnect() = 0; |
45 | 45 |
46 protected: | 46 protected: |
47 HostConnection() {} | 47 HostConnection() {} |
48 | 48 |
49 private: | 49 private: |
50 DISALLOW_COPY_AND_ASSIGN(HostConnection); | 50 DISALLOW_COPY_AND_ASSIGN(HostConnection); |
51 }; | 51 }; |
52 | 52 |
53 } // namespace remoting | 53 } // namespace remoting |
54 | 54 |
55 #endif // REMOTING_CLIENT_HOST_CONNECTION_H_ | 55 #endif // REMOTING_CLIENT_HOST_CONNECTION_H_ |
OLD | NEW |