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

Side by Side Diff: remoting/host/remoting_me2me_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: include <utility> 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
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | remoting/host/resizing_host_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <utility>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/debug/alias.h" 16 #include "base/debug/alias.h"
16 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
17 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
20 #include "base/message_loop/message_loop.h" 21 #include "base/message_loop/message_loop.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 scoped_refptr<PairingRegistry> pairing_registry_; 465 scoped_refptr<PairingRegistry> pairing_registry_;
465 466
466 ShutdownWatchdog* shutdown_watchdog_; 467 ShutdownWatchdog* shutdown_watchdog_;
467 468
468 DISALLOW_COPY_AND_ASSIGN(HostProcess); 469 DISALLOW_COPY_AND_ASSIGN(HostProcess);
469 }; 470 };
470 471
471 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, 472 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
472 int* exit_code_out, 473 int* exit_code_out,
473 ShutdownWatchdog* shutdown_watchdog) 474 ShutdownWatchdog* shutdown_watchdog)
474 : context_(context.Pass()), 475 : context_(std::move(context)),
475 state_(HOST_STARTING), 476 state_(HOST_STARTING),
476 use_service_account_(false), 477 use_service_account_(false),
477 enable_vp9_(false), 478 enable_vp9_(false),
478 frame_recorder_buffer_size_(0), 479 frame_recorder_buffer_size_(0),
479 policy_state_(POLICY_INITIALIZING), 480 policy_state_(POLICY_INITIALIZING),
480 host_username_match_required_(false), 481 host_username_match_required_(false),
481 allow_nat_traversal_(true), 482 allow_nat_traversal_(true),
482 allow_relay_(true), 483 allow_relay_(true),
483 allow_pairing_(true), 484 allow_pairing_(true),
484 curtain_required_(false), 485 curtain_required_(false),
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 if (allow_pairing_) { 774 if (allow_pairing_) {
774 // On Windows |pairing_registry_| is initialized in 775 // On Windows |pairing_registry_| is initialized in
775 // InitializePairingRegistry(). 776 // InitializePairingRegistry().
776 #if !defined(OS_WIN) 777 #if !defined(OS_WIN)
777 if (!pairing_registry_) { 778 if (!pairing_registry_) {
778 scoped_ptr<PairingRegistry::Delegate> delegate = 779 scoped_ptr<PairingRegistry::Delegate> delegate =
779 CreatePairingRegistryDelegate(); 780 CreatePairingRegistryDelegate();
780 781
781 if (delegate) 782 if (delegate)
782 pairing_registry_ = new PairingRegistry(context_->file_task_runner(), 783 pairing_registry_ = new PairingRegistry(context_->file_task_runner(),
783 delegate.Pass()); 784 std::move(delegate));
784 } 785 }
785 #endif // defined(OS_WIN) 786 #endif // defined(OS_WIN)
786 787
787 pairing_registry = pairing_registry_; 788 pairing_registry = pairing_registry_;
788 } 789 }
789 790
790 factory = protocol::Me2MeHostAuthenticatorFactory::CreateWithSharedSecret( 791 factory = protocol::Me2MeHostAuthenticatorFactory::CreateWithSharedSecret(
791 use_service_account_, host_owner_, local_certificate, key_pair_, 792 use_service_account_, host_owner_, local_certificate, key_pair_,
792 host_secret_hash_, pairing_registry); 793 host_secret_hash_, pairing_registry);
793 794
794 host_->set_pairing_registry(pairing_registry); 795 host_->set_pairing_registry(pairing_registry);
795 } else { 796 } else {
796 DCHECK(third_party_auth_config_.token_url.is_valid()); 797 DCHECK(third_party_auth_config_.token_url.is_valid());
797 DCHECK(third_party_auth_config_.token_validation_url.is_valid()); 798 DCHECK(third_party_auth_config_.token_validation_url.is_valid());
798 799
799 scoped_ptr<protocol::TokenValidatorFactory> token_validator_factory( 800 scoped_ptr<protocol::TokenValidatorFactory> token_validator_factory(
800 new TokenValidatorFactoryImpl( 801 new TokenValidatorFactoryImpl(
801 third_party_auth_config_, 802 third_party_auth_config_,
802 key_pair_, context_->url_request_context_getter())); 803 key_pair_, context_->url_request_context_getter()));
803 factory = protocol::Me2MeHostAuthenticatorFactory::CreateWithThirdPartyAuth( 804 factory = protocol::Me2MeHostAuthenticatorFactory::CreateWithThirdPartyAuth(
804 use_service_account_, host_owner_, local_certificate, key_pair_, 805 use_service_account_, host_owner_, local_certificate, key_pair_,
805 token_validator_factory.Pass()); 806 std::move(token_validator_factory));
806 } 807 }
807 808
808 #if defined(OS_POSIX) 809 #if defined(OS_POSIX)
809 // On Linux and Mac, perform a PAM authorization step after authentication. 810 // On Linux and Mac, perform a PAM authorization step after authentication.
810 factory.reset(new PamAuthorizationFactory(factory.Pass())); 811 factory.reset(new PamAuthorizationFactory(std::move(factory)));
811 #endif 812 #endif
812 host_->SetAuthenticatorFactory(factory.Pass()); 813 host_->SetAuthenticatorFactory(std::move(factory));
813 } 814 }
814 815
815 // IPC::Listener implementation. 816 // IPC::Listener implementation.
816 bool HostProcess::OnMessageReceived(const IPC::Message& message) { 817 bool HostProcess::OnMessageReceived(const IPC::Message& message) {
817 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 818 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
818 819
819 #if defined(REMOTING_MULTI_PROCESS) 820 #if defined(REMOTING_MULTI_PROCESS)
820 bool handled = true; 821 bool handled = true;
821 IPC_BEGIN_MESSAGE_MAP(HostProcess, message) 822 IPC_BEGIN_MESSAGE_MAP(HostProcess, message)
822 IPC_MESSAGE_HANDLER(ChromotingDaemonMsg_Crash, OnCrash) 823 IPC_MESSAGE_HANDLER(ChromotingDaemonMsg_Crash, OnCrash)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 HKEY privileged_hkey = reinterpret_cast<HKEY>( 991 HKEY privileged_hkey = reinterpret_cast<HKEY>(
991 IPC::PlatformFileForTransitToPlatformFile(privileged_key)); 992 IPC::PlatformFileForTransitToPlatformFile(privileged_key));
992 HKEY unprivileged_hkey = reinterpret_cast<HKEY>( 993 HKEY unprivileged_hkey = reinterpret_cast<HKEY>(
993 IPC::PlatformFileForTransitToPlatformFile(unprivileged_key)); 994 IPC::PlatformFileForTransitToPlatformFile(unprivileged_key));
994 995
995 scoped_ptr<PairingRegistryDelegateWin> delegate( 996 scoped_ptr<PairingRegistryDelegateWin> delegate(
996 new PairingRegistryDelegateWin()); 997 new PairingRegistryDelegateWin());
997 delegate->SetRootKeys(privileged_hkey, unprivileged_hkey); 998 delegate->SetRootKeys(privileged_hkey, unprivileged_hkey);
998 999
999 pairing_registry_ = new PairingRegistry(context_->file_task_runner(), 1000 pairing_registry_ = new PairingRegistry(context_->file_task_runner(),
1000 delegate.Pass()); 1001 std::move(delegate));
1001 1002
1002 // (Re)Create the authenticator factory now that |pairing_registry_| has been 1003 // (Re)Create the authenticator factory now that |pairing_registry_| has been
1003 // initialized. 1004 // initialized.
1004 CreateAuthenticatorFactory(); 1005 CreateAuthenticatorFactory();
1005 } 1006 }
1006 #endif // !defined(OS_WIN) 1007 #endif // !defined(OS_WIN)
1007 1008
1008 // Applies the host config, returning true if successful. 1009 // Applies the host config, returning true if successful.
1009 bool HostProcess::ApplyConfig(const base::DictionaryValue& config) { 1010 bool HostProcess::ApplyConfig(const base::DictionaryValue& config) {
1010 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1011 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 context_->url_request_context_getter(), xmpp_server_config_); 1419 context_->url_request_context_getter(), xmpp_server_config_);
1419 signal_strategy_.reset(xmpp_signal_strategy); 1420 signal_strategy_.reset(xmpp_signal_strategy);
1420 1421
1421 // Create SignalingConnector. 1422 // Create SignalingConnector.
1422 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker(new DnsBlackholeChecker( 1423 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker(new DnsBlackholeChecker(
1423 context_->url_request_context_getter(), talkgadget_prefix_)); 1424 context_->url_request_context_getter(), talkgadget_prefix_));
1424 scoped_ptr<OAuthTokenGetter::OAuthCredentials> oauth_credentials( 1425 scoped_ptr<OAuthTokenGetter::OAuthCredentials> oauth_credentials(
1425 new OAuthTokenGetter::OAuthCredentials(xmpp_server_config_.username, 1426 new OAuthTokenGetter::OAuthCredentials(xmpp_server_config_.username,
1426 oauth_refresh_token_, 1427 oauth_refresh_token_,
1427 use_service_account_)); 1428 use_service_account_));
1428 oauth_token_getter_.reset(new OAuthTokenGetterImpl( 1429 oauth_token_getter_.reset(
1429 oauth_credentials.Pass(), context_->url_request_context_getter(), false)); 1430 new OAuthTokenGetterImpl(std::move(oauth_credentials),
1431 context_->url_request_context_getter(), false));
1430 signaling_connector_.reset(new SignalingConnector( 1432 signaling_connector_.reset(new SignalingConnector(
1431 xmpp_signal_strategy, dns_blackhole_checker.Pass(), 1433 xmpp_signal_strategy, std::move(dns_blackhole_checker),
1432 oauth_token_getter_.get(), 1434 oauth_token_getter_.get(),
1433 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this)))); 1435 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this))));
1434 1436
1435 #if defined(USE_GCD) 1437 #if defined(USE_GCD)
1436 // Create objects to manage GCD state. 1438 // Create objects to manage GCD state.
1437 ServiceUrls* service_urls = ServiceUrls::GetInstance(); 1439 ServiceUrls* service_urls = ServiceUrls::GetInstance();
1438 scoped_ptr<GcdRestClient> gcd_rest_client(new GcdRestClient( 1440 scoped_ptr<GcdRestClient> gcd_rest_client(new GcdRestClient(
1439 service_urls->gcd_base_url(), host_id_, 1441 service_urls->gcd_base_url(), host_id_,
1440 context_->url_request_context_getter(), oauth_token_getter_.get())); 1442 context_->url_request_context_getter(), oauth_token_getter_.get()));
1441 gcd_state_updater_.reset( 1443 gcd_state_updater_.reset(new GcdStateUpdater(
1442 new GcdStateUpdater(base::Bind(&HostProcess::OnHeartbeatSuccessful, 1444 base::Bind(&HostProcess::OnHeartbeatSuccessful, base::Unretained(this)),
1443 base::Unretained(this)), 1445 base::Bind(&HostProcess::OnUnknownHostIdError, base::Unretained(this)),
1444 base::Bind(&HostProcess::OnUnknownHostIdError, 1446 signal_strategy_.get(), std::move(gcd_rest_client)));
1445 base::Unretained(this)),
1446 signal_strategy_.get(), gcd_rest_client.Pass()));
1447 PushNotificationSubscriber::Subscription sub; 1447 PushNotificationSubscriber::Subscription sub;
1448 sub.channel = "cloud_devices"; 1448 sub.channel = "cloud_devices";
1449 PushNotificationSubscriber::SubscriptionList subs; 1449 PushNotificationSubscriber::SubscriptionList subs;
1450 subs.push_back(sub); 1450 subs.push_back(sub);
1451 gcd_subscriber_.reset( 1451 gcd_subscriber_.reset(
1452 new PushNotificationSubscriber(signal_strategy_.get(), subs)); 1452 new PushNotificationSubscriber(signal_strategy_.get(), subs));
1453 #endif // defined(USE_GCD) 1453 #endif // defined(USE_GCD)
1454 1454
1455 // Create HeartbeatSender. 1455 // Create HeartbeatSender.
1456 heartbeat_sender_.reset(new HeartbeatSender( 1456 heartbeat_sender_.reset(new HeartbeatSender(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 #else // !defined(NDEBUG) 1521 #else // !defined(NDEBUG)
1522 LOG(ERROR) << "WebRTC is enabled only in debug builds."; 1522 LOG(ERROR) << "WebRTC is enabled only in debug builds.";
1523 ShutdownHost(kUsageExitCode); 1523 ShutdownHost(kUsageExitCode);
1524 return; 1524 return;
1525 #endif // defined(NDEBUG) 1525 #endif // defined(NDEBUG)
1526 } else { 1526 } else {
1527 transport_factory.reset( 1527 transport_factory.reset(
1528 new protocol::IceTransportFactory(transport_context)); 1528 new protocol::IceTransportFactory(transport_context));
1529 } 1529 }
1530 scoped_ptr<protocol::SessionManager> session_manager( 1530 scoped_ptr<protocol::SessionManager> session_manager(
1531 new protocol::JingleSessionManager(transport_factory.Pass(), 1531 new protocol::JingleSessionManager(std::move(transport_factory),
1532 signal_strategy_.get())); 1532 signal_strategy_.get()));
1533 1533
1534 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = 1534 scoped_ptr<protocol::CandidateSessionConfig> protocol_config =
1535 protocol::CandidateSessionConfig::CreateDefault(); 1535 protocol::CandidateSessionConfig::CreateDefault();
1536 if (!desktop_environment_factory_->SupportsAudioCapture()) 1536 if (!desktop_environment_factory_->SupportsAudioCapture())
1537 protocol_config->DisableAudioChannel(); 1537 protocol_config->DisableAudioChannel();
1538 if (enable_vp9_) 1538 if (enable_vp9_)
1539 protocol_config->set_vp9_experiment_enabled(true); 1539 protocol_config->set_vp9_experiment_enabled(true);
1540 #if !defined(NDEBUG) 1540 #if !defined(NDEBUG)
1541 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { 1541 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) {
1542 protocol_config->set_webrtc_supported(true); 1542 protocol_config->set_webrtc_supported(true);
1543 } 1543 }
1544 #endif // !defined(NDEBUG) 1544 #endif // !defined(NDEBUG)
1545 session_manager->set_protocol_config(protocol_config.Pass()); 1545 session_manager->set_protocol_config(std::move(protocol_config));
1546 1546
1547 host_.reset(new ChromotingHost( 1547 host_.reset(new ChromotingHost(
1548 desktop_environment_factory_.get(), 1548 desktop_environment_factory_.get(), std::move(session_manager),
1549 session_manager.Pass(), context_->audio_task_runner(), 1549 context_->audio_task_runner(), context_->input_task_runner(),
1550 context_->input_task_runner(), context_->video_capture_task_runner(), 1550 context_->video_capture_task_runner(),
1551 context_->video_encode_task_runner(), context_->network_task_runner(), 1551 context_->video_encode_task_runner(), context_->network_task_runner(),
1552 context_->ui_task_runner())); 1552 context_->ui_task_runner()));
1553 1553
1554 if (frame_recorder_buffer_size_ > 0) { 1554 if (frame_recorder_buffer_size_ > 0) {
1555 scoped_ptr<VideoFrameRecorderHostExtension> frame_recorder_extension( 1555 scoped_ptr<VideoFrameRecorderHostExtension> frame_recorder_extension(
1556 new VideoFrameRecorderHostExtension()); 1556 new VideoFrameRecorderHostExtension());
1557 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_); 1557 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_);
1558 host_->AddExtension(frame_recorder_extension.Pass()); 1558 host_->AddExtension(std::move(frame_recorder_extension));
1559 } 1559 }
1560 1560
1561 // TODO(simonmorris): Get the maximum session duration from a policy. 1561 // TODO(simonmorris): Get the maximum session duration from a policy.
1562 #if defined(OS_LINUX) 1562 #if defined(OS_LINUX)
1563 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); 1563 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20));
1564 #endif 1564 #endif
1565 1565
1566 host_change_notification_listener_.reset(new HostChangeNotificationListener( 1566 host_change_notification_listener_.reset(new HostChangeNotificationListener(
1567 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); 1567 this, host_id_, signal_strategy_.get(), directory_bot_jid_));
1568 1568
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 // NetworkChangeNotifier must be initialized after MessageLoop. 1743 // NetworkChangeNotifier must be initialized after MessageLoop.
1744 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( 1744 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier(
1745 net::NetworkChangeNotifier::Create()); 1745 net::NetworkChangeNotifier::Create());
1746 1746
1747 // Create & start the HostProcess using these threads. 1747 // Create & start the HostProcess using these threads.
1748 // TODO(wez): The HostProcess holds a reference to itself until Shutdown(). 1748 // TODO(wez): The HostProcess holds a reference to itself until Shutdown().
1749 // Remove this hack as part of the multi-process refactoring. 1749 // Remove this hack as part of the multi-process refactoring.
1750 int exit_code = kSuccessExitCode; 1750 int exit_code = kSuccessExitCode;
1751 ShutdownWatchdog shutdown_watchdog( 1751 ShutdownWatchdog shutdown_watchdog(
1752 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); 1752 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds));
1753 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); 1753 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog);
1754 1754
1755 // Run the main (also UI) message loop until the host no longer needs it. 1755 // Run the main (also UI) message loop until the host no longer needs it.
1756 message_loop.Run(); 1756 message_loop.Run();
1757 1757
1758 return exit_code; 1758 return exit_code;
1759 } 1759 }
1760 1760
1761 } // namespace remoting 1761 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | remoting/host/resizing_host_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698