| 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 namespace protocol { | 16 namespace protocol { |
| 17 | 17 |
| 18 class SessionConfig; |
| 18 class VideoStub; | 19 class VideoStub; |
| 19 | 20 |
| 20 class ConnectionToHost { | 21 class ConnectionToHost { |
| 21 public: | 22 public: |
| 22 class HostEventCallback { | 23 class HostEventCallback { |
| 23 public: | 24 public: |
| 24 virtual ~HostEventCallback() {} | 25 virtual ~HostEventCallback() {} |
| 25 | 26 |
| 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. | 27 // Called when the network connection is opened. |
| 32 virtual void OnConnectionOpened(ConnectionToHost* conn) = 0; | 28 virtual void OnConnectionOpened(ConnectionToHost* conn) = 0; |
| 33 | 29 |
| 34 // Called when the network connection is closed. | 30 // Called when the network connection is closed. |
| 35 virtual void OnConnectionClosed(ConnectionToHost* conn) = 0; | 31 virtual void OnConnectionClosed(ConnectionToHost* conn) = 0; |
| 36 | 32 |
| 37 // Called when the network connection has failed. | 33 // Called when the network connection has failed. |
| 38 virtual void OnConnectionFailed(ConnectionToHost* conn) = 0; | 34 virtual void OnConnectionFailed(ConnectionToHost* conn) = 0; |
| 39 }; | 35 }; |
| 40 | 36 |
| 41 virtual ~ConnectionToHost() {} | 37 virtual ~ConnectionToHost() {} |
| 42 | 38 |
| 43 // TODO(ajwong): We need to generalize this API. | 39 // TODO(ajwong): We need to generalize this API. |
| 44 virtual void Connect(const std::string& username, | 40 virtual void Connect(const std::string& username, |
| 45 const std::string& auth_token, | 41 const std::string& auth_token, |
| 46 const std::string& host_jid, | 42 const std::string& host_jid, |
| 47 HostEventCallback* event_callback, | 43 HostEventCallback* event_callback, |
| 48 VideoStub* video_stub) = 0; | 44 VideoStub* video_stub) = 0; |
| 49 virtual void Disconnect() = 0; | 45 virtual void Disconnect() = 0; |
| 50 | 46 |
| 47 virtual const SessionConfig* config() = 0; |
| 48 |
| 51 // Send an input event to the host. | 49 // Send an input event to the host. |
| 52 virtual void SendEvent(const ChromotingClientMessage& msg) = 0; | 50 virtual void SendEvent(const ChromotingClientMessage& msg) = 0; |
| 53 | 51 |
| 54 protected: | 52 protected: |
| 55 ConnectionToHost() {} | 53 ConnectionToHost() {} |
| 56 | 54 |
| 57 private: | 55 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost); | 56 DISALLOW_COPY_AND_ASSIGN(ConnectionToHost); |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 } // namespace protocol | 59 } // namespace protocol |
| 62 } // namespace remoting | 60 } // namespace remoting |
| 63 | 61 |
| 64 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ | 62 #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ |
| OLD | NEW |