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

Side by Side Diff: remoting/host/it2me/it2me_host.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/host/it2me/it2me_host.h" 5 #include "remoting/host/it2me/it2me_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 30 matching lines...) Expand all
41 41
42 } // namespace 42 } // namespace
43 43
44 It2MeHost::It2MeHost( 44 It2MeHost::It2MeHost(
45 scoped_ptr<ChromotingHostContext> host_context, 45 scoped_ptr<ChromotingHostContext> host_context,
46 scoped_ptr<PolicyWatcher> policy_watcher, 46 scoped_ptr<PolicyWatcher> policy_watcher,
47 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory, 47 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory,
48 base::WeakPtr<It2MeHost::Observer> observer, 48 base::WeakPtr<It2MeHost::Observer> observer,
49 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, 49 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
50 const std::string& directory_bot_jid) 50 const std::string& directory_bot_jid)
51 : host_context_(host_context.Pass()), 51 : host_context_(std::move(host_context)),
52 task_runner_(host_context_->ui_task_runner()), 52 task_runner_(host_context_->ui_task_runner()),
53 observer_(observer), 53 observer_(observer),
54 xmpp_server_config_(xmpp_server_config), 54 xmpp_server_config_(xmpp_server_config),
55 directory_bot_jid_(directory_bot_jid), 55 directory_bot_jid_(directory_bot_jid),
56 state_(kDisconnected), 56 state_(kDisconnected),
57 failed_login_attempts_(0), 57 failed_login_attempts_(0),
58 policy_watcher_(policy_watcher.Pass()), 58 policy_watcher_(std::move(policy_watcher)),
59 confirmation_dialog_factory_(confirmation_dialog_factory.Pass()), 59 confirmation_dialog_factory_(std::move(confirmation_dialog_factory)),
60 nat_traversal_enabled_(false), 60 nat_traversal_enabled_(false),
61 policy_received_(false) { 61 policy_received_(false) {
62 DCHECK(task_runner_->BelongsToCurrentThread()); 62 DCHECK(task_runner_->BelongsToCurrentThread());
63 } 63 }
64 64
65 void It2MeHost::Connect() { 65 void It2MeHost::Connect() {
66 if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) { 66 if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) {
67 DCHECK(task_runner_->BelongsToCurrentThread()); 67 DCHECK(task_runner_->BelongsToCurrentThread());
68 host_context_->ui_task_runner()->PostTask( 68 host_context_->ui_task_runner()->PostTask(
69 FROM_HERE, base::Bind(&It2MeHost::Connect, this)); 69 FROM_HERE, base::Bind(&It2MeHost::Connect, this));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 confirmation_dialog_factory_->Create(); 136 confirmation_dialog_factory_->Create();
137 137
138 // TODO(dcaiafa): Remove after dialog implementations for all platforms exist. 138 // TODO(dcaiafa): Remove after dialog implementations for all platforms exist.
139 if (!confirmation_dialog) { 139 if (!confirmation_dialog) {
140 ReadPolicyAndConnect(); 140 ReadPolicyAndConnect();
141 return; 141 return;
142 } 142 }
143 143
144 confirmation_dialog_proxy_.reset( 144 confirmation_dialog_proxy_.reset(
145 new It2MeConfirmationDialogProxy(host_context_->ui_task_runner(), 145 new It2MeConfirmationDialogProxy(host_context_->ui_task_runner(),
146 confirmation_dialog.Pass())); 146 std::move(confirmation_dialog)));
147 147
148 confirmation_dialog_proxy_->Show( 148 confirmation_dialog_proxy_->Show(
149 base::Bind(&It2MeHost::OnConfirmationResult, base::Unretained(this))); 149 base::Bind(&It2MeHost::OnConfirmationResult, base::Unretained(this)));
150 } 150 }
151 151
152 void It2MeHost::OnConfirmationResult(It2MeConfirmationDialog::Result result) { 152 void It2MeHost::OnConfirmationResult(It2MeConfirmationDialog::Result result) {
153 switch (result) { 153 switch (result) {
154 case It2MeConfirmationDialog::Result::OK: 154 case It2MeConfirmationDialog::Result::OK:
155 ReadPolicyAndConnect(); 155 ReadPolicyAndConnect();
156 break; 156 break;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 xmpp_server_config_)); 208 xmpp_server_config_));
209 209
210 // Request registration of the host for support. 210 // Request registration of the host for support.
211 scoped_ptr<RegisterSupportHostRequest> register_request( 211 scoped_ptr<RegisterSupportHostRequest> register_request(
212 new RegisterSupportHostRequest( 212 new RegisterSupportHostRequest(
213 signal_strategy.get(), host_key_pair_, directory_bot_jid_, 213 signal_strategy.get(), host_key_pair_, directory_bot_jid_,
214 base::Bind(&It2MeHost::OnReceivedSupportID, 214 base::Bind(&It2MeHost::OnReceivedSupportID,
215 base::Unretained(this)))); 215 base::Unretained(this))));
216 216
217 // Beyond this point nothing can fail, so save the config and request. 217 // Beyond this point nothing can fail, so save the config and request.
218 signal_strategy_ = signal_strategy.Pass(); 218 signal_strategy_ = std::move(signal_strategy);
219 register_request_ = register_request.Pass(); 219 register_request_ = std::move(register_request);
220 220
221 // If NAT traversal is off then limit port range to allow firewall pin-holing. 221 // If NAT traversal is off then limit port range to allow firewall pin-holing.
222 HOST_LOG << "NAT state: " << nat_traversal_enabled_; 222 HOST_LOG << "NAT state: " << nat_traversal_enabled_;
223 protocol::NetworkSettings network_settings( 223 protocol::NetworkSettings network_settings(
224 nat_traversal_enabled_ ? 224 nat_traversal_enabled_ ?
225 protocol::NetworkSettings::NAT_TRAVERSAL_FULL : 225 protocol::NetworkSettings::NAT_TRAVERSAL_FULL :
226 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED); 226 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED);
227 if (!nat_traversal_enabled_) { 227 if (!nat_traversal_enabled_) {
228 network_settings.port_range.min_port = 228 network_settings.port_range.min_port =
229 protocol::NetworkSettings::kDefaultMinPort; 229 protocol::NetworkSettings::kDefaultMinPort;
230 network_settings.port_range.max_port = 230 network_settings.port_range.max_port =
231 protocol::NetworkSettings::kDefaultMaxPort; 231 protocol::NetworkSettings::kDefaultMaxPort;
232 } 232 }
233 233
234 scoped_ptr<protocol::TransportFactory> transport_factory( 234 scoped_ptr<protocol::TransportFactory> transport_factory(
235 new protocol::IceTransportFactory(new protocol::TransportContext( 235 new protocol::IceTransportFactory(new protocol::TransportContext(
236 signal_strategy_.get(), 236 signal_strategy_.get(),
237 make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory( 237 make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory(
238 host_context_->url_request_context_getter())), 238 host_context_->url_request_context_getter())),
239 network_settings, protocol::TransportRole::SERVER))); 239 network_settings, protocol::TransportRole::SERVER)));
240 240
241 scoped_ptr<protocol::SessionManager> session_manager( 241 scoped_ptr<protocol::SessionManager> session_manager(
242 new protocol::JingleSessionManager(transport_factory.Pass(), 242 new protocol::JingleSessionManager(std::move(transport_factory),
243 signal_strategy.get())); 243 signal_strategy.get()));
244 244
245 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = 245 scoped_ptr<protocol::CandidateSessionConfig> protocol_config =
246 protocol::CandidateSessionConfig::CreateDefault(); 246 protocol::CandidateSessionConfig::CreateDefault();
247 // Disable audio by default. 247 // Disable audio by default.
248 // TODO(sergeyu): Add UI to enable it. 248 // TODO(sergeyu): Add UI to enable it.
249 protocol_config->DisableAudioChannel(); 249 protocol_config->DisableAudioChannel();
250 session_manager->set_protocol_config(protocol_config.Pass()); 250 session_manager->set_protocol_config(std::move(protocol_config));
251 251
252 // Create the host. 252 // Create the host.
253 host_.reset(new ChromotingHost( 253 host_.reset(new ChromotingHost(
254 desktop_environment_factory_.get(), 254 desktop_environment_factory_.get(), std::move(session_manager),
255 session_manager.Pass(), host_context_->audio_task_runner(), 255 host_context_->audio_task_runner(), host_context_->input_task_runner(),
256 host_context_->input_task_runner(),
257 host_context_->video_capture_task_runner(), 256 host_context_->video_capture_task_runner(),
258 host_context_->video_encode_task_runner(), 257 host_context_->video_encode_task_runner(),
259 host_context_->network_task_runner(), host_context_->ui_task_runner())); 258 host_context_->network_task_runner(), host_context_->ui_task_runner()));
260 host_->AddStatusObserver(this); 259 host_->AddStatusObserver(this);
261 host_status_logger_.reset( 260 host_status_logger_.reset(
262 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::IT2ME, 261 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::IT2ME,
263 signal_strategy_.get(), directory_bot_jid_)); 262 signal_strategy_.get(), directory_bot_jid_));
264 263
265 // Create event logger. 264 // Create event logger.
266 host_event_logger_ = 265 host_event_logger_ =
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 std::string error_message = "Failed to generate host certificate."; 449 std::string error_message = "Failed to generate host certificate.";
451 LOG(ERROR) << error_message; 450 LOG(ERROR) << error_message;
452 SetState(kError, error_message); 451 SetState(kError, error_message);
453 Shutdown(); 452 Shutdown();
454 return; 453 return;
455 } 454 }
456 455
457 scoped_ptr<protocol::AuthenticatorFactory> factory( 456 scoped_ptr<protocol::AuthenticatorFactory> factory(
458 new protocol::It2MeHostAuthenticatorFactory( 457 new protocol::It2MeHostAuthenticatorFactory(
459 local_certificate, host_key_pair_, access_code)); 458 local_certificate, host_key_pair_, access_code));
460 host_->SetAuthenticatorFactory(factory.Pass()); 459 host_->SetAuthenticatorFactory(std::move(factory));
461 460
462 // Pass the Access Code to the script object before changing state. 461 // Pass the Access Code to the script object before changing state.
463 task_runner_->PostTask( 462 task_runner_->PostTask(
464 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode, 463 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode,
465 observer_, access_code, lifetime)); 464 observer_, access_code, lifetime));
466 465
467 SetState(kReceivedAccessCode, ""); 466 SetState(kReceivedAccessCode, "");
468 } 467 }
469 468
470 It2MeHostFactory::It2MeHostFactory() : policy_service_(nullptr) { 469 It2MeHostFactory::It2MeHostFactory() : policy_service_(nullptr) {
(...skipping 12 matching lines...) Expand all
483 scoped_ptr<ChromotingHostContext> context, 482 scoped_ptr<ChromotingHostContext> context,
484 base::WeakPtr<It2MeHost::Observer> observer, 483 base::WeakPtr<It2MeHost::Observer> observer,
485 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, 484 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
486 const std::string& directory_bot_jid) { 485 const std::string& directory_bot_jid) {
487 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); 486 DCHECK(context->ui_task_runner()->BelongsToCurrentThread());
488 487
489 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory( 488 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory(
490 new It2MeConfirmationDialogFactory()); 489 new It2MeConfirmationDialogFactory());
491 scoped_ptr<PolicyWatcher> policy_watcher = 490 scoped_ptr<PolicyWatcher> policy_watcher =
492 PolicyWatcher::Create(policy_service_, context->file_task_runner()); 491 PolicyWatcher::Create(policy_service_, context->file_task_runner());
493 return new It2MeHost(context.Pass(), policy_watcher.Pass(), 492 return new It2MeHost(std::move(context), std::move(policy_watcher),
494 confirmation_dialog_factory.Pass(), 493 std::move(confirmation_dialog_factory), observer,
495 observer, xmpp_server_config, directory_bot_jid); 494 xmpp_server_config, directory_bot_jid);
496 } 495 }
497 496
498 } // namespace remoting 497 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698