OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_CLIENT_HOST_CONNECTION_H_ |
| 6 #define REMOTING_CLIENT_HOST_CONNECTION_H_ |
| 7 |
| 8 #include <deque> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/message_loop.h" |
| 12 #include "base/ref_counted.h" |
| 13 #include "base/scoped_ptr.h" |
| 14 #include "remoting/base/protocol_decoder.h" |
| 15 #include "remoting/base/protocol/chromotocol.pb.h" |
| 16 #include "remoting/jingle_glue/jingle_channel.h" |
| 17 #include "remoting/jingle_glue/jingle_client.h" |
| 18 |
| 19 namespace remoting { |
| 20 |
| 21 class HostConnection : public JingleChannel::Callback, |
| 22 public JingleClient::Callback { |
| 23 public: |
| 24 class EventHandler { |
| 25 public: |
| 26 virtual ~EventHandler() {} |
| 27 |
| 28 // Handles an event received by the HostConnection. Receiver will own the |
| 29 // HostMessages in HostMessageList and needs to delete them. |
| 30 // Note that the sender of messages will not reference messages |
| 31 // again so it is okay to clear |messages| in this method. |
| 32 virtual void HandleMessages(HostConnection* conn, |
| 33 HostMessageList* messages) = 0; |
| 34 |
| 35 // Called when the network connection is opened. |
| 36 virtual void OnConnectionOpened(HostConnection* conn) = 0; |
| 37 |
| 38 // Called when the network connection is closed. |
| 39 virtual void OnConnectionClosed(HostConnection* conn) = 0; |
| 40 |
| 41 // Called when the network connection has failed. |
| 42 virtual void OnConnectionFailed(HostConnection* conn) = 0; |
| 43 }; |
| 44 |
| 45 // Constructs a HostConnection object. |
| 46 HostConnection(ProtocolDecoder* decoder, EventHandler* handler); |
| 47 |
| 48 virtual ~HostConnection(); |
| 49 |
| 50 void Connect(const std::string& username, const std::string& password, |
| 51 const std::string& host_jid); |
| 52 void Disconnect(); |
| 53 |
| 54 // JingleChannel::Callback interface. |
| 55 void OnStateChange(JingleChannel* channel, JingleChannel::State state); |
| 56 void OnPacketReceived(JingleChannel* channel, |
| 57 scoped_refptr<media::DataBuffer> buffer); |
| 58 |
| 59 // JingleClient::Callback interface. |
| 60 void OnStateChange(JingleClient* client, JingleClient::State state); |
| 61 bool OnAcceptConnection(JingleClient* client, const std::string& jid, |
| 62 JingleChannel::Callback** callback); |
| 63 void OnNewConnection(JingleClient* client, |
| 64 scoped_refptr<JingleChannel> channel); |
| 65 |
| 66 private: |
| 67 scoped_refptr<JingleClient> jingle_client_; |
| 68 scoped_refptr<JingleChannel> jingle_channel_; |
| 69 scoped_ptr<ProtocolDecoder> decoder_; |
| 70 EventHandler* handler_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(HostConnection); |
| 73 }; |
| 74 |
| 75 } // namespace remoting |
| 76 |
| 77 #endif // REMOTING_CLIENT_HOST_CONNECTION_H_ |
OLD | NEW |