OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // ChromotingClient is the controller for the Client implementation. | 5 // ChromotingClient is the controller for the Client implementation. |
6 | 6 |
7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | |
15 #include "remoting/client/client_config.h" | |
16 #include "remoting/client/chromoting_stats.h" | 14 #include "remoting/client/chromoting_stats.h" |
17 #include "remoting/protocol/client_stub.h" | 15 #include "remoting/protocol/client_stub.h" |
18 #include "remoting/protocol/clipboard_stub.h" | 16 #include "remoting/protocol/clipboard_stub.h" |
19 #include "remoting/protocol/connection_to_host.h" | 17 #include "remoting/protocol/connection_to_host.h" |
20 #include "remoting/protocol/input_stub.h" | 18 #include "remoting/protocol/input_stub.h" |
21 #include "remoting/protocol/video_stub.h" | 19 #include "remoting/protocol/video_stub.h" |
22 | 20 |
23 namespace base { | 21 namespace base { |
24 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
25 } // namespace base | 23 } // namespace base |
(...skipping 10 matching lines...) Expand all Loading... |
36 class ClientUserInterface; | 34 class ClientUserInterface; |
37 class FrameConsumerProxy; | 35 class FrameConsumerProxy; |
38 class FrameProducer; | 36 class FrameProducer; |
39 class VideoRenderer; | 37 class VideoRenderer; |
40 class SignalStrategy; | 38 class SignalStrategy; |
41 | 39 |
42 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, | 40 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, |
43 public protocol::ClientStub { | 41 public protocol::ClientStub { |
44 public: | 42 public: |
45 // |audio_player| may be null, in which case audio will not be requested. | 43 // |audio_player| may be null, in which case audio will not be requested. |
46 ChromotingClient(const ClientConfig& config, | 44 ChromotingClient(ClientContext* client_context, |
47 ClientContext* client_context, | |
48 protocol::ConnectionToHost* connection, | |
49 ClientUserInterface* user_interface, | 45 ClientUserInterface* user_interface, |
50 VideoRenderer* video_renderer, | 46 VideoRenderer* video_renderer, |
51 scoped_ptr<AudioPlayer> audio_player); | 47 scoped_ptr<AudioPlayer> audio_player); |
52 | 48 |
53 virtual ~ChromotingClient(); | 49 virtual ~ChromotingClient(); |
54 | 50 |
55 // Start the client. Must be called on the main thread. |signal_strategy| | 51 // Start the client. Must be called on the main thread. |signal_strategy| |
56 // must outlive the client. | 52 // must outlive the client. |
57 void Start(SignalStrategy* signal_strategy, | 53 void Start(SignalStrategy* signal_strategy, |
58 scoped_ptr<protocol::TransportFactory> transport_factory); | 54 scoped_ptr<protocol::Authenticator> authenticator, |
| 55 scoped_ptr<protocol::TransportFactory> transport_factory, |
| 56 const std::string& host_jid, |
| 57 const std::string& capabilities); |
| 58 |
| 59 protocol::ConnectionToHost::State connection_state() const { |
| 60 return connection_.state(); |
| 61 } |
| 62 |
| 63 protocol::ClipboardStub* clipboard_forwarder() { |
| 64 return connection_.clipboard_forwarder(); |
| 65 } |
| 66 protocol::HostStub* host_stub() { return connection_.host_stub(); } |
| 67 protocol::InputStub* input_stub() { return connection_.input_stub(); } |
59 | 68 |
60 // ClientStub implementation. | 69 // ClientStub implementation. |
61 virtual void SetCapabilities( | 70 virtual void SetCapabilities( |
62 const protocol::Capabilities& capabilities) OVERRIDE; | 71 const protocol::Capabilities& capabilities) OVERRIDE; |
63 virtual void SetPairingResponse( | 72 virtual void SetPairingResponse( |
64 const protocol::PairingResponse& pairing_response) OVERRIDE; | 73 const protocol::PairingResponse& pairing_response) OVERRIDE; |
65 virtual void DeliverHostMessage( | 74 virtual void DeliverHostMessage( |
66 const protocol::ExtensionMessage& message) OVERRIDE; | 75 const protocol::ExtensionMessage& message) OVERRIDE; |
67 | 76 |
68 // ClipboardStub implementation for receiving clipboard data from host. | 77 // ClipboardStub implementation for receiving clipboard data from host. |
(...skipping 13 matching lines...) Expand all Loading... |
82 const protocol::TransportRoute& route) OVERRIDE; | 91 const protocol::TransportRoute& route) OVERRIDE; |
83 | 92 |
84 private: | 93 private: |
85 // Called when the connection is authenticated. | 94 // Called when the connection is authenticated. |
86 void OnAuthenticated(); | 95 void OnAuthenticated(); |
87 | 96 |
88 // Called when all channels are connected. | 97 // Called when all channels are connected. |
89 void OnChannelsConnected(); | 98 void OnChannelsConnected(); |
90 | 99 |
91 // The following are not owned by this class. | 100 // The following are not owned by this class. |
92 ClientConfig config_; | |
93 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 101 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
94 protocol::ConnectionToHost* connection_; | |
95 ClientUserInterface* user_interface_; | 102 ClientUserInterface* user_interface_; |
96 VideoRenderer* video_renderer_; | 103 VideoRenderer* video_renderer_; |
97 | 104 |
| 105 protocol::ConnectionToHost connection_; |
| 106 |
98 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; | 107 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; |
99 | 108 |
100 // If non-NULL, this is called when the client is done. | 109 std::string local_capabilities_; |
101 base::Closure client_done_; | |
102 | 110 |
103 // The set of all capabilities supported by the host. | 111 // The set of all capabilities supported by the host. |
104 std::string host_capabilities_; | 112 std::string host_capabilities_; |
105 | 113 |
106 // True if |protocol::Capabilities| message has been received. | 114 // True if |protocol::Capabilities| message has been received. |
107 bool host_capabilities_received_; | 115 bool host_capabilities_received_; |
108 | 116 |
109 // Record the statistics of the connection. | 117 // Record the statistics of the connection. |
110 ChromotingStats stats_; | 118 ChromotingStats stats_; |
111 | 119 |
112 // WeakPtr used to avoid tasks accessing the client after it is deleted. | |
113 base::WeakPtr<ChromotingClient> weak_ptr_; | |
114 base::WeakPtrFactory<ChromotingClient> weak_factory_; | |
115 | |
116 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 120 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
117 }; | 121 }; |
118 | 122 |
119 } // namespace remoting | 123 } // namespace remoting |
120 | 124 |
121 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 125 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
OLD | NEW |