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 "remoting/client/chromoting_stats.h" | 14 #include "remoting/client/chromoting_stats.h" |
15 #include "remoting/protocol/client_stub.h" | 15 #include "remoting/protocol/client_stub.h" |
16 #include "remoting/protocol/clipboard_stub.h" | 16 #include "remoting/protocol/clipboard_stub.h" |
17 #include "remoting/protocol/connection_to_host.h" | 17 #include "remoting/protocol/connection_to_host.h" |
| 18 #include "remoting/protocol/connection_to_host_impl.h" |
18 #include "remoting/protocol/input_stub.h" | 19 #include "remoting/protocol/input_stub.h" |
19 #include "remoting/protocol/video_stub.h" | 20 #include "remoting/protocol/video_stub.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
23 } // namespace base | 24 } // namespace base |
24 | 25 |
25 namespace remoting { | 26 namespace remoting { |
26 | 27 |
27 namespace protocol { | 28 namespace protocol { |
(...skipping 16 matching lines...) Expand all Loading... |
44 // |client_context|, |user_interface| and |video_renderer| must outlive the | 45 // |client_context|, |user_interface| and |video_renderer| must outlive the |
45 // client. |audio_player| may be null, in which case audio will not be | 46 // client. |audio_player| may be null, in which case audio will not be |
46 // requested. | 47 // requested. |
47 ChromotingClient(ClientContext* client_context, | 48 ChromotingClient(ClientContext* client_context, |
48 ClientUserInterface* user_interface, | 49 ClientUserInterface* user_interface, |
49 VideoRenderer* video_renderer, | 50 VideoRenderer* video_renderer, |
50 scoped_ptr<AudioPlayer> audio_player); | 51 scoped_ptr<AudioPlayer> audio_player); |
51 | 52 |
52 ~ChromotingClient() override; | 53 ~ChromotingClient() override; |
53 | 54 |
| 55 // Used to set fake/mock objects for tests which use the ChromotingClient. |
54 void SetProtocolConfigForTests( | 56 void SetProtocolConfigForTests( |
55 scoped_ptr<protocol::CandidateSessionConfig> config); | 57 scoped_ptr<protocol::CandidateSessionConfig> config); |
| 58 void SetConnectionToHostForTests( |
| 59 scoped_ptr<protocol::ConnectionToHost> connection_to_host); |
56 | 60 |
57 // Start the client. Must be called on the main thread. |signal_strategy| | 61 // Start the client. Must be called on the main thread. |signal_strategy| |
58 // must outlive the client. | 62 // must outlive the client. |
59 void Start(SignalStrategy* signal_strategy, | 63 void Start(SignalStrategy* signal_strategy, |
60 scoped_ptr<protocol::Authenticator> authenticator, | 64 scoped_ptr<protocol::Authenticator> authenticator, |
61 scoped_ptr<protocol::TransportFactory> transport_factory, | 65 scoped_ptr<protocol::TransportFactory> transport_factory, |
62 const std::string& host_jid, | 66 const std::string& host_jid, |
63 const std::string& capabilities); | 67 const std::string& capabilities); |
64 | 68 |
65 protocol::ConnectionToHost::State connection_state() const { | 69 protocol::ConnectionToHost::State connection_state() const { |
66 return connection_.state(); | 70 return connection_->state(); |
67 } | 71 } |
68 | 72 |
69 protocol::ClipboardStub* clipboard_forwarder() { | 73 protocol::ClipboardStub* clipboard_forwarder() { |
70 return connection_.clipboard_forwarder(); | 74 return connection_->clipboard_forwarder(); |
71 } | 75 } |
72 protocol::HostStub* host_stub() { return connection_.host_stub(); } | 76 protocol::HostStub* host_stub() { return connection_->host_stub(); } |
73 protocol::InputStub* input_stub() { return connection_.input_stub(); } | 77 protocol::InputStub* input_stub() { return connection_->input_stub(); } |
74 | 78 |
75 // ClientStub implementation. | 79 // ClientStub implementation. |
76 void SetCapabilities(const protocol::Capabilities& capabilities) override; | 80 void SetCapabilities(const protocol::Capabilities& capabilities) override; |
77 void SetPairingResponse( | 81 void SetPairingResponse( |
78 const protocol::PairingResponse& pairing_response) override; | 82 const protocol::PairingResponse& pairing_response) override; |
79 void DeliverHostMessage(const protocol::ExtensionMessage& message) override; | 83 void DeliverHostMessage(const protocol::ExtensionMessage& message) override; |
80 | 84 |
81 // ClipboardStub implementation for receiving clipboard data from host. | 85 // ClipboardStub implementation for receiving clipboard data from host. |
82 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; | 86 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; |
83 | 87 |
(...skipping 12 matching lines...) Expand all Loading... |
96 void OnAuthenticated(); | 100 void OnAuthenticated(); |
97 | 101 |
98 // Called when all channels are connected. | 102 // Called when all channels are connected. |
99 void OnChannelsConnected(); | 103 void OnChannelsConnected(); |
100 | 104 |
101 // The following are not owned by this class. | 105 // The following are not owned by this class. |
102 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 106 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
103 ClientUserInterface* user_interface_; | 107 ClientUserInterface* user_interface_; |
104 VideoRenderer* video_renderer_; | 108 VideoRenderer* video_renderer_; |
105 | 109 |
106 protocol::ConnectionToHost connection_; | 110 scoped_ptr<protocol::ConnectionToHost> connection_; |
107 | 111 |
108 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; | 112 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; |
109 | 113 |
110 std::string local_capabilities_; | 114 std::string local_capabilities_; |
111 | 115 |
112 // The set of all capabilities supported by the host. | 116 // The set of all capabilities supported by the host. |
113 std::string host_capabilities_; | 117 std::string host_capabilities_; |
114 | 118 |
115 // True if |protocol::Capabilities| message has been received. | 119 // True if |protocol::Capabilities| message has been received. |
116 bool host_capabilities_received_; | 120 bool host_capabilities_received_; |
117 | 121 |
118 // Record the statistics of the connection. | 122 // Record the statistics of the connection. |
119 ChromotingStats stats_; | 123 ChromotingStats stats_; |
120 | 124 |
121 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 125 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
122 }; | 126 }; |
123 | 127 |
124 } // namespace remoting | 128 } // namespace remoting |
125 | 129 |
126 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 130 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
OLD | NEW |