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 // JingleHostConnection implements the HostConnection interface using | 5 // JingleHostConnection implements the HostConnection interface using |
6 // libjingle as the transport protocol. | 6 // libjingle as the transport protocol. |
7 // | 7 // |
8 // Much of this class focuses on translating JingleClient and JingleChannel | 8 // Much of this class focuses on translating JingleClient and JingleChannel |
9 // callbacks into HostConnection::HostEventCallback messages. | 9 // callbacks into HostConnection::HostEventCallback messages. |
10 // | 10 // |
11 // The public API of this class is designed to be asynchronous, and thread | 11 // The public API of this class is designed to be asynchronous, and thread |
12 // safe for invocation from other threads. | 12 // safe for invocation from other threads. |
13 // | 13 // |
14 // Internally though, all work delegeated to the |network_thread| given | 14 // Internally though, all work delegeated to the |network_thread| given |
15 // during construction. Any event handlers running on the |network_thread| | 15 // during construction. Any event handlers running on the |network_thread| |
16 // should not block. | 16 // should not block. |
17 | 17 |
18 #ifndef REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ | 18 #ifndef REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ |
19 #define REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ | 19 #define REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ |
20 | 20 |
21 #include "base/ref_counted.h" | 21 #include "base/ref_counted.h" |
22 #include "base/scoped_ptr.h" | 22 #include "base/scoped_ptr.h" |
23 #include "base/task.h" | 23 #include "base/task.h" |
24 #include "remoting/base/protocol_decoder.h" | 24 #include "remoting/base/protocol_decoder.h" |
| 25 #include "remoting/client/client_context.h" |
25 #include "remoting/client/host_connection.h" | 26 #include "remoting/client/host_connection.h" |
26 #include "remoting/jingle_glue/jingle_channel.h" | 27 #include "remoting/jingle_glue/jingle_channel.h" |
27 #include "remoting/jingle_glue/jingle_client.h" | 28 #include "remoting/jingle_glue/jingle_client.h" |
28 | 29 |
29 class MessageLoop; | 30 class MessageLoop; |
30 | 31 |
31 namespace remoting { | 32 namespace remoting { |
32 | 33 |
| 34 class ClientConfig; |
33 class JingleThread; | 35 class JingleThread; |
34 | 36 |
35 class JingleHostConnection : public HostConnection, | 37 class JingleHostConnection : public HostConnection, |
36 public JingleChannel::Callback, | 38 public JingleChannel::Callback, |
37 public JingleClient::Callback { | 39 public JingleClient::Callback { |
38 public: | 40 public: |
39 explicit JingleHostConnection(JingleThread* network_thread); | 41 explicit JingleHostConnection(ClientContext* context); |
40 virtual ~JingleHostConnection(); | 42 virtual ~JingleHostConnection(); |
41 | 43 |
42 virtual void Connect(const std::string& username, | 44 virtual void Connect(ClientConfig* config, |
43 const std::string& auth_token, | |
44 const std::string& host_jid, | |
45 HostEventCallback* event_callback); | 45 HostEventCallback* event_callback); |
46 virtual void Disconnect(); | 46 virtual void Disconnect(); |
47 | 47 |
48 // JingleChannel::Callback interface. | 48 // JingleChannel::Callback interface. |
49 virtual void OnStateChange(JingleChannel* channel, | 49 virtual void OnStateChange(JingleChannel* channel, |
50 JingleChannel::State state); | 50 JingleChannel::State state); |
51 virtual void OnPacketReceived(JingleChannel* channel, | 51 virtual void OnPacketReceived(JingleChannel* channel, |
52 scoped_refptr<media::DataBuffer> buffer); | 52 scoped_refptr<media::DataBuffer> buffer); |
53 | 53 |
54 // JingleClient::Callback interface. | 54 // JingleClient::Callback interface. |
55 virtual void OnStateChange(JingleClient* client, JingleClient::State state); | 55 virtual void OnStateChange(JingleClient* client, JingleClient::State state); |
56 virtual bool OnAcceptConnection(JingleClient* client, const std::string& jid, | 56 virtual bool OnAcceptConnection(JingleClient* client, const std::string& jid, |
57 JingleChannel::Callback** callback); | 57 JingleChannel::Callback** callback); |
58 virtual void OnNewConnection(JingleClient* client, | 58 virtual void OnNewConnection(JingleClient* client, |
59 scoped_refptr<JingleChannel> channel); | 59 scoped_refptr<JingleChannel> channel); |
60 | 60 |
61 private: | 61 private: |
62 MessageLoop* message_loop(); | 62 MessageLoop* message_loop(); |
63 | 63 |
64 void DoConnect(const std::string& username, | 64 void DoConnect(ClientConfig* config, |
65 const std::string& auth_token, | |
66 const std::string& host_jid, | |
67 HostEventCallback* event_callback); | 65 HostEventCallback* event_callback); |
68 void DoDisconnect(); | 66 void DoDisconnect(); |
69 | 67 |
70 JingleThread* network_thread_; | 68 ClientContext* context_; |
71 | 69 |
72 scoped_refptr<JingleClient> jingle_client_; | 70 scoped_refptr<JingleClient> jingle_client_; |
73 scoped_refptr<JingleChannel> jingle_channel_; | 71 scoped_refptr<JingleChannel> jingle_channel_; |
74 | 72 |
75 ProtocolDecoder decoder_; | 73 ProtocolDecoder decoder_; |
76 HostEventCallback* event_callback_; | 74 HostEventCallback* event_callback_; |
77 | 75 |
78 DISALLOW_COPY_AND_ASSIGN(JingleHostConnection); | 76 DISALLOW_COPY_AND_ASSIGN(JingleHostConnection); |
79 }; | 77 }; |
80 | 78 |
81 } // namespace remoting | 79 } // namespace remoting |
82 | 80 |
83 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::JingleHostConnection); | 81 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::JingleHostConnection); |
84 | 82 |
85 #endif // REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ | 83 #endif // REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ |
OLD | NEW |