Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: remoting/client/chromoting_client.cc

Issue 976233003: Adding the base ChromotingInstance implementation and unittests. This class will be used by the ap… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a unit test name Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "remoting/client/chromoting_client.h" 5 #include "remoting/client/chromoting_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "remoting/base/capabilities.h" 8 #include "remoting/base/capabilities.h"
9 #include "remoting/client/audio_decode_scheduler.h" 9 #include "remoting/client/audio_decode_scheduler.h"
10 #include "remoting/client/audio_player.h" 10 #include "remoting/client/audio_player.h"
(...skipping 15 matching lines...) Expand all
26 26
27 ChromotingClient::ChromotingClient( 27 ChromotingClient::ChromotingClient(
28 ClientContext* client_context, 28 ClientContext* client_context,
29 ClientUserInterface* user_interface, 29 ClientUserInterface* user_interface,
30 VideoRenderer* video_renderer, 30 VideoRenderer* video_renderer,
31 scoped_ptr<AudioPlayer> audio_player) 31 scoped_ptr<AudioPlayer> audio_player)
32 : task_runner_(client_context->main_task_runner()), 32 : task_runner_(client_context->main_task_runner()),
33 user_interface_(user_interface), 33 user_interface_(user_interface),
34 video_renderer_(video_renderer), 34 video_renderer_(video_renderer),
35 host_capabilities_received_(false) { 35 host_capabilities_received_(false) {
36 connection_.reset(new protocol::ConnectionToHost());
Sergey Ulanov 2015/03/09 06:44:40 this should be in the initializer list above, but
joedow 2015/03/09 21:09:25 The problem with moving this code to start is that
36 if (audio_player) { 37 if (audio_player) {
37 audio_decode_scheduler_.reset(new AudioDecodeScheduler( 38 audio_decode_scheduler_.reset(new AudioDecodeScheduler(
38 client_context->main_task_runner(), 39 client_context->main_task_runner(),
39 client_context->audio_decode_task_runner(), 40 client_context->audio_decode_task_runner(),
40 audio_player.Pass())); 41 audio_player.Pass()));
41 } 42 }
42 } 43 }
43 44
44 ChromotingClient::~ChromotingClient() {} 45 ChromotingClient::~ChromotingClient() {}
45 46
46 void ChromotingClient::SetProtocolConfigForTests( 47 void ChromotingClient::SetProtocolConfigForTests(
47 scoped_ptr<protocol::CandidateSessionConfig> config) { 48 scoped_ptr<protocol::CandidateSessionConfig> config) {
48 connection_.set_candidate_config(config.Pass()); 49 connection_->set_candidate_config(config.Pass());
50 }
51
52 void ChromotingClient::SetConnectionToHostForTests(
53 scoped_ptr<protocol::ConnectionToHost> connection_to_host) {
54 connection_ = connection_to_host.Pass();
49 } 55 }
50 56
51 void ChromotingClient::Start( 57 void ChromotingClient::Start(
52 SignalStrategy* signal_strategy, 58 SignalStrategy* signal_strategy,
53 scoped_ptr<protocol::Authenticator> authenticator, 59 scoped_ptr<protocol::Authenticator> authenticator,
54 scoped_ptr<protocol::TransportFactory> transport_factory, 60 scoped_ptr<protocol::TransportFactory> transport_factory,
55 const std::string& host_jid, 61 const std::string& host_jid,
56 const std::string& capabilities) { 62 const std::string& capabilities) {
57 DCHECK(task_runner_->BelongsToCurrentThread()); 63 DCHECK(task_runner_->BelongsToCurrentThread());
58 64
59 local_capabilities_ = capabilities; 65 local_capabilities_ = capabilities;
60 66
61 connection_.set_client_stub(this); 67 connection_->set_client_stub(this);
62 connection_.set_clipboard_stub(this); 68 connection_->set_clipboard_stub(this);
63 connection_.set_video_stub(video_renderer_->GetVideoStub()); 69 connection_->set_video_stub(video_renderer_->GetVideoStub());
64 connection_.set_audio_stub(audio_decode_scheduler_.get()); 70 connection_->set_audio_stub(audio_decode_scheduler_.get());
65 71
66 connection_.Connect(signal_strategy, transport_factory.Pass(), 72 connection_->Connect(signal_strategy, transport_factory.Pass(),
67 authenticator.Pass(), host_jid, this); 73 authenticator.Pass(), host_jid, this);
68 } 74 }
69 75
70 void ChromotingClient::SetCapabilities( 76 void ChromotingClient::SetCapabilities(
71 const protocol::Capabilities& capabilities) { 77 const protocol::Capabilities& capabilities) {
72 DCHECK(task_runner_->BelongsToCurrentThread()); 78 DCHECK(task_runner_->BelongsToCurrentThread());
73 79
74 // Only accept the first |protocol::Capabilities| message. 80 // Only accept the first |protocol::Capabilities| message.
75 if (host_capabilities_received_) { 81 if (host_capabilities_received_) {
76 LOG(WARNING) << "protocol::Capabilities has been received already."; 82 LOG(WARNING) << "protocol::Capabilities has been received already.";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const protocol::TransportRoute& route) { 146 const protocol::TransportRoute& route) {
141 VLOG(0) << "Using " << protocol::TransportRoute::GetTypeString(route.type) 147 VLOG(0) << "Using " << protocol::TransportRoute::GetTypeString(route.type)
142 << " connection for " << channel_name << " channel"; 148 << " connection for " << channel_name << " channel";
143 user_interface_->OnRouteChanged(channel_name, route); 149 user_interface_->OnRouteChanged(channel_name, route);
144 } 150 }
145 151
146 void ChromotingClient::OnAuthenticated() { 152 void ChromotingClient::OnAuthenticated() {
147 DCHECK(task_runner_->BelongsToCurrentThread()); 153 DCHECK(task_runner_->BelongsToCurrentThread());
148 154
149 // Initialize the decoder. 155 // Initialize the decoder.
150 video_renderer_->OnSessionConfig(connection_.config()); 156 video_renderer_->OnSessionConfig(connection_->config());
151 if (connection_.config().is_audio_enabled()) 157 if (connection_->config().is_audio_enabled())
152 audio_decode_scheduler_->Initialize(connection_.config()); 158 audio_decode_scheduler_->Initialize(connection_->config());
153
154 } 159 }
155 160
156 void ChromotingClient::OnChannelsConnected() { 161 void ChromotingClient::OnChannelsConnected() {
157 DCHECK(task_runner_->BelongsToCurrentThread()); 162 DCHECK(task_runner_->BelongsToCurrentThread());
158 163
159 // Negotiate capabilities with the host. 164 // Negotiate capabilities with the host.
160 VLOG(1) << "Client capabilities: " << local_capabilities_; 165 VLOG(1) << "Client capabilities: " << local_capabilities_;
161 166
162 protocol::Capabilities capabilities; 167 protocol::Capabilities capabilities;
163 capabilities.set_capabilities(local_capabilities_); 168 capabilities.set_capabilities(local_capabilities_);
164 connection_.host_stub()->SetCapabilities(capabilities); 169 connection_->host_stub()->SetCapabilities(capabilities);
165 } 170 }
166 171
167 } // namespace remoting 172 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698