diff options
author | sergeyu <sergeyu@chromium.org> | 2015-12-23 11:01:22 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-23 19:02:20 +0000 |
commit | 1417e013d741b99685fee8f3d3c166f597655eda (patch) | |
tree | 6a2ab7f1547bd187cb4eb8e037f8ed69ca36eed1 | |
parent | 090488ff3ff55782b02a1b2965bdbe2acd0b8f53 (diff) | |
download | chromium_src-1417e013d741b99685fee8f3d3c166f597655eda.zip chromium_src-1417e013d741b99685fee8f3d3c166f597655eda.tar.gz chromium_src-1417e013d741b99685fee8f3d3c166f597655eda.tar.bz2 |
Use std::move() instead of .Pass() in remoting/host
Now there is a presubmit check that doesn't allow Pass() anymore.
See https://www.chromium.org/rvalue-references for information
about std::move in chromium.
Review URL: https://codereview.chromium.org/1549493004
Cr-Commit-Position: refs/heads/master@{#366759}
102 files changed, 623 insertions, 573 deletions
diff --git a/remoting/host/audio_capturer_linux.cc b/remoting/host/audio_capturer_linux.cc index 64a7846..dea720a 100644 --- a/remoting/host/audio_capturer_linux.cc +++ b/remoting/host/audio_capturer_linux.cc @@ -5,6 +5,7 @@ #include "remoting/host/audio_capturer_linux.h" #include <stdint.h> +#include <utility> #include "base/files/file_path.h" #include "base/lazy_instance.h" @@ -66,7 +67,7 @@ void AudioCapturerLinux::OnDataRead( packet->set_sampling_rate(AudioPipeReader::kSamplingRate); packet->set_bytes_per_sample(AudioPipeReader::kBytesPerSample); packet->set_channels(AudioPipeReader::kChannels); - callback_.Run(packet.Pass()); + callback_.Run(std::move(packet)); } bool AudioCapturer::IsSupported() { diff --git a/remoting/host/audio_capturer_win.cc b/remoting/host/audio_capturer_win.cc index 325a11d..8c90113 100644 --- a/remoting/host/audio_capturer_win.cc +++ b/remoting/host/audio_capturer_win.cc @@ -4,14 +4,15 @@ #include "remoting/host/audio_capturer_win.h" -#include <windows.h> #include <avrt.h> #include <mmreg.h> #include <mmsystem.h> - #include <stdint.h> #include <stdlib.h> +#include <windows.h> + #include <algorithm> +#include <utility> #include "base/logging.h" @@ -236,7 +237,7 @@ void AudioCapturerWin::DoCapture() { packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2); packet->set_channels(AudioPacket::CHANNELS_STEREO); - callback_.Run(packet.Pass()); + callback_.Run(std::move(packet)); } hr = audio_capture_client_->ReleaseBuffer(frames); diff --git a/remoting/host/audio_pump.cc b/remoting/host/audio_pump.cc index a6e22d4..d6b799d 100644 --- a/remoting/host/audio_pump.cc +++ b/remoting/host/audio_pump.cc @@ -4,6 +4,8 @@ #include "remoting/host/audio_pump.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/logging.h" @@ -58,8 +60,8 @@ AudioPump::Core::Core(base::WeakPtr<AudioPump> pump, scoped_ptr<AudioEncoder> audio_encoder) : pump_(pump), pump_task_runner_(base::ThreadTaskRunnerHandle::Get()), - audio_capturer_(audio_capturer.Pass()), - audio_encoder_(audio_encoder.Pass()), + audio_capturer_(std::move(audio_capturer)), + audio_encoder_(std::move(audio_encoder)), enabled_(true), bytes_pending_(0) { thread_checker_.DetachFromThread(); @@ -99,7 +101,7 @@ void AudioPump::Core::EncodeAudioPacket(scoped_ptr<AudioPacket> packet) { return; scoped_ptr<AudioPacket> encoded_packet = - audio_encoder_->Encode(packet.Pass()); + audio_encoder_->Encode(std::move(packet)); // The audio encoder returns a null audio packet if there's no audio to send. if (!encoded_packet) @@ -123,8 +125,8 @@ AudioPump::AudioPump( weak_factory_(this) { DCHECK(audio_stub_); - core_.reset(new Core(weak_factory_.GetWeakPtr(), audio_capturer.Pass(), - audio_encoder.Pass())); + core_.reset(new Core(weak_factory_.GetWeakPtr(), std::move(audio_capturer), + std::move(audio_encoder))); audio_task_runner_->PostTask( FROM_HERE, base::Bind(&Core::Start, base::Unretained(core_.get()))); @@ -149,7 +151,7 @@ void AudioPump::SendAudioPacket(scoped_ptr<AudioPacket> packet, int size) { DCHECK(packet); audio_stub_->ProcessAudioPacket( - packet.Pass(), + std::move(packet), base::Bind(&AudioPump::OnPacketSent, weak_factory_.GetWeakPtr(), size)); } diff --git a/remoting/host/audio_pump_unittest.cc b/remoting/host/audio_pump_unittest.cc index fe3b44f..b0b0dee 100644 --- a/remoting/host/audio_pump_unittest.cc +++ b/remoting/host/audio_pump_unittest.cc @@ -6,6 +6,8 @@ #include <stddef.h> +#include <utility> + #include "base/macros.h" #include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" @@ -24,7 +26,7 @@ namespace { scoped_ptr<AudioPacket> MakeAudioPacket() { scoped_ptr<AudioPacket> packet(new AudioPacket); packet->add_data()->resize(1000); - return packet.Pass(); + return packet; } } // namespace @@ -53,7 +55,7 @@ class FakeAudioEncoder : public AudioEncoder { ~FakeAudioEncoder() override {} scoped_ptr<AudioPacket> Encode(scoped_ptr<AudioPacket> packet) override { - return packet.Pass(); + return packet; } int GetBitrate() override { return 160000; @@ -108,7 +110,7 @@ void AudioPumpTest::TearDown() { void AudioPumpTest::ProcessAudioPacket( scoped_ptr<AudioPacket> audio_packet, const base::Closure& done) { - sent_packets_.push_back(audio_packet.Pass()); + sent_packets_.push_back(std::move(audio_packet)); done_closures_.push_back(done); } diff --git a/remoting/host/backoff_timer.cc b/remoting/host/backoff_timer.cc index 16679b5..5f2c07d 100644 --- a/remoting/host/backoff_timer.cc +++ b/remoting/host/backoff_timer.cc @@ -4,13 +4,13 @@ #include "remoting/host/backoff_timer.h" +#include <utility> + namespace remoting { -BackoffTimer::BackoffTimer() : timer_(new base::Timer(false, false)) { -} +BackoffTimer::BackoffTimer() : timer_(new base::Timer(false, false)) {} -BackoffTimer::~BackoffTimer() { -} +BackoffTimer::~BackoffTimer() {} void BackoffTimer::Start(const tracked_objects::Location& posted_from, base::TimeDelta delay, @@ -33,6 +33,10 @@ void BackoffTimer::Stop() { backoff_entry_.reset(); }; +void BackoffTimer::SetTimerForTest(scoped_ptr<base::Timer> timer) { + timer_ = std::move(timer); +} + void BackoffTimer::StartTimer() { timer_->Start( posted_from_, backoff_entry_->GetTimeUntilRelease(), diff --git a/remoting/host/backoff_timer.h b/remoting/host/backoff_timer.h index d691cb4..edd49a5 100644 --- a/remoting/host/backoff_timer.h +++ b/remoting/host/backoff_timer.h @@ -33,7 +33,7 @@ class BackoffTimer { // Returns true if the user task may be invoked in the future. bool IsRunning() const { return backoff_entry_; } - void SetTimerForTest(scoped_ptr<base::Timer> timer) { timer_ = timer.Pass(); } + void SetTimerForTest(scoped_ptr<base::Timer> timer); private: void StartTimer(); diff --git a/remoting/host/cast_extension.cc b/remoting/host/cast_extension.cc index 6b513f6..cf2d51c 100644 --- a/remoting/host/cast_extension.cc +++ b/remoting/host/cast_extension.cc @@ -31,11 +31,9 @@ std::string CastExtension::capability() const { scoped_ptr<HostExtensionSession> CastExtension::CreateExtensionSession( ClientSessionControl* client_session_control, protocol::ClientStub* client_stub) { - return CastExtensionSession::Create(network_task_runner_, - url_request_context_getter_, - network_settings_, - client_session_control, - client_stub).Pass(); + return CastExtensionSession::Create( + network_task_runner_, url_request_context_getter_, network_settings_, + client_session_control, client_stub); } } // namespace remoting diff --git a/remoting/host/cast_extension_session.cc b/remoting/host/cast_extension_session.cc index 0364bce..4ad16ce 100644 --- a/remoting/host/cast_extension_session.cc +++ b/remoting/host/cast_extension_session.cc @@ -4,6 +4,8 @@ #include "remoting/host/cast_extension_session.h" +#include <utility> + #include "base/bind.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -182,7 +184,7 @@ scoped_ptr<CastExtensionSession> CastExtensionSession::Create( !cast_extension_session->InitializePeerConnection()) { return nullptr; } - return cast_extension_session.Pass(); + return cast_extension_session; } void CastExtensionSession::OnCreateSessionDescription( @@ -236,7 +238,7 @@ void CastExtensionSession::OnCreateVideoCapturer( if (received_offer_) { has_grabbed_capturer_ = true; - if (SetupVideoStream(capturer->Pass())) { + if (SetupVideoStream(std::move(*capturer))) { peer_connection_->CreateAnswer(create_session_desc_observer_, nullptr); } else { has_grabbed_capturer_ = false; @@ -528,7 +530,7 @@ bool CastExtensionSession::SetupVideoStream( } scoped_ptr<WebrtcVideoCapturerAdapter> video_capturer_adapter( - new WebrtcVideoCapturerAdapter(desktop_capturer.Pass())); + new WebrtcVideoCapturerAdapter(std::move(desktop_capturer))); // Set video stream constraints. webrtc::FakeConstraints video_constraints; diff --git a/remoting/host/chromeos/aura_desktop_capturer.cc b/remoting/host/chromeos/aura_desktop_capturer.cc index 02b960d..dbaea58 100644 --- a/remoting/host/chromeos/aura_desktop_capturer.cc +++ b/remoting/host/chromeos/aura_desktop_capturer.cc @@ -4,6 +4,8 @@ #include "remoting/host/chromeos/aura_desktop_capturer.h" +#include <utility> + #include "base/bind.h" #include "cc/output/copy_output_request.h" #include "cc/output/copy_output_result.h" @@ -49,7 +51,7 @@ void AuraDesktopCapturer::Capture(const webrtc::DesktopRegion&) { gfx::Rect window_rect(desktop_window_->bounds().size()); request->set_area(window_rect); - desktop_window_->layer()->RequestCopyOfOutput(request.Pass()); + desktop_window_->layer()->RequestCopyOfOutput(std::move(request)); } void AuraDesktopCapturer::OnFrameCaptured( @@ -64,7 +66,7 @@ void AuraDesktopCapturer::OnFrameCaptured( scoped_ptr<SkBitmap> bitmap = result->TakeBitmap(); scoped_ptr<webrtc::DesktopFrame> frame( - SkiaBitmapDesktopFrame::Create(bitmap.Pass())); + SkiaBitmapDesktopFrame::Create(std::move(bitmap))); // |VideoFramePump| will not encode the frame if |updated_region| is empty. const webrtc::DesktopRect& rect = webrtc::DesktopRect::MakeWH( diff --git a/remoting/host/chromeos/aura_desktop_capturer_unittest.cc b/remoting/host/chromeos/aura_desktop_capturer_unittest.cc index a7c0f4a..89f91b6 100644 --- a/remoting/host/chromeos/aura_desktop_capturer_unittest.cc +++ b/remoting/host/chromeos/aura_desktop_capturer_unittest.cc @@ -7,6 +7,8 @@ #include <stddef.h> #include <stdint.h> +#include <utility> + #include "cc/output/copy_output_result.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -54,9 +56,8 @@ class AuraDesktopCapturerTest : public testing::Test, SkImageInfo::Make(3, 4, kBGRA_8888_SkColorType, kPremul_SkAlphaType); bitmap->installPixels(info, const_cast<unsigned char*>(frame_data), 12); - scoped_ptr<cc::CopyOutputResult> output = - cc::CopyOutputResult::CreateBitmapResult(bitmap.Pass()); - capturer_->OnFrameCaptured(output.Pass()); + capturer_->OnFrameCaptured( + cc::CopyOutputResult::CreateBitmapResult(std::move(bitmap))); } scoped_ptr<AuraDesktopCapturer> capturer_; diff --git a/remoting/host/chromeos/clipboard_aura.cc b/remoting/host/chromeos/clipboard_aura.cc index 3933c95..ef0438b 100644 --- a/remoting/host/chromeos/clipboard_aura.cc +++ b/remoting/host/chromeos/clipboard_aura.cc @@ -4,6 +4,8 @@ #include "remoting/host/chromeos/clipboard_aura.h" +#include <utility> + #include "base/strings/utf_string_conversions.h" #include "remoting/base/constants.h" #include "remoting/proto/event.pb.h" @@ -33,7 +35,7 @@ void ClipboardAura::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { DCHECK(thread_checker_.CalledOnValidThread()); - client_clipboard_ = client_clipboard.Pass(); + client_clipboard_ = std::move(client_clipboard); // Aura doesn't provide a clipboard-changed notification. The only way to // detect clipboard changes is by polling. diff --git a/remoting/host/chromeos/mouse_cursor_monitor_aura.cc b/remoting/host/chromeos/mouse_cursor_monitor_aura.cc index f1120aa..ed7a0e0 100644 --- a/remoting/host/chromeos/mouse_cursor_monitor_aura.cc +++ b/remoting/host/chromeos/mouse_cursor_monitor_aura.cc @@ -4,6 +4,8 @@ #include "remoting/host/chromeos/mouse_cursor_monitor_aura.h" +#include <utility> + #include "ash/shell.h" #include "base/bind.h" #include "base/callback.h" @@ -95,7 +97,7 @@ void MouseCursorMonitorAura::NotifyCursorChanged(const ui::Cursor& cursor) { } scoped_ptr<webrtc::DesktopFrame> image( - SkiaBitmapDesktopFrame::Create(cursor_bitmap.Pass())); + SkiaBitmapDesktopFrame::Create(std::move(cursor_bitmap))); scoped_ptr<webrtc::MouseCursor> cursor_shape(new webrtc::MouseCursor( image.release(), webrtc::DesktopVector(cursor_hotspot.x(), cursor_hotspot.y()))); diff --git a/remoting/host/chromeos/skia_bitmap_desktop_frame.cc b/remoting/host/chromeos/skia_bitmap_desktop_frame.cc index 6711b25..dfd9b10 100644 --- a/remoting/host/chromeos/skia_bitmap_desktop_frame.cc +++ b/remoting/host/chromeos/skia_bitmap_desktop_frame.cc @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "remoting/host/chromeos/skia_bitmap_desktop_frame.h" + #include <stddef.h> +#include <utility> + #include "base/logging.h" -#include "remoting/host/chromeos/skia_bitmap_desktop_frame.h" namespace remoting { @@ -23,7 +26,7 @@ SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create( const size_t row_bytes = bitmap->rowBytes(); SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame( - size, row_bytes, bitmap_data, bitmap.Pass()); + size, row_bytes, bitmap_data, std::move(bitmap)); return result; } @@ -32,10 +35,8 @@ SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size, int stride, uint8_t* data, scoped_ptr<SkBitmap> bitmap) - : DesktopFrame(size, stride, data, nullptr), bitmap_(bitmap.Pass()) { -} + : DesktopFrame(size, stride, data, nullptr), bitmap_(std::move(bitmap)) {} -SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() { -} +SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() {} } // namespace remoting diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 0b18314..3fdfaaa 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -7,6 +7,7 @@ #include <stddef.h> #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -71,7 +72,7 @@ ChromotingHost::ChromotingHost( scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) : desktop_environment_factory_(desktop_environment_factory), - session_manager_(session_manager.Pass()), + session_manager_(std::move(session_manager)), audio_task_runner_(audio_task_runner), input_task_runner_(input_task_runner), video_capture_task_runner_(video_capture_task_runner), @@ -134,7 +135,7 @@ void ChromotingHost::AddExtension(scoped_ptr<HostExtension> extension) { void ChromotingHost::SetAuthenticatorFactory( scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory) { DCHECK(CalledOnValidThread()); - session_manager_->set_authenticator_factory(authenticator_factory.Pass()); + session_manager_->set_authenticator_factory(std::move(authenticator_factory)); } void ChromotingHost::SetEnableCurtaining(bool enable) { @@ -283,8 +284,8 @@ void ChromotingHost::OnIncomingSession( ClientSession* client = new ClientSession( this, audio_task_runner_, input_task_runner_, video_capture_task_runner_, video_encode_task_runner_, network_task_runner_, ui_task_runner_, - connection.Pass(), desktop_environment_factory_, max_session_duration_, - pairing_registry_, extensions_.get()); + std::move(connection), desktop_environment_factory_, + max_session_duration_, pairing_registry_, extensions_.get()); clients_.push_back(client); } diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index de03e60..fc77198 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "remoting/host/chromoting_host.h" + +#include <utility> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/memory/scoped_ptr.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/host/audio_capturer.h" -#include "remoting/host/chromoting_host.h" #include "remoting/host/chromoting_host_context.h" #include "remoting/host/fake_desktop_environment.h" #include "remoting/host/fake_mouse_cursor_monitor.h" @@ -121,23 +124,19 @@ class ChromotingHostTest : public testing::Test { // Helper method to pretend a client is connected to ChromotingHost. void SimulateClientConnection(int connection_index, bool authenticate, bool reject) { - scoped_ptr<protocol::ConnectionToClient> connection = - ((connection_index == 0) ? owned_connection1_ : owned_connection2_) - .Pass(); + scoped_ptr<protocol::ConnectionToClient> connection = std::move( + (connection_index == 0) ? owned_connection1_ : owned_connection2_); protocol::ConnectionToClient* connection_ptr = connection.get(); scoped_ptr<ClientSession> client(new ClientSession( host_.get(), - task_runner_, // Audio - task_runner_, // Input - task_runner_, // Video capture - task_runner_, // Video encode - task_runner_, // Network - task_runner_, // UI - connection.Pass(), - desktop_environment_factory_.get(), - base::TimeDelta(), - nullptr, - std::vector<HostExtension*>())); + task_runner_, // Audio + task_runner_, // Input + task_runner_, // Video capture + task_runner_, // Video encode + task_runner_, // Network + task_runner_, // UI + std::move(connection), desktop_environment_factory_.get(), + base::TimeDelta(), nullptr, std::vector<HostExtension*>())); ClientSession* client_ptr = client.get(); connection_ptr->set_host_stub(client.get()); diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 32d7adc..5ca5e41 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -5,6 +5,7 @@ #include "remoting/host/client_session.h" #include <algorithm> +#include <utility> #include "base/command_line.h" #include "base/single_thread_task_runner.h" @@ -75,7 +76,7 @@ ClientSession::ClientSession( scoped_refptr<protocol::PairingRegistry> pairing_registry, const std::vector<HostExtension*>& extensions) : event_handler_(event_handler), - connection_(connection.Pass()), + connection_(std::move(connection)), client_jid_(connection_->session()->jid()), desktop_environment_factory_(desktop_environment_factory), input_tracker_(&host_input_filter_), @@ -343,7 +344,7 @@ void ClientSession::OnConnectionChannelsConnected( CreateAudioEncoder(connection_->session()->config()); audio_pump_.reset(new AudioPump( audio_task_runner_, desktop_environment_->CreateAudioCapturer(), - audio_encoder.Pass(), connection_->audio_stub())); + std::move(audio_encoder), connection_->audio_stub())); } // Notify the event handler that all our channels are now connected. @@ -464,9 +465,9 @@ void ClientSession::ResetVideoPipeline() { // TODO(sergeyu): Move DesktopCapturerProxy creation to DesktopEnvironment. // When using IpcDesktopCapturer the capture thread is not useful. scoped_ptr<webrtc::DesktopCapturer> capturer_proxy(new DesktopCapturerProxy( - video_capture_task_runner_, video_capturer.Pass())); + video_capture_task_runner_, std::move(video_capturer))); - video_stream_ = connection_->StartVideoStream(capturer_proxy.Pass()); + video_stream_ = connection_->StartVideoStream(std::move(capturer_proxy)); video_stream_->SetSizeCallback( base::Bind(&ClientSession::OnScreenSizeChanged, base::Unretained(this))); diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc index 45ad65b..dade472 100644 --- a/remoting/host/client_session_unittest.cc +++ b/remoting/host/client_session_unittest.cc @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "remoting/host/client_session.h" + #include <stdint.h> #include <algorithm> #include <string> +#include <utility> #include <vector> #include "base/message_loop/message_loop.h" @@ -16,7 +19,6 @@ #include "remoting/base/auto_thread_task_runner.h" #include "remoting/base/constants.h" #include "remoting/codec/video_encoder_verbatim.h" -#include "remoting/host/client_session.h" #include "remoting/host/desktop_environment.h" #include "remoting/host/fake_desktop_environment.h" #include "remoting/host/fake_host_extension.h" @@ -179,7 +181,7 @@ void ClientSessionTest::CreateClientSession() { // Mock protocol::ConnectionToClient APIs called directly by ClientSession. // HostStub is not touched by ClientSession, so we can safely pass nullptr. scoped_ptr<protocol::FakeConnectionToClient> connection( - new protocol::FakeConnectionToClient(session.Pass())); + new protocol::FakeConnectionToClient(std::move(session))); connection->set_client_stub(&client_stub_); connection_ = connection.get(); @@ -191,11 +193,8 @@ void ClientSessionTest::CreateClientSession() { task_runner_, // Encode thread. task_runner_, // Network thread. task_runner_, // UI thread. - connection.Pass(), - desktop_environment_factory_.get(), - base::TimeDelta(), - nullptr, - extensions_)); + std::move(connection), desktop_environment_factory_.get(), + base::TimeDelta(), nullptr, extensions_)); } void ClientSessionTest::ConnectClientSession() { diff --git a/remoting/host/daemon_process_win.cc b/remoting/host/daemon_process_win.cc index e290857..6d651ac 100644 --- a/remoting/host/daemon_process_win.cc +++ b/remoting/host/daemon_process_win.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/base_switches.h" #include "base/bind.h" #include "base/bind_helpers.h" @@ -229,8 +231,8 @@ void DaemonProcessWin::LaunchNetworkProcess() { kCopiedSwitchNames, arraysize(kCopiedSwitchNames)); scoped_ptr<UnprivilegedProcessDelegate> delegate( - new UnprivilegedProcessDelegate(io_task_runner(), target.Pass())); - network_launcher_.reset(new WorkerProcessLauncher(delegate.Pass(), this)); + new UnprivilegedProcessDelegate(io_task_runner(), std::move(target))); + network_launcher_.reset(new WorkerProcessLauncher(std::move(delegate), this)); } scoped_ptr<DaemonProcess> DaemonProcess::Create( @@ -241,7 +243,7 @@ scoped_ptr<DaemonProcess> DaemonProcess::Create( new DaemonProcessWin(caller_task_runner, io_task_runner, stopped_callback)); daemon_process->Initialize(); - return daemon_process.Pass(); + return std::move(daemon_process); } void DaemonProcessWin::DisableAutoStart() { diff --git a/remoting/host/desktop_capturer_proxy.cc b/remoting/host/desktop_capturer_proxy.cc index ae08870..048f077 100644 --- a/remoting/host/desktop_capturer_proxy.cc +++ b/remoting/host/desktop_capturer_proxy.cc @@ -6,6 +6,8 @@ #include <stddef.h> +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/macros.h" @@ -47,7 +49,7 @@ DesktopCapturerProxy::Core::Core( scoped_ptr<webrtc::DesktopCapturer> capturer) : proxy_(proxy), caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), - capturer_(capturer.Pass()) { + capturer_(std::move(capturer)) { thread_checker_.DetachFromThread(); } @@ -87,10 +89,9 @@ void DesktopCapturerProxy::Core::OnCaptureCompleted( DesktopCapturerProxy::DesktopCapturerProxy( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_ptr<webrtc::DesktopCapturer> capturer) - : capture_task_runner_(capture_task_runner), - weak_factory_(this) { + : capture_task_runner_(capture_task_runner), weak_factory_(this) { core_.reset(new Core(weak_factory_.GetWeakPtr(), capture_task_runner, - capturer.Pass())); + std::move(capturer))); } void DesktopCapturerProxy::Start(Callback* callback) { diff --git a/remoting/host/desktop_process.cc b/remoting/host/desktop_process.cc index 50d0467..b74c94d 100644 --- a/remoting/host/desktop_process.cc +++ b/remoting/host/desktop_process.cc @@ -7,6 +7,8 @@ #include "remoting/host/desktop_process.h" +#include <utility> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/debug/alias.h" @@ -96,7 +98,7 @@ bool DesktopProcess::Start( DCHECK(!desktop_environment_factory_); DCHECK(desktop_environment_factory); - desktop_environment_factory_ = desktop_environment_factory.Pass(); + desktop_environment_factory_ = std::move(desktop_environment_factory); // Launch the audio capturing thread. scoped_refptr<AutoThreadTaskRunner> audio_task_runner; diff --git a/remoting/host/desktop_process_main.cc b/remoting/host/desktop_process_main.cc index b17554c..95242c9 100644 --- a/remoting/host/desktop_process_main.cc +++ b/remoting/host/desktop_process_main.cc @@ -5,6 +5,8 @@ // This file implements the Windows service controlling Me2Me host processes // running within user sessions. +#include <utility> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" @@ -64,7 +66,7 @@ int DesktopProcessMain() { ui_task_runner)); #endif // !defined(OS_WIN) - if (!desktop_process.Start(desktop_environment_factory.Pass())) + if (!desktop_process.Start(std::move(desktop_environment_factory))) return kInitializationFailed; // Run the UI message loop. diff --git a/remoting/host/desktop_process_unittest.cc b/remoting/host/desktop_process_unittest.cc index 317ffc4..55aac14 100644 --- a/remoting/host/desktop_process_unittest.cc +++ b/remoting/host/desktop_process_unittest.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/location.h" @@ -264,7 +266,7 @@ void DesktopProcessTest::RunDesktopProcess() { .WillRepeatedly(Return(false)); DesktopProcess desktop_process(ui_task_runner, io_task_runner_, channel_name); - EXPECT_TRUE(desktop_process.Start(desktop_environment_factory.Pass())); + EXPECT_TRUE(desktop_process.Start(std::move(desktop_environment_factory))); ui_task_runner = nullptr; run_loop.Run(); diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc index 68fad4f..add8b70 100644 --- a/remoting/host/desktop_session_agent.cc +++ b/remoting/host/desktop_session_agent.cc @@ -4,6 +4,8 @@ #include "remoting/host/desktop_session_agent.h" +#include <utility> + #include "base/files/file_util.h" #include "base/logging.h" #include "base/macros.h" @@ -86,7 +88,8 @@ class DesktopSessionAgent::SharedBuffer : public webrtc::SharedMemory { if (!memory->CreateAndMapAnonymous(size)) return nullptr; #endif // defined(OS_MACOSX) && !defined(OS_IOS) - return make_scoped_ptr(new SharedBuffer(agent, memory.Pass(), size, id)); + return make_scoped_ptr( + new SharedBuffer(agent, std::move(memory), size, id)); } ~SharedBuffer() override { agent_->OnSharedBufferDeleted(id()); } @@ -100,7 +103,7 @@ class DesktopSessionAgent::SharedBuffer : public webrtc::SharedMemory { int id) : SharedMemory(memory->memory(), size, 0, id), agent_(agent), - shared_memory_(memory.Pass()) {} + shared_memory_(std::move(memory)) {} DesktopSessionAgent* agent_; scoped_ptr<base::SharedMemory> shared_memory_; @@ -296,7 +299,7 @@ void DesktopSessionAgent::OnStartSessionAgent( // Start the input injector. scoped_ptr<protocol::ClipboardStub> clipboard_stub( new DesktopSesssionClipboardStub(this)); - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); // Start the audio capturer. if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc index 19b5eb9..1cedfd5 100644 --- a/remoting/host/desktop_session_proxy.cc +++ b/remoting/host/desktop_session_proxy.cc @@ -6,6 +6,8 @@ #include <stddef.h> +#include <utility> + #include "base/compiler_specific.h" #include "base/logging.h" #include "base/macros.h" @@ -229,7 +231,7 @@ bool DesktopSessionProxy::AttachToDesktop( if (!client_session_control_.get()) return false; - desktop_process_ = desktop_process.Pass(); + desktop_process_ = std::move(desktop_process); #if defined(OS_WIN) // On Windows: |desktop_process| is a valid handle, but |desktop_pipe| needs @@ -403,7 +405,7 @@ void DesktopSessionProxy::StartInputInjector( scoped_ptr<protocol::ClipboardStub> client_clipboard) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); - client_clipboard_ = client_clipboard.Pass(); + client_clipboard_ = std::move(client_clipboard); } void DesktopSessionProxy::SetScreenResolution( @@ -522,7 +524,7 @@ void DesktopSessionProxy::OnCaptureCompleted( } --pending_capture_frame_requests_; - PostCaptureCompleted(frame.Pass()); + PostCaptureCompleted(std::move(frame)); } void DesktopSessionProxy::OnMouseCursor( diff --git a/remoting/host/desktop_session_win.cc b/remoting/host/desktop_session_win.cc index f973546..3001a13 100644 --- a/remoting/host/desktop_session_win.cc +++ b/remoting/host/desktop_session_win.cc @@ -5,7 +5,9 @@ #include "remoting/host/desktop_session_win.h" #include <sddl.h> + #include <limits> +#include <utility> #include "base/base_switches.h" #include "base/command_line.h" @@ -369,11 +371,9 @@ scoped_ptr<DesktopSession> DesktopSessionWin::CreateForConsole( DaemonProcess* daemon_process, int id, const ScreenResolution& resolution) { - scoped_ptr<ConsoleSession> session(new ConsoleSession( + return make_scoped_ptr(new ConsoleSession( caller_task_runner, io_task_runner, daemon_process, id, HostService::GetInstance())); - - return session.Pass(); } // static @@ -389,7 +389,7 @@ scoped_ptr<DesktopSession> DesktopSessionWin::CreateForVirtualTerminal( if (!session->Initialize(resolution)) return nullptr; - return session.Pass(); + return std::move(session); } DesktopSessionWin::DesktopSessionWin( @@ -537,19 +537,16 @@ void DesktopSessionWin::OnSessionAttached(uint32_t session_id) { kCopiedSwitchNames, arraysize(kCopiedSwitchNames)); // Create a delegate capable of launching a process in a different session. - scoped_ptr<WtsSessionProcessDelegate> delegate( - new WtsSessionProcessDelegate(io_task_runner_, - target.Pass(), - launch_elevated, - base::WideToUTF8( - kDaemonIpcSecurityDescriptor))); + scoped_ptr<WtsSessionProcessDelegate> delegate(new WtsSessionProcessDelegate( + io_task_runner_, std::move(target), launch_elevated, + base::WideToUTF8(kDaemonIpcSecurityDescriptor))); if (!delegate->Initialize(session_id)) { TerminateSession(); return; } // Create a launcher for the desktop process, using the per-session delegate. - launcher_.reset(new WorkerProcessLauncher(delegate.Pass(), this)); + launcher_.reset(new WorkerProcessLauncher(std::move(delegate), this)); } void DesktopSessionWin::OnSessionDetached() { diff --git a/remoting/host/desktop_shape_tracker_win.cc b/remoting/host/desktop_shape_tracker_win.cc index a98515e..547d9e3 100644 --- a/remoting/host/desktop_shape_tracker_win.cc +++ b/remoting/host/desktop_shape_tracker_win.cc @@ -68,7 +68,7 @@ void DesktopShapeTrackerWin::RefreshDesktopShape() { // If the shape has changed, refresh |desktop_shape_|. if (!EqualRgn(shape_data->desktop_region.get(), old_desktop_region_.get())) { - old_desktop_region_ = shape_data->desktop_region.Pass(); + old_desktop_region_ = std::move(shape_data->desktop_region); // Determine the size of output buffer required to receive the region. DWORD bytes_size = GetRegionData(old_desktop_region_.get(), 0, nullptr); diff --git a/remoting/host/fake_desktop_environment.cc b/remoting/host/fake_desktop_environment.cc index ed30c06..1d94b19 100644 --- a/remoting/host/fake_desktop_environment.cc +++ b/remoting/host/fake_desktop_environment.cc @@ -4,6 +4,8 @@ #include "remoting/host/fake_desktop_environment.h" +#include <utility> + #include "remoting/host/audio_capturer.h" #include "remoting/host/gnubby_auth_handler.h" #include "remoting/host/input_injector.h" @@ -64,7 +66,7 @@ scoped_ptr<AudioCapturer> FakeDesktopEnvironment::CreateAudioCapturer() { scoped_ptr<InputInjector> FakeDesktopEnvironment::CreateInputInjector() { scoped_ptr<FakeInputInjector> result(new FakeInputInjector()); last_input_injector_ = result->AsWeakPtr(); - return result.Pass(); + return std::move(result); } scoped_ptr<ScreenControls> FakeDesktopEnvironment::CreateScreenControls() { @@ -77,7 +79,7 @@ FakeDesktopEnvironment::CreateVideoCapturer() { new protocol::FakeDesktopCapturer()); if (!frame_generator_.is_null()) result->set_frame_generator(frame_generator_); - return result.Pass(); + return std::move(result); } scoped_ptr<webrtc::MouseCursorMonitor> @@ -105,7 +107,7 @@ scoped_ptr<DesktopEnvironment> FakeDesktopEnvironmentFactory::Create( scoped_ptr<FakeDesktopEnvironment> result(new FakeDesktopEnvironment()); result->set_frame_generator(frame_generator_); last_desktop_environment_ = result->AsWeakPtr(); - return result.Pass(); + return std::move(result); } void FakeDesktopEnvironmentFactory::SetEnableCurtaining(bool enable) {} diff --git a/remoting/host/fake_host_extension.cc b/remoting/host/fake_host_extension.cc index 73464c1..3317b770 100644 --- a/remoting/host/fake_host_extension.cc +++ b/remoting/host/fake_host_extension.cc @@ -93,8 +93,7 @@ scoped_ptr<HostExtensionSession> FakeExtension::CreateExtensionSession( protocol::ClientStub* client_stub) { DCHECK(!was_instantiated()); was_instantiated_ = true; - scoped_ptr<HostExtensionSession> session(new Session(this, message_type_)); - return session.Pass(); + return make_scoped_ptr(new Session(this, message_type_)); } } // namespace remoting diff --git a/remoting/host/gcd_rest_client.cc b/remoting/host/gcd_rest_client.cc index a6dfbd4..d985538 100644 --- a/remoting/host/gcd_rest_client.cc +++ b/remoting/host/gcd_rest_client.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/json/json_writer.h" @@ -27,11 +29,9 @@ GcdRestClient::GcdRestClient(const std::string& gcd_base_url, gcd_device_id_(gcd_device_id), url_request_context_getter_(url_request_context_getter), token_getter_(token_getter), - clock_(new base::DefaultClock) { -} + clock_(new base::DefaultClock) {} -GcdRestClient::~GcdRestClient() { -} +GcdRestClient::~GcdRestClient() {} void GcdRestClient::PatchState( scoped_ptr<base::DictionaryValue> patch_details, @@ -59,9 +59,9 @@ void GcdRestClient::PatchState( scoped_ptr<base::ListValue> patch_list(new base::ListValue); base::DictionaryValue* patch_item = new base::DictionaryValue; patch_list->Append(patch_item); - patch_item->Set("patch", patch_details.Pass()); + patch_item->Set("patch", std::move(patch_details)); patch_item->SetDouble("timeMs", now); - patch_dict->Set("patches", patch_list.Pass()); + patch_dict->Set("patches", std::move(patch_list)); // Stringify the message. std::string patch_string; @@ -88,6 +88,10 @@ void GcdRestClient::PatchState( base::Bind(&GcdRestClient::OnTokenReceived, base::Unretained(this))); } +void GcdRestClient::SetClockForTest(scoped_ptr<base::Clock> clock) { + clock_ = std::move(clock); +} + void GcdRestClient::OnTokenReceived(OAuthTokenGetter::Status status, const std::string& user_email, const std::string& access_token) { diff --git a/remoting/host/gcd_rest_client.h b/remoting/host/gcd_rest_client.h index 52c49e8..23263f2 100644 --- a/remoting/host/gcd_rest_client.h +++ b/remoting/host/gcd_rest_client.h @@ -53,7 +53,7 @@ class GcdRestClient : public net::URLFetcherDelegate { void PatchState(scoped_ptr<base::DictionaryValue> patch_details, const GcdRestClient::ResultCallback& callback); - void SetClockForTest(scoped_ptr<base::Clock> clock) { clock_ = clock.Pass(); } + void SetClockForTest(scoped_ptr<base::Clock> clock); private: void OnTokenReceived(OAuthTokenGetter::Status status, diff --git a/remoting/host/gcd_rest_client_unittest.cc b/remoting/host/gcd_rest_client_unittest.cc index 9e61950..cfdbd9e 100644 --- a/remoting/host/gcd_rest_client_unittest.cc +++ b/remoting/host/gcd_rest_client_unittest.cc @@ -28,7 +28,7 @@ class GcdRestClientTest : public testing::Test { scoped_ptr<base::DictionaryValue> MakePatchDetails(int id) { scoped_ptr<base::DictionaryValue> patch_details(new base::DictionaryValue); patch_details->SetInteger("id", id); - return patch_details.Pass(); + return patch_details; } void CreateClient(OAuthTokenGetter* token_getter = nullptr) { @@ -55,7 +55,7 @@ TEST_F(GcdRestClientTest, NetworkErrorGettingToken) { FakeOAuthTokenGetter token_getter(OAuthTokenGetter::NETWORK_ERROR, "", ""); CreateClient(&token_getter); - client_->PatchState(MakePatchDetails(0).Pass(), + client_->PatchState(MakePatchDetails(0), base::Bind(&GcdRestClientTest::OnRequestComplete, base::Unretained(this))); base::RunLoop().RunUntilIdle(); @@ -68,7 +68,7 @@ TEST_F(GcdRestClientTest, AuthErrorGettingToken) { FakeOAuthTokenGetter token_getter(OAuthTokenGetter::AUTH_ERROR, "", ""); CreateClient(&token_getter); - client_->PatchState(MakePatchDetails(0).Pass(), + client_->PatchState(MakePatchDetails(0), base::Bind(&GcdRestClientTest::OnRequestComplete, base::Unretained(this))); base::RunLoop().RunUntilIdle(); @@ -80,7 +80,7 @@ TEST_F(GcdRestClientTest, AuthErrorGettingToken) { TEST_F(GcdRestClientTest, NetworkErrorOnPost) { CreateClient(); - client_->PatchState(MakePatchDetails(0).Pass(), + client_->PatchState(MakePatchDetails(0), base::Bind(&GcdRestClientTest::OnRequestComplete, base::Unretained(this))); net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); @@ -97,7 +97,7 @@ TEST_F(GcdRestClientTest, NetworkErrorOnPost) { TEST_F(GcdRestClientTest, OtherErrorOnPost) { CreateClient(); - client_->PatchState(MakePatchDetails(0).Pass(), + client_->PatchState(MakePatchDetails(0), base::Bind(&GcdRestClientTest::OnRequestComplete, base::Unretained(this))); net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); @@ -114,7 +114,7 @@ TEST_F(GcdRestClientTest, OtherErrorOnPost) { TEST_F(GcdRestClientTest, NoSuchHost) { CreateClient(); - client_->PatchState(MakePatchDetails(0).Pass(), + client_->PatchState(MakePatchDetails(0), base::Bind(&GcdRestClientTest::OnRequestComplete, base::Unretained(this))); net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); @@ -131,7 +131,7 @@ TEST_F(GcdRestClientTest, NoSuchHost) { TEST_F(GcdRestClientTest, Succeed) { CreateClient(); - client_->PatchState(MakePatchDetails(0).Pass(), + client_->PatchState(MakePatchDetails(0), base::Bind(&GcdRestClientTest::OnRequestComplete, base::Unretained(this))); net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); diff --git a/remoting/host/gcd_state_updater.cc b/remoting/host/gcd_state_updater.cc index 5b9b578..c6cc22a 100644 --- a/remoting/host/gcd_state_updater.cc +++ b/remoting/host/gcd_state_updater.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/callback_helpers.h" #include "base/strings/stringize_macros.h" #include "base/time/time.h" @@ -30,7 +32,7 @@ GcdStateUpdater::GcdStateUpdater( : on_update_successful_callback_(on_update_successful_callback), on_unknown_host_id_error_(on_unknown_host_id_error), signal_strategy_(signal_strategy), - gcd_rest_client_(gcd_rest_client.Pass()) { + gcd_rest_client_(std::move(gcd_rest_client)) { DCHECK(signal_strategy_); DCHECK(thread_checker_.CalledOnValidThread()); @@ -116,11 +118,11 @@ void GcdStateUpdater::MaybeSendStateUpdate() { pending_request_jid_ = signal_strategy_->GetLocalJid(); base_state->SetString("_jabberId", pending_request_jid_); base_state->SetString("_hostVersion", STRINGIZE(VERSION)); - patch->Set("base", base_state.Pass()); + patch->Set("base", std::move(base_state)); // Send the update to GCD. gcd_rest_client_->PatchState( - patch.Pass(), + std::move(patch), base::Bind(&GcdStateUpdater::OnPatchStateResult, base::Unretained(this))); } diff --git a/remoting/host/gcd_state_updater_unittest.cc b/remoting/host/gcd_state_updater_unittest.cc index 3411a81..2496341 100644 --- a/remoting/host/gcd_state_updater_unittest.cc +++ b/remoting/host/gcd_state_updater_unittest.cc @@ -5,6 +5,7 @@ #include "remoting/host/gcd_state_updater.h" #include <algorithm> +#include <utility> #include <vector> #include "base/strings/stringize_macros.h" @@ -62,7 +63,7 @@ TEST_F(GcdStateUpdaterTest, Success) { scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), - &signal_strategy_, rest_client_.Pass())); + &signal_strategy_, std::move(rest_client_))); signal_strategy_.Connect(); task_runner_->RunUntilIdle(); @@ -86,7 +87,7 @@ TEST_F(GcdStateUpdaterTest, QueuedRequests) { scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), - &signal_strategy_, rest_client_.Pass())); + &signal_strategy_, std::move(rest_client_))); // Connect, then re-connect with a different JID while the status // update for the first connection is pending. @@ -130,7 +131,7 @@ TEST_F(GcdStateUpdaterTest, Retry) { scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), - &signal_strategy_, rest_client_.Pass())); + &signal_strategy_, std::move(rest_client_))); signal_strategy_.Connect(); task_runner_->RunUntilIdle(); @@ -155,7 +156,7 @@ TEST_F(GcdStateUpdaterTest, UnknownHost) { scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), - &signal_strategy_, rest_client_.Pass())); + &signal_strategy_, std::move(rest_client_))); signal_strategy_.Connect(); task_runner_->RunUntilIdle(); diff --git a/remoting/host/gnubby_auth_handler_posix.cc b/remoting/host/gnubby_auth_handler_posix.cc index a3d67db..5592b3a 100644 --- a/remoting/host/gnubby_auth_handler_posix.cc +++ b/remoting/host/gnubby_auth_handler_posix.cc @@ -210,7 +210,7 @@ void GnubbyAuthHandlerPosix::OnAccepted(int result) { int connection_id = ++last_connection_id_; GnubbySocket* socket = - new GnubbySocket(accept_socket_.Pass(), request_timeout_, + new GnubbySocket(std::move(accept_socket_), request_timeout_, base::Bind(&GnubbyAuthHandlerPosix::RequestTimedOut, base::Unretained(this), connection_id)); active_sockets_[connection_id] = socket; diff --git a/remoting/host/gnubby_socket.cc b/remoting/host/gnubby_socket.cc index 21dad81..82fe34a 100644 --- a/remoting/host/gnubby_socket.cc +++ b/remoting/host/gnubby_socket.cc @@ -4,6 +4,8 @@ #include "remoting/host/gnubby_socket.h" +#include <utility> + #include "base/callback_helpers.h" #include "base/macros.h" #include "base/timer/timer.h" @@ -27,7 +29,7 @@ const char kSshError[] = {0x05}; GnubbySocket::GnubbySocket(scoped_ptr<net::StreamSocket> socket, const base::TimeDelta& timeout, const base::Closure& timeout_callback) - : socket_(socket.Pass()), + : socket_(std::move(socket)), read_completed_(false), read_buffer_(new net::IOBufferWithSize(kRequestReadBufferLength)) { timer_.reset(new base::Timer(false, false)); @@ -60,7 +62,7 @@ void GnubbySocket::SendResponse(const std::string& response_data) { scoped_ptr<std::string> response( new std::string(response_length_string + response_data)); write_buffer_ = new net::DrainableIOBuffer( - new net::StringIOBuffer(response.Pass()), response_len); + new net::StringIOBuffer(std::move(response)), response_len); DoWrite(); } diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc index 5b75c4a..079a393 100644 --- a/remoting/host/heartbeat_sender.cc +++ b/remoting/host/heartbeat_sender.cc @@ -342,7 +342,7 @@ scoped_ptr<XmlElement> HeartbeatSender::CreateHeartbeatMessage() { AddHostFieldsToLogEntry(log_entry.get()); log->AddElement(log_entry->ToStanza().release()); heartbeat->AddElement(log.release()); - return heartbeat.Pass(); + return heartbeat; } scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() { @@ -354,7 +354,7 @@ scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() { std::string signature(host_key_pair_->SignMessage(message)); signature_tag->AddText(signature); - return signature_tag.Pass(); + return signature_tag; } } // namespace remoting diff --git a/remoting/host/host_change_notification_listener_unittest.cc b/remoting/host/host_change_notification_listener_unittest.cc index 0d3f231..bdaff5b 100644 --- a/remoting/host/host_change_notification_listener_unittest.cc +++ b/remoting/host/host_change_notification_listener_unittest.cc @@ -78,7 +78,7 @@ class HostChangeNotificationListenerTest : public testing::Test { stanza->AddElement(host_changed); stanza->AddAttr(buzz::QN_FROM, botJid); stanza->AddAttr(buzz::QN_TO, kTestJid); - return stanza.Pass(); + return stanza; } MockListener mock_listener_; diff --git a/remoting/host/host_config.cc b/remoting/host/host_config.cc index 872bb07..f464962 100644 --- a/remoting/host/host_config.cc +++ b/remoting/host/host_config.cc @@ -21,9 +21,7 @@ scoped_ptr<base::DictionaryValue> HostConfigFromJson( return nullptr; } - scoped_ptr<base::DictionaryValue> config( - static_cast<base::DictionaryValue*>(value.release())); - return config.Pass(); + return make_scoped_ptr(static_cast<base::DictionaryValue*>(value.release())); } std::string HostConfigToJson(const base::DictionaryValue& host_config) { diff --git a/remoting/host/host_window_proxy.cc b/remoting/host/host_window_proxy.cc index f539cfb..4fd0fae 100644 --- a/remoting/host/host_window_proxy.cc +++ b/remoting/host/host_window_proxy.cc @@ -4,6 +4,8 @@ #include "remoting/host/host_window_proxy.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/logging.h" @@ -75,7 +77,7 @@ HostWindowProxy::HostWindowProxy( // Detach |host_window| from the calling thread so that |Core| could run it on // the |ui_task_runner_| thread. host_window->DetachFromThread(); - core_ = new Core(caller_task_runner, ui_task_runner, host_window.Pass()); + core_ = new Core(caller_task_runner, ui_task_runner, std::move(host_window)); } HostWindowProxy::~HostWindowProxy() { @@ -97,7 +99,7 @@ HostWindowProxy::Core::Core( scoped_ptr<HostWindow> host_window) : caller_task_runner_(caller_task_runner), ui_task_runner_(ui_task_runner), - host_window_(host_window.Pass()), + host_window_(std::move(host_window)), weak_factory_(this) { DCHECK(caller_task_runner->BelongsToCurrentThread()); } diff --git a/remoting/host/input_injector_chromeos.cc b/remoting/host/input_injector_chromeos.cc index 9f876b3..49b08e7 100644 --- a/remoting/host/input_injector_chromeos.cc +++ b/remoting/host/input_injector_chromeos.cc @@ -5,6 +5,7 @@ #include "remoting/host/input_injector_chromeos.h" #include <set> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -117,7 +118,7 @@ void InputInjectorChromeos::Core::Start( // Implemented by remoting::ClipboardAura. clipboard_ = Clipboard::Create(); - clipboard_->Start(client_clipboard.Pass()); + clipboard_->Start(std::move(client_clipboard)); point_transformer_.reset(new PointTransformer()); } diff --git a/remoting/host/input_injector_mac.cc b/remoting/host/input_injector_mac.cc index 63bf04c..fc2ba1b 100644 --- a/remoting/host/input_injector_mac.cc +++ b/remoting/host/input_injector_mac.cc @@ -8,7 +8,9 @@ #include <Carbon/Carbon.h> #include <IOKit/pwr_mgt/IOPMLib.h> #include <stdint.h> + #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/compiler_specific.h" @@ -154,7 +156,7 @@ void InputInjectorMac::InjectTouchEvent(const TouchEvent& event) { void InputInjectorMac::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { - core_->Start(client_clipboard.Pass()); + core_->Start(std::move(client_clipboard)); } InputInjectorMac::Core::Core( @@ -341,7 +343,7 @@ void InputInjectorMac::Core::Start( return; } - clipboard_->Start(client_clipboard.Pass()); + clipboard_->Start(std::move(client_clipboard)); } void InputInjectorMac::Core::Stop() { diff --git a/remoting/host/input_injector_win.cc b/remoting/host/input_injector_win.cc index 1810445..396b46b 100644 --- a/remoting/host/input_injector_win.cc +++ b/remoting/host/input_injector_win.cc @@ -4,8 +4,10 @@ #include "remoting/host/input_injector.h" -#include <windows.h> #include <stdint.h> +#include <windows.h> + +#include <utility> #include "base/bind.h" #include "base/compiler_specific.h" @@ -151,7 +153,7 @@ void InputInjectorWin::InjectTouchEvent(const TouchEvent& event) { void InputInjectorWin::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { - core_->Start(client_clipboard.Pass()); + core_->Start(std::move(client_clipboard)); } InputInjectorWin::Core::Core( @@ -222,7 +224,7 @@ void InputInjectorWin::Core::Start( return; } - clipboard_->Start(client_clipboard.Pass()); + clipboard_->Start(std::move(client_clipboard)); touch_injector_.Init(); } diff --git a/remoting/host/input_injector_x11.cc b/remoting/host/input_injector_x11.cc index 98ee434..030df3f 100644 --- a/remoting/host/input_injector_x11.cc +++ b/remoting/host/input_injector_x11.cc @@ -13,6 +13,7 @@ #undef Status // Xlib.h #defines this, which breaks protobuf headers. #include <set> +#include <utility> #include "base/bind.h" #include "base/compiler_specific.h" @@ -242,7 +243,7 @@ void InputInjectorX11::InjectTouchEvent(const TouchEvent& event) { void InputInjectorX11::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { - core_->Start(client_clipboard.Pass()); + core_->Start(std::move(client_clipboard)); } InputInjectorX11::Core::Core( @@ -629,7 +630,7 @@ void InputInjectorX11::Core::Start( InitMouseButtonMap(); - clipboard_->Start(client_clipboard.Pass()); + clipboard_->Start(std::move(client_clipboard)); } void InputInjectorX11::Core::Stop() { @@ -651,7 +652,7 @@ scoped_ptr<InputInjector> InputInjector::Create( new InputInjectorX11(main_task_runner)); if (!injector->Init()) return nullptr; - return injector.Pass(); + return std::move(injector); } // static diff --git a/remoting/host/ipc_audio_capturer.cc b/remoting/host/ipc_audio_capturer.cc index 5bc568d..3b6b95d 100644 --- a/remoting/host/ipc_audio_capturer.cc +++ b/remoting/host/ipc_audio_capturer.cc @@ -4,6 +4,8 @@ #include "remoting/host/ipc_audio_capturer.h" +#include <utility> + #include "remoting/host/desktop_session_proxy.h" #include "remoting/proto/audio.pb.h" @@ -28,7 +30,7 @@ bool IpcAudioCapturer::Start(const PacketCapturedCallback& callback) { } void IpcAudioCapturer::OnAudioPacket(scoped_ptr<AudioPacket> packet) { - callback_.Run(packet.Pass()); + callback_.Run(std::move(packet)); } } // namespace remoting diff --git a/remoting/host/ipc_desktop_environment.cc b/remoting/host/ipc_desktop_environment.cc index da7a529..6cbfb1a 100644 --- a/remoting/host/ipc_desktop_environment.cc +++ b/remoting/host/ipc_desktop_environment.cc @@ -200,7 +200,7 @@ void IpcDesktopEnvironmentFactory::OnDesktopSessionAgentAttached( ActiveConnectionsList::iterator i = active_connections_.find(terminal_id); if (i != active_connections_.end()) { i->second->DetachFromDesktop(); - i->second->AttachToDesktop(desktop_process.Pass(), desktop_pipe); + i->second->AttachToDesktop(std::move(desktop_process), desktop_pipe); } else { #if defined(OS_POSIX) DCHECK(desktop_pipe.auto_close); diff --git a/remoting/host/ipc_desktop_environment_unittest.cc b/remoting/host/ipc_desktop_environment_unittest.cc index 95261cb..a27bc70 100644 --- a/remoting/host/ipc_desktop_environment_unittest.cc +++ b/remoting/host/ipc_desktop_environment_unittest.cc @@ -4,6 +4,8 @@ #include <stdint.h> +#include <utility> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" @@ -417,7 +419,7 @@ void IpcDesktopEnvironmentTest::CreateDesktopProcess() { .Times(AnyNumber()) .WillRepeatedly(Return(false)); - EXPECT_TRUE(desktop_process_->Start(desktop_environment_factory.Pass())); + EXPECT_TRUE(desktop_process_->Start(std::move(desktop_environment_factory))); } void IpcDesktopEnvironmentTest::DestoyDesktopProcess() { @@ -462,7 +464,7 @@ TEST_F(IpcDesktopEnvironmentTest, Basic) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); // Run the message loop until the desktop is attached. setup_run_loop_->Run(); @@ -481,7 +483,7 @@ TEST_F(IpcDesktopEnvironmentTest, CapabilitiesNoTouch) { EXPECT_EQ("rateLimitResizeRequests", desktop_environment_->GetCapabilities()); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); // Run the message loop until the desktop is attached. setup_run_loop_->Run(); @@ -507,7 +509,7 @@ TEST_F(IpcDesktopEnvironmentTest, TouchEventsCapabilities) { desktop_environment_->GetCapabilities()); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); // Run the message loop until the desktop is attached. setup_run_loop_->Run(); @@ -524,7 +526,7 @@ TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. @@ -549,7 +551,7 @@ TEST_F(IpcDesktopEnvironmentTest, Reattach) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. @@ -578,7 +580,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. @@ -605,7 +607,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. @@ -632,7 +634,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. @@ -658,7 +660,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. @@ -685,7 +687,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. @@ -727,7 +729,7 @@ TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { .Times(0); // Start the input injector and screen capturer. - input_injector_->Start(clipboard_stub.Pass()); + input_injector_->Start(std::move(clipboard_stub)); video_capturer_->Start(&desktop_capturer_callback_); // Run the message loop until the desktop is attached. diff --git a/remoting/host/ipc_input_injector.cc b/remoting/host/ipc_input_injector.cc index 3a2132f..fb5fd09 100644 --- a/remoting/host/ipc_input_injector.cc +++ b/remoting/host/ipc_input_injector.cc @@ -4,6 +4,8 @@ #include "remoting/host/ipc_input_injector.h" +#include <utility> + #include "remoting/host/desktop_session_proxy.h" namespace remoting { @@ -39,7 +41,7 @@ void IpcInputInjector::InjectTouchEvent(const protocol::TouchEvent& event) { void IpcInputInjector::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { - desktop_session_proxy_->StartInputInjector(client_clipboard.Pass()); + desktop_session_proxy_->StartInputInjector(std::move(client_clipboard)); } } // namespace remoting diff --git a/remoting/host/ipc_util_win.cc b/remoting/host/ipc_util_win.cc index 22ac15a..d9952ef 100644 --- a/remoting/host/ipc_util_win.cc +++ b/remoting/host/ipc_util_win.cc @@ -4,6 +4,8 @@ #include "remoting/host/ipc_util.h" +#include <utility> + #include "base/files/file.h" #include "base/logging.h" #include "base/single_thread_task_runner.h" @@ -84,8 +86,8 @@ bool CreateConnectedIpcChannel( return false; } - *client_out = client.Pass(); - *server_out = server.Pass(); + *client_out = std::move(client); + *server_out = std::move(server); return true; } @@ -128,7 +130,7 @@ bool CreateIpcChannel( return false; } - *pipe_out = pipe.Pass(); + *pipe_out = std::move(pipe); return true; } diff --git a/remoting/host/it2me/it2me_confirmation_dialog_proxy.cc b/remoting/host/it2me/it2me_confirmation_dialog_proxy.cc index 00efc95..de00e67 100644 --- a/remoting/host/it2me/it2me_confirmation_dialog_proxy.cc +++ b/remoting/host/it2me/it2me_confirmation_dialog_proxy.cc @@ -4,6 +4,8 @@ #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/location.h" @@ -51,7 +53,7 @@ It2MeConfirmationDialogProxy::Core::Core( : ui_task_runner_(ui_task_runner), caller_task_runner_(caller_task_runner), parent_(parent), - dialog_(dialog.Pass()) { + dialog_(std::move(dialog)) { } It2MeConfirmationDialogProxy::Core::~Core() { @@ -78,7 +80,7 @@ It2MeConfirmationDialogProxy::It2MeConfirmationDialogProxy( scoped_ptr<It2MeConfirmationDialog> dialog) : weak_factory_(this) { core_.reset(new Core(ui_task_runner, base::ThreadTaskRunnerHandle::Get(), - weak_factory_.GetWeakPtr(), dialog.Pass())); + weak_factory_.GetWeakPtr(), std::move(dialog))); } It2MeConfirmationDialogProxy::~It2MeConfirmationDialogProxy() { diff --git a/remoting/host/it2me/it2me_host.cc b/remoting/host/it2me/it2me_host.cc index 1fea411..426c06b 100644 --- a/remoting/host/it2me/it2me_host.cc +++ b/remoting/host/it2me/it2me_host.cc @@ -6,6 +6,8 @@ #include <stddef.h> +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/strings/string_util.h" @@ -50,15 +52,15 @@ It2MeHost::It2MeHost( base::WeakPtr<It2MeHost::Observer> observer, const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, const std::string& directory_bot_jid) - : host_context_(host_context.Pass()), + : host_context_(std::move(host_context)), task_runner_(host_context_->ui_task_runner()), observer_(observer), xmpp_server_config_(xmpp_server_config), directory_bot_jid_(directory_bot_jid), state_(kDisconnected), failed_login_attempts_(0), - policy_watcher_(policy_watcher.Pass()), - confirmation_dialog_factory_(confirmation_dialog_factory.Pass()), + policy_watcher_(std::move(policy_watcher)), + confirmation_dialog_factory_(std::move(confirmation_dialog_factory)), nat_traversal_enabled_(false), policy_received_(false) { DCHECK(task_runner_->BelongsToCurrentThread()); @@ -145,7 +147,7 @@ void It2MeHost::ShowConfirmationPrompt() { confirmation_dialog_proxy_.reset( new It2MeConfirmationDialogProxy(host_context_->ui_task_runner(), - confirmation_dialog.Pass())); + std::move(confirmation_dialog))); confirmation_dialog_proxy_->Show( base::Bind(&It2MeHost::OnConfirmationResult, base::Unretained(this))); @@ -217,8 +219,8 @@ void It2MeHost::FinishConnect() { base::Unretained(this)))); // Beyond this point nothing can fail, so save the config and request. - signal_strategy_ = signal_strategy.Pass(); - register_request_ = register_request.Pass(); + signal_strategy_ = std::move(signal_strategy); + register_request_ = std::move(register_request); // If NAT traversal is off then limit port range to allow firewall pin-holing. HOST_LOG << "NAT state: " << nat_traversal_enabled_; @@ -241,7 +243,7 @@ void It2MeHost::FinishConnect() { network_settings, protocol::TransportRole::SERVER))); scoped_ptr<protocol::SessionManager> session_manager( - new protocol::JingleSessionManager(transport_factory.Pass(), + new protocol::JingleSessionManager(std::move(transport_factory), signal_strategy.get())); scoped_ptr<protocol::CandidateSessionConfig> protocol_config = @@ -249,13 +251,12 @@ void It2MeHost::FinishConnect() { // Disable audio by default. // TODO(sergeyu): Add UI to enable it. protocol_config->DisableAudioChannel(); - session_manager->set_protocol_config(protocol_config.Pass()); + session_manager->set_protocol_config(std::move(protocol_config)); // Create the host. host_.reset(new ChromotingHost( - desktop_environment_factory_.get(), - session_manager.Pass(), host_context_->audio_task_runner(), - host_context_->input_task_runner(), + desktop_environment_factory_.get(), std::move(session_manager), + host_context_->audio_task_runner(), host_context_->input_task_runner(), host_context_->video_capture_task_runner(), host_context_->video_encode_task_runner(), host_context_->network_task_runner(), host_context_->ui_task_runner())); @@ -459,7 +460,7 @@ void It2MeHost::OnReceivedSupportID( scoped_ptr<protocol::AuthenticatorFactory> factory( new protocol::It2MeHostAuthenticatorFactory( local_certificate, host_key_pair_, access_code)); - host_->SetAuthenticatorFactory(factory.Pass()); + host_->SetAuthenticatorFactory(std::move(factory)); // Pass the Access Code to the script object before changing state. task_runner_->PostTask( @@ -492,9 +493,9 @@ scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( new It2MeConfirmationDialogFactory()); scoped_ptr<PolicyWatcher> policy_watcher = PolicyWatcher::Create(policy_service_, context->file_task_runner()); - return new It2MeHost(context.Pass(), policy_watcher.Pass(), - confirmation_dialog_factory.Pass(), - observer, xmpp_server_config, directory_bot_jid); + return new It2MeHost(std::move(context), std::move(policy_watcher), + std::move(confirmation_dialog_factory), observer, + xmpp_server_config, directory_bot_jid); } } // namespace remoting diff --git a/remoting/host/it2me/it2me_native_messaging_host.cc b/remoting/host/it2me/it2me_native_messaging_host.cc index ad171fd..294e23d 100644 --- a/remoting/host/it2me/it2me_native_messaging_host.cc +++ b/remoting/host/it2me/it2me_native_messaging_host.cc @@ -5,6 +5,7 @@ #include "remoting/host/it2me/it2me_native_messaging_host.h" #include <string> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -43,8 +44,8 @@ It2MeNativeMessagingHost::It2MeNativeMessagingHost( scoped_ptr<ChromotingHostContext> context, scoped_ptr<It2MeHostFactory> factory) : client_(nullptr), - host_context_(context.Pass()), - factory_(factory.Pass()), + host_context_(std::move(context)), + factory_(std::move(factory)), weak_factory_(this) { weak_ptr_ = weak_factory_.GetWeakPtr(); @@ -90,20 +91,20 @@ void It2MeNativeMessagingHost::OnMessage(const std::string& message) { std::string type; if (!message_dict->GetString("type", &type)) { - SendErrorAndExit(response.Pass(), "'type' not found in request."); + SendErrorAndExit(std::move(response), "'type' not found in request."); return; } response->SetString("type", type + "Response"); if (type == "hello") { - ProcessHello(*message_dict, response.Pass()); + ProcessHello(*message_dict, std::move(response)); } else if (type == "connect") { - ProcessConnect(*message_dict, response.Pass()); + ProcessConnect(*message_dict, std::move(response)); } else if (type == "disconnect") { - ProcessDisconnect(*message_dict, response.Pass()); + ProcessDisconnect(*message_dict, std::move(response)); } else { - SendErrorAndExit(response.Pass(), "Unsupported request type: " + type); + SendErrorAndExit(std::move(response), "Unsupported request type: " + type); } } @@ -137,7 +138,7 @@ void It2MeNativeMessagingHost::ProcessHello( scoped_ptr<base::ListValue> supported_features_list(new base::ListValue()); response->Set("supportedFeatures", supported_features_list.release()); - SendMessageToClient(response.Pass()); + SendMessageToClient(std::move(response)); } void It2MeNativeMessagingHost::ProcessConnect( @@ -146,7 +147,7 @@ void It2MeNativeMessagingHost::ProcessConnect( DCHECK(task_runner()->BelongsToCurrentThread()); if (it2me_host_.get()) { - SendErrorAndExit(response.Pass(), + SendErrorAndExit(std::move(response), "Connect can be called only when disconnected."); return; } @@ -154,13 +155,13 @@ void It2MeNativeMessagingHost::ProcessConnect( XmppSignalStrategy::XmppServerConfig xmpp_config = xmpp_server_config_; if (!message.GetString("userName", &xmpp_config.username)) { - SendErrorAndExit(response.Pass(), "'userName' not found in request."); + SendErrorAndExit(std::move(response), "'userName' not found in request."); return; } std::string auth_service_with_token; if (!message.GetString("authServiceWithToken", &auth_service_with_token)) { - SendErrorAndExit(response.Pass(), + SendErrorAndExit(std::move(response), "'authServiceWithToken' not found in request."); return; } @@ -171,8 +172,8 @@ void It2MeNativeMessagingHost::ProcessConnect( const char kOAuth2ServicePrefix[] = "oauth2:"; if (!base::StartsWith(auth_service_with_token, kOAuth2ServicePrefix, base::CompareCase::SENSITIVE)) { - SendErrorAndExit(response.Pass(), "Invalid 'authServiceWithToken': " + - auth_service_with_token); + SendErrorAndExit(std::move(response), "Invalid 'authServiceWithToken': " + + auth_service_with_token); return; } @@ -182,26 +183,26 @@ void It2MeNativeMessagingHost::ProcessConnect( #if !defined(NDEBUG) std::string address; if (!message.GetString("xmppServerAddress", &address)) { - SendErrorAndExit(response.Pass(), + SendErrorAndExit(std::move(response), "'xmppServerAddress' not found in request."); return; } - if (!net::ParseHostAndPort( - address, &xmpp_server_config_.host, &xmpp_server_config_.port)) { - SendErrorAndExit(response.Pass(), + if (!net::ParseHostAndPort(address, &xmpp_server_config_.host, + &xmpp_server_config_.port)) { + SendErrorAndExit(std::move(response), "Invalid 'xmppServerAddress': " + address); return; } if (!message.GetBoolean("xmppServerUseTls", &xmpp_server_config_.use_tls)) { - SendErrorAndExit(response.Pass(), + SendErrorAndExit(std::move(response), "'xmppServerUseTls' not found in request."); return; } if (!message.GetString("directoryBotJid", &directory_bot_jid_)) { - SendErrorAndExit(response.Pass(), + SendErrorAndExit(std::move(response), "'directoryBotJid' not found in request."); return; } @@ -214,7 +215,7 @@ void It2MeNativeMessagingHost::ProcessConnect( directory_bot_jid_); it2me_host_->Connect(); - SendMessageToClient(response.Pass()); + SendMessageToClient(std::move(response)); } void It2MeNativeMessagingHost::ProcessDisconnect( @@ -226,7 +227,7 @@ void It2MeNativeMessagingHost::ProcessDisconnect( it2me_host_->Disconnect(); it2me_host_ = nullptr; } - SendMessageToClient(response.Pass()); + SendMessageToClient(std::move(response)); } void It2MeNativeMessagingHost::SendErrorAndExit( @@ -238,7 +239,7 @@ void It2MeNativeMessagingHost::SendErrorAndExit( response->SetString("type", "error"); response->SetString("description", description); - SendMessageToClient(response.Pass()); + SendMessageToClient(std::move(response)); // Trigger a host shutdown by sending an empty message. client_->CloseChannel(std::string()); @@ -283,7 +284,7 @@ void It2MeNativeMessagingHost::OnStateChanged( ; } - SendMessageToClient(message.Pass()); + SendMessageToClient(std::move(message)); } void It2MeNativeMessagingHost::OnNatPolicyChanged(bool nat_traversal_enabled) { @@ -293,7 +294,7 @@ void It2MeNativeMessagingHost::OnNatPolicyChanged(bool nat_traversal_enabled) { message->SetString("type", "natPolicyChanged"); message->SetBoolean("natTraversalEnabled", nat_traversal_enabled); - SendMessageToClient(message.Pass()); + SendMessageToClient(std::move(message)); } // Stores the Access Code for the web-app to query. diff --git a/remoting/host/it2me/it2me_native_messaging_host_main.cc b/remoting/host/it2me/it2me_native_messaging_host_main.cc index 0fb94c8..b853ce9 100644 --- a/remoting/host/it2me/it2me_native_messaging_host_main.cc +++ b/remoting/host/it2me/it2me_native_messaging_host_main.cc @@ -4,6 +4,8 @@ #include "remoting/host/it2me/it2me_native_messaging_host_main.h" +#include <utility> + #include "base/at_exit.h" #include "base/command_line.h" #include "base/i18n/icu_util.h" @@ -122,17 +124,17 @@ int StartIt2MeNativeMessagingHost() { // Set up the native messaging channel. scoped_ptr<extensions::NativeMessagingChannel> channel( - new PipeMessagingChannel(read_file.Pass(), write_file.Pass())); + new PipeMessagingChannel(std::move(read_file), std::move(write_file))); scoped_ptr<ChromotingHostContext> context = ChromotingHostContext::Create(new remoting::AutoThreadTaskRunner( message_loop.task_runner(), run_loop.QuitClosure())); scoped_ptr<extensions::NativeMessageHost> host( - new It2MeNativeMessagingHost(context.Pass(), factory.Pass())); + new It2MeNativeMessagingHost(std::move(context), std::move(factory))); host->Start(native_messaging_pipe.get()); - native_messaging_pipe->Start(host.Pass(), channel.Pass()); + native_messaging_pipe->Start(std::move(host), std::move(channel)); // Run the loop until channel is alive. run_loop.Run(); diff --git a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc index aff8739..7b541a6 100644 --- a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc +++ b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/compiler_specific.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -76,8 +78,8 @@ class MockIt2MeHost : public It2MeHost { base::WeakPtr<It2MeHost::Observer> observer, const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, const std::string& directory_bot_jid) - : It2MeHost(context.Pass(), - policy_watcher.Pass(), + : It2MeHost(std::move(context), + std::move(policy_watcher), nullptr, observer, xmpp_server_config, @@ -158,7 +160,7 @@ class MockIt2MeHostFactory : public It2MeHostFactory { base::WeakPtr<It2MeHost::Observer> observer, const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, const std::string& directory_bot_jid) override { - return new MockIt2MeHost(context.Pass(), nullptr, observer, + return new MockIt2MeHost(std::move(context), nullptr, observer, xmpp_server_config, directory_bot_jid); } @@ -311,12 +313,12 @@ void It2MeNativeMessagingHostTest::WriteMessageToInputPipe( void It2MeNativeMessagingHostTest::VerifyHelloResponse(int request_id) { scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); - VerifyCommonProperties(response.Pass(), "helloResponse", request_id); + VerifyCommonProperties(std::move(response), "helloResponse", request_id); } void It2MeNativeMessagingHostTest::VerifyErrorResponse() { scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); - VerifyStringProperty(response.Pass(), "type", "error"); + VerifyStringProperty(std::move(response), "type", "error"); } void It2MeNativeMessagingHostTest::VerifyConnectResponses(int request_id) { @@ -337,7 +339,7 @@ void It2MeNativeMessagingHostTest::VerifyConnectResponses(int request_id) { if (type == "connectResponse") { EXPECT_FALSE(connect_response_received); connect_response_received = true; - VerifyId(response.Pass(), request_id); + VerifyId(std::move(response), request_id); } else if (type == "hostStateChanged") { std::string state; ASSERT_TRUE(response->GetString("state", &state)); @@ -393,7 +395,7 @@ void It2MeNativeMessagingHostTest::VerifyDisconnectResponses(int request_id) { if (type == "disconnectResponse") { EXPECT_FALSE(disconnect_response_received); disconnect_response_received = true; - VerifyId(response.Pass(), request_id); + VerifyId(std::move(response), request_id); } else if (type == "hostStateChanged") { std::string state; ASSERT_TRUE(response->GetString("state", &state)); @@ -440,8 +442,8 @@ void It2MeNativeMessagingHostTest::StartHost() { pipe_.reset(new NativeMessagingPipe()); scoped_ptr<extensions::NativeMessagingChannel> channel( - new PipeMessagingChannel(input_read_file.Pass(), - output_write_file.Pass())); + new PipeMessagingChannel(std::move(input_read_file), + std::move(output_write_file))); // Creating a native messaging host with a mock It2MeHostFactory. scoped_ptr<extensions::NativeMessageHost> it2me_host( @@ -450,7 +452,7 @@ void It2MeNativeMessagingHostTest::StartHost() { make_scoped_ptr(new MockIt2MeHostFactory()))); it2me_host->Start(pipe_.get()); - pipe_->Start(it2me_host.Pass(), channel.Pass()); + pipe_->Start(std::move(it2me_host), std::move(channel)); // Notify the test that the host has finished starting up. test_message_loop_->task_runner()->PostTask( diff --git a/remoting/host/it2me_desktop_environment.cc b/remoting/host/it2me_desktop_environment.cc index 57bb5a5..511f4cc 100644 --- a/remoting/host/it2me_desktop_environment.cc +++ b/remoting/host/it2me_desktop_environment.cc @@ -4,6 +4,8 @@ #include "remoting/host/it2me_desktop_environment.h" +#include <utility> + #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "build/build_config.h" @@ -58,16 +60,12 @@ It2MeDesktopEnvironment::It2MeDesktopEnvironment( if (want_user_interface) { continue_window_ = HostWindow::CreateContinueWindow(); continue_window_.reset(new HostWindowProxy( - caller_task_runner, - ui_task_runner, - continue_window_.Pass())); + caller_task_runner, ui_task_runner, std::move(continue_window_))); continue_window_->Start(client_session_control); disconnect_window_ = HostWindow::CreateDisconnectWindow(); disconnect_window_.reset(new HostWindowProxy( - caller_task_runner, - ui_task_runner, - disconnect_window_.Pass())); + caller_task_runner, ui_task_runner, std::move(disconnect_window_))); disconnect_window_->Start(client_session_control); } } diff --git a/remoting/host/linux/audio_pipe_reader.cc b/remoting/host/linux/audio_pipe_reader.cc index c8bda1b..691e78b 100644 --- a/remoting/host/linux/audio_pipe_reader.cc +++ b/remoting/host/linux/audio_pipe_reader.cc @@ -10,6 +10,8 @@ #include <sys/types.h> #include <unistd.h> +#include <utility> + #include "base/logging.h" #include "base/posix/eintr_wrapper.h" #include "base/stl_util.h" @@ -116,7 +118,7 @@ void AudioPipeReader::TryOpenPipe() { file_descriptor_watcher_.StopWatchingFileDescriptor(); timer_.Stop(); - pipe_ = new_pipe.Pass(); + pipe_ = std::move(new_pipe); if (pipe_.IsValid()) { // Get buffer size for the pipe. diff --git a/remoting/host/me2me_desktop_environment.cc b/remoting/host/me2me_desktop_environment.cc index d9663eb..6ca6e50 100644 --- a/remoting/host/me2me_desktop_environment.cc +++ b/remoting/host/me2me_desktop_environment.cc @@ -4,6 +4,8 @@ #include "remoting/host/me2me_desktop_environment.h" +#include <utility> + #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "build/build_config.h" @@ -117,9 +119,7 @@ bool Me2MeDesktopEnvironment::InitializeSecurity( disconnect_window_ = HostWindow::CreateDisconnectWindow(); disconnect_window_.reset(new HostWindowProxy( - caller_task_runner(), - ui_task_runner(), - disconnect_window_.Pass())); + caller_task_runner(), ui_task_runner(), std::move(disconnect_window_))); disconnect_window_->Start(client_session_control); } @@ -158,7 +158,7 @@ scoped_ptr<DesktopEnvironment> Me2MeDesktopEnvironmentFactory::Create( } desktop_environment->SetEnableGnubbyAuth(gnubby_auth_enabled_); - return desktop_environment.Pass(); + return std::move(desktop_environment); } void Me2MeDesktopEnvironmentFactory::SetEnableCurtaining(bool enable) { diff --git a/remoting/host/mouse_shape_pump.cc b/remoting/host/mouse_shape_pump.cc index b32e4a2..98d131e4 100644 --- a/remoting/host/mouse_shape_pump.cc +++ b/remoting/host/mouse_shape_pump.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/macros.h" @@ -56,7 +58,7 @@ MouseShapePump::Core::Core( scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor) : proxy_(proxy), caller_task_runner_(caller_task_runner), - mouse_cursor_monitor_(mouse_cursor_monitor.Pass()), + mouse_cursor_monitor_(std::move(mouse_cursor_monitor)), capture_timer_(true, true) { thread_checker_.DetachFromThread(); } @@ -124,7 +126,7 @@ MouseShapePump::MouseShapePump( weak_factory_(this) { core_.reset(new Core(weak_factory_.GetWeakPtr(), base::ThreadTaskRunnerHandle::Get(), - mouse_cursor_monitor.Pass())); + std::move(mouse_cursor_monitor))); capture_task_runner_->PostTask( FROM_HERE, base::Bind(&Core::Start, base::Unretained(core_.get()))); } diff --git a/remoting/host/mouse_shape_pump_unittest.cc b/remoting/host/mouse_shape_pump_unittest.cc index e3cd0ac..048ed64 100644 --- a/remoting/host/mouse_shape_pump_unittest.cc +++ b/remoting/host/mouse_shape_pump_unittest.cc @@ -4,6 +4,8 @@ #include "remoting/host/mouse_shape_pump.h" +#include <utility> + #include "base/bind.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" @@ -138,8 +140,8 @@ TEST_F(MouseShapePumpTest, FirstCursor) { .RetiresOnSaturation(); // Start the pump. - pump_.reset(new MouseShapePump(capture_task_runner_, cursor_monitor.Pass(), - &client_stub_)); + pump_.reset(new MouseShapePump(capture_task_runner_, + std::move(cursor_monitor), &client_stub_)); run_loop.Run(); } diff --git a/remoting/host/native_messaging/log_message_handler.cc b/remoting/host/native_messaging/log_message_handler.cc index 4f82933..d301cc3 100644 --- a/remoting/host/native_messaging/log_message_handler.cc +++ b/remoting/host/native_messaging/log_message_handler.cc @@ -124,7 +124,7 @@ void LogMessageHandler::SendLogMessageToClient( dictionary->SetString("file", file); dictionary->SetInteger("line", line); - delegate_.Run(dictionary.Pass()); + delegate_.Run(std::move(dictionary)); suppress_logging_ = false; } diff --git a/remoting/host/native_messaging/native_messaging_pipe.cc b/remoting/host/native_messaging/native_messaging_pipe.cc index 58fc532..d19dde5 100644 --- a/remoting/host/native_messaging/native_messaging_pipe.cc +++ b/remoting/host/native_messaging/native_messaging_pipe.cc @@ -4,6 +4,8 @@ #include "remoting/host/native_messaging/native_messaging_pipe.h" +#include <utility> + #include "base/callback_helpers.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -11,17 +13,14 @@ namespace remoting { -NativeMessagingPipe::NativeMessagingPipe() { -} - -NativeMessagingPipe::~NativeMessagingPipe() { -} +NativeMessagingPipe::NativeMessagingPipe() {} +NativeMessagingPipe::~NativeMessagingPipe() {} void NativeMessagingPipe::Start( scoped_ptr<extensions::NativeMessageHost> host, scoped_ptr<extensions::NativeMessagingChannel> channel) { - host_ = host.Pass(); - channel_ = channel.Pass(); + host_ = std::move(host); + channel_ = std::move(channel); channel_->Start(this); } @@ -39,7 +38,7 @@ void NativeMessagingPipe::OnDisconnect() { void NativeMessagingPipe::PostMessageFromNativeHost( const std::string& message) { scoped_ptr<base::Value> json = base::JSONReader::Read(message); - channel_->SendMessage(json.Pass()); + channel_->SendMessage(std::move(json)); } void NativeMessagingPipe::CloseChannel(const std::string& error_message) { diff --git a/remoting/host/native_messaging/native_messaging_reader.cc b/remoting/host/native_messaging/native_messaging_reader.cc index f7df74d..ffb553e 100644 --- a/remoting/host/native_messaging/native_messaging_reader.cc +++ b/remoting/host/native_messaging/native_messaging_reader.cc @@ -7,6 +7,7 @@ #include <stdint.h> #include <string> +#include <utility> #include "base/bind.h" #include "base/files/file.h" @@ -70,7 +71,7 @@ NativeMessagingReader::Core::Core( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SequencedTaskRunner> read_task_runner, base::WeakPtr<NativeMessagingReader> reader) - : read_stream_(file.Pass()), + : read_stream_(std::move(file)), reader_(reader), caller_task_runner_(caller_task_runner), read_task_runner_(read_task_runner) { @@ -138,7 +139,7 @@ NativeMessagingReader::NativeMessagingReader(base::File file) weak_factory_(this) { reader_thread_.Start(); read_task_runner_ = reader_thread_.task_runner(); - core_.reset(new Core(file.Pass(), base::ThreadTaskRunnerHandle::Get(), + core_.reset(new Core(std::move(file), base::ThreadTaskRunnerHandle::Get(), read_task_runner_, weak_factory_.GetWeakPtr())); } @@ -160,7 +161,7 @@ void NativeMessagingReader::Start(MessageCallback message_callback, void NativeMessagingReader::InvokeMessageCallback( scoped_ptr<base::Value> message) { - message_callback_.Run(message.Pass()); + message_callback_.Run(std::move(message)); } void NativeMessagingReader::InvokeEofCallback() { diff --git a/remoting/host/native_messaging/native_messaging_reader_unittest.cc b/remoting/host/native_messaging/native_messaging_reader_unittest.cc index 8c076b4..73ff362 100644 --- a/remoting/host/native_messaging/native_messaging_reader_unittest.cc +++ b/remoting/host/native_messaging/native_messaging_reader_unittest.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/bind.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" @@ -49,14 +51,12 @@ class NativeMessagingReaderTest : public testing::Test { base::RunLoop run_loop_; }; -NativeMessagingReaderTest::NativeMessagingReaderTest() { -} - +NativeMessagingReaderTest::NativeMessagingReaderTest() {} NativeMessagingReaderTest::~NativeMessagingReaderTest() {} void NativeMessagingReaderTest::SetUp() { ASSERT_TRUE(MakePipe(&read_file_, &write_file_)); - reader_.reset(new NativeMessagingReader(read_file_.Pass())); + reader_.reset(new NativeMessagingReader(std::move(read_file_))); } void NativeMessagingReaderTest::Run() { @@ -72,7 +72,7 @@ void NativeMessagingReaderTest::Run() { } void NativeMessagingReaderTest::OnMessage(scoped_ptr<base::Value> message) { - message_ = message.Pass(); + message_ = std::move(message); } void NativeMessagingReaderTest::WriteMessage(const std::string& message) { diff --git a/remoting/host/native_messaging/native_messaging_writer.cc b/remoting/host/native_messaging/native_messaging_writer.cc index f8d442a..03e420f 100644 --- a/remoting/host/native_messaging/native_messaging_writer.cc +++ b/remoting/host/native_messaging/native_messaging_writer.cc @@ -8,6 +8,7 @@ #include <stdint.h> #include <string> +#include <utility> #include "base/json/json_writer.h" @@ -32,9 +33,7 @@ const size_t kMaximumMessageSize = 1024 * 1024; namespace remoting { NativeMessagingWriter::NativeMessagingWriter(base::File file) - : write_stream_(file.Pass()), - fail_(false) { -} + : write_stream_(std::move(file)), fail_(false) {} NativeMessagingWriter::~NativeMessagingWriter() { } diff --git a/remoting/host/native_messaging/native_messaging_writer_unittest.cc b/remoting/host/native_messaging/native_messaging_writer_unittest.cc index 88dbb21..def0a75 100644 --- a/remoting/host/native_messaging/native_messaging_writer_unittest.cc +++ b/remoting/host/native_messaging/native_messaging_writer_unittest.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/json/json_reader.h" #include "base/memory/scoped_ptr.h" #include "base/stl_util.h" @@ -29,12 +31,11 @@ class NativeMessagingWriterTest : public testing::Test { }; NativeMessagingWriterTest::NativeMessagingWriterTest() {} - NativeMessagingWriterTest::~NativeMessagingWriterTest() {} void NativeMessagingWriterTest::SetUp() { ASSERT_TRUE(MakePipe(&read_file_, &write_file_)); - writer_.reset(new NativeMessagingWriter(write_file_.Pass())); + writer_.reset(new NativeMessagingWriter(std::move(write_file_))); } TEST_F(NativeMessagingWriterTest, GoodMessage) { diff --git a/remoting/host/native_messaging/pipe_messaging_channel.cc b/remoting/host/native_messaging/pipe_messaging_channel.cc index 2d8dc11..a1e8831 100644 --- a/remoting/host/native_messaging/pipe_messaging_channel.cc +++ b/remoting/host/native_messaging/pipe_messaging_channel.cc @@ -4,6 +4,8 @@ #include "remoting/host/native_messaging/pipe_messaging_channel.h" +#include <utility> + #include "base/bind.h" #include "base/callback.h" #include "base/callback_helpers.h" @@ -43,19 +45,16 @@ base::File DuplicatePlatformFile(base::File file) { namespace remoting { -PipeMessagingChannel::PipeMessagingChannel( - base::File input, - base::File output) - : native_messaging_reader_(DuplicatePlatformFile(input.Pass())), - native_messaging_writer_(new NativeMessagingWriter( - DuplicatePlatformFile(output.Pass()))), +PipeMessagingChannel::PipeMessagingChannel(base::File input, base::File output) + : native_messaging_reader_(DuplicatePlatformFile(std::move(input))), + native_messaging_writer_( + new NativeMessagingWriter(DuplicatePlatformFile(std::move(output)))), event_handler_(nullptr), weak_factory_(this) { weak_ptr_ = weak_factory_.GetWeakPtr(); } -PipeMessagingChannel::~PipeMessagingChannel() { -} +PipeMessagingChannel::~PipeMessagingChannel() {} void PipeMessagingChannel::Start(EventHandler* event_handler) { DCHECK(CalledOnValidThread()); @@ -73,11 +72,10 @@ void PipeMessagingChannel::ProcessMessage(scoped_ptr<base::Value> message) { DCHECK(CalledOnValidThread()); if (event_handler_) - event_handler_->OnMessage(message.Pass()); + event_handler_->OnMessage(std::move(message)); } -void PipeMessagingChannel::SendMessage( - scoped_ptr<base::Value> message) { +void PipeMessagingChannel::SendMessage(scoped_ptr<base::Value> message) { DCHECK(CalledOnValidThread()); bool success = message && native_messaging_writer_; diff --git a/remoting/host/oauth_token_getter_impl.cc b/remoting/host/oauth_token_getter_impl.cc index 3d08f03..1dd35aa 100644 --- a/remoting/host/oauth_token_getter_impl.cc +++ b/remoting/host/oauth_token_getter_impl.cc @@ -4,6 +4,8 @@ #include "remoting/host/oauth_token_getter_impl.h" +#include <utility> + #include "base/bind.h" #include "base/callback.h" #include "base/strings/string_util.h" @@ -28,7 +30,7 @@ OAuthTokenGetterImpl::OAuthTokenGetterImpl( const scoped_refptr<net::URLRequestContextGetter>& url_request_context_getter, bool auto_refresh) - : oauth_credentials_(oauth_credentials.Pass()), + : oauth_credentials_(std::move(oauth_credentials)), gaia_oauth_client_( new gaia::GaiaOAuthClient(url_request_context_getter.get())), url_request_context_getter_(url_request_context_getter) { @@ -37,8 +39,7 @@ OAuthTokenGetterImpl::OAuthTokenGetterImpl( } } -OAuthTokenGetterImpl::~OAuthTokenGetterImpl() { -} +OAuthTokenGetterImpl::~OAuthTokenGetterImpl() {} void OAuthTokenGetterImpl::OnGetTokensResponse(const std::string& user_email, const std::string& access_token, diff --git a/remoting/host/pairing_registry_delegate.cc b/remoting/host/pairing_registry_delegate.cc index c7e49a0..a9596b0 100644 --- a/remoting/host/pairing_registry_delegate.cc +++ b/remoting/host/pairing_registry_delegate.cc @@ -4,6 +4,8 @@ #include "remoting/host/pairing_registry_delegate.h" +#include <utility> + #include "base/single_thread_task_runner.h" namespace remoting { @@ -16,7 +18,7 @@ scoped_refptr<PairingRegistry> CreatePairingRegistry( scoped_ptr<PairingRegistry::Delegate> delegate( CreatePairingRegistryDelegate()); if (delegate) { - pairing_registry = new PairingRegistry(task_runner, delegate.Pass()); + pairing_registry = new PairingRegistry(task_runner, std::move(delegate)); } return pairing_registry; } diff --git a/remoting/host/pairing_registry_delegate_linux.cc b/remoting/host/pairing_registry_delegate_linux.cc index cf51255..8bd25de 100644 --- a/remoting/host/pairing_registry_delegate_linux.cc +++ b/remoting/host/pairing_registry_delegate_linux.cc @@ -60,7 +60,7 @@ scoped_ptr<base::ListValue> PairingRegistryDelegateLinux::LoadAll() { pairings->Append(pairing_json.release()); } - return pairings.Pass(); + return pairings; } bool PairingRegistryDelegateLinux::DeleteAll() { diff --git a/remoting/host/pairing_registry_delegate_win.cc b/remoting/host/pairing_registry_delegate_win.cc index 90b04ba..d65014e 100644 --- a/remoting/host/pairing_registry_delegate_win.cc +++ b/remoting/host/pairing_registry_delegate_win.cc @@ -4,6 +4,8 @@ #include "remoting/host/pairing_registry_delegate_win.h" +#include <utility> + #include "base/json/json_string_value_serializer.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" @@ -139,7 +141,7 @@ scoped_ptr<base::ListValue> PairingRegistryDelegateWin::LoadAll() { pairings->Append(pairing.ToValue().release()); } - return pairings.Pass(); + return pairings; } bool PairingRegistryDelegateWin::DeleteAll() { @@ -223,8 +225,8 @@ bool PairingRegistryDelegateWin::Save(const PairingRegistry::Pairing& pairing) { std::wstring value_name = base::UTF8ToWide(pairing.client_id()); // Write pairing to the registry. - if (!WriteValue(privileged_, value_name.c_str(), secret_json.Pass()) || - !WriteValue(unprivileged_, value_name.c_str(), pairing_json.Pass())) { + if (!WriteValue(privileged_, value_name.c_str(), std::move(secret_json)) || + !WriteValue(unprivileged_, value_name.c_str(), std::move(pairing_json))) { return false; } diff --git a/remoting/host/pam_authorization_factory_posix.cc b/remoting/host/pam_authorization_factory_posix.cc index 7de2141..c0352aa 100644 --- a/remoting/host/pam_authorization_factory_posix.cc +++ b/remoting/host/pam_authorization_factory_posix.cc @@ -6,6 +6,8 @@ #include <security/pam_appl.h> +#include <utility> + #include "base/bind.h" #include "base/callback.h" #include "base/environment.h" @@ -46,15 +48,13 @@ class PamAuthorizer : public protocol::Authenticator { scoped_ptr<protocol::Authenticator> underlying_; enum { NOT_CHECKED, ALLOWED, DISALLOWED } local_login_status_; }; + } // namespace PamAuthorizer::PamAuthorizer(scoped_ptr<protocol::Authenticator> underlying) - : underlying_(underlying.Pass()), - local_login_status_(NOT_CHECKED) { -} + : underlying_(std::move(underlying)), local_login_status_(NOT_CHECKED) {} -PamAuthorizer::~PamAuthorizer() { -} +PamAuthorizer::~PamAuthorizer() {} protocol::Authenticator::State PamAuthorizer::state() const { if (local_login_status_ == DISALLOWED) { @@ -93,7 +93,7 @@ void PamAuthorizer::OnMessageProcessed(const base::Closure& resume_callback) { scoped_ptr<buzz::XmlElement> PamAuthorizer::GetNextMessage() { scoped_ptr<buzz::XmlElement> result(underlying_->GetNextMessage()); MaybeCheckLocalLogin(); - return result.Pass(); + return result; } const std::string& PamAuthorizer::GetAuthKey() const { @@ -160,14 +160,11 @@ int PamAuthorizer::PamConversation(int num_messages, return PAM_SUCCESS; } - PamAuthorizationFactory::PamAuthorizationFactory( scoped_ptr<protocol::AuthenticatorFactory> underlying) - : underlying_(underlying.Pass()) { -} + : underlying_(std::move(underlying)) {} -PamAuthorizationFactory::~PamAuthorizationFactory() { -} +PamAuthorizationFactory::~PamAuthorizationFactory() {} scoped_ptr<protocol::Authenticator> PamAuthorizationFactory::CreateAuthenticator( @@ -176,8 +173,7 @@ PamAuthorizationFactory::CreateAuthenticator( const buzz::XmlElement* first_message) { scoped_ptr<protocol::Authenticator> authenticator( underlying_->CreateAuthenticator(local_jid, remote_jid, first_message)); - return make_scoped_ptr(new PamAuthorizer(authenticator.Pass())); + return make_scoped_ptr(new PamAuthorizer(std::move(authenticator))); } - } // namespace remoting diff --git a/remoting/host/policy_watcher.cc b/remoting/host/policy_watcher.cc index 84d3210..5d4d88f 100644 --- a/remoting/host/policy_watcher.cc +++ b/remoting/host/policy_watcher.cc @@ -7,6 +7,8 @@ #include "remoting/host/policy_watcher.h" +#include <utility> + #include "base/bind.h" #include "base/compiler_specific.h" #include "base/files/file_path.h" @@ -63,7 +65,7 @@ scoped_ptr<base::DictionaryValue> CopyValuesAndAddDefaults( to->Set(i.key(), value->DeepCopy()); } - return to.Pass(); + return to; } policy::PolicyNamespace GetPolicyNamespace() { @@ -79,7 +81,7 @@ scoped_ptr<policy::SchemaRegistry> CreateSchemaRegistry() { scoped_ptr<policy::SchemaRegistry> schema_registry( new policy::SchemaRegistry()); schema_registry->RegisterComponent(GetPolicyNamespace(), schema); - return schema_registry.Pass(); + return schema_registry; } scoped_ptr<base::DictionaryValue> CopyChromotingPoliciesIntoDictionary( @@ -99,7 +101,7 @@ scoped_ptr<base::DictionaryValue> CopyChromotingPoliciesIntoDictionary( } } - return policy_dict.Pass(); + return policy_dict; } // Takes a dictionary containing only 1) recognized policy names and 2) @@ -167,9 +169,9 @@ PolicyWatcher::PolicyWatcher( : old_policies_(new base::DictionaryValue()), default_values_(new base::DictionaryValue()), policy_service_(policy_service), - owned_schema_registry_(owned_schema_registry.Pass()), - owned_policy_provider_(owned_policy_provider.Pass()), - owned_policy_service_(owned_policy_service.Pass()) { + owned_schema_registry_(std::move(owned_schema_registry)), + owned_policy_provider_(std::move(owned_policy_provider)), + owned_policy_service_(std::move(owned_policy_service)) { DCHECK(policy_service_); DCHECK(owned_schema_registry_); @@ -275,7 +277,7 @@ PolicyWatcher::StoreNewAndReturnChangedPolicies( // Save the new policies. old_policies_.swap(new_policies); - return changed_policies.Pass(); + return changed_policies; } void PolicyWatcher::OnPolicyUpdated(const policy::PolicyNamespace& ns, @@ -296,7 +298,7 @@ void PolicyWatcher::OnPolicyUpdated(const policy::PolicyNamespace& ns, // Limit reporting to only the policies that were changed. scoped_ptr<base::DictionaryValue> changed_policies = - StoreNewAndReturnChangedPolicies(filled_policies.Pass()); + StoreNewAndReturnChangedPolicies(std::move(filled_policies)); if (changed_policies->empty()) { return; } @@ -308,7 +310,7 @@ void PolicyWatcher::OnPolicyUpdated(const policy::PolicyNamespace& ns, } // Notify our client of the changed policies. - policy_updated_callback_.Run(changed_policies.Pass()); + policy_updated_callback_.Run(std::move(changed_policies)); } void PolicyWatcher::OnPolicyServiceInitialized(policy::PolicyDomain domain) { @@ -322,7 +324,7 @@ scoped_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoader( scoped_ptr<policy::SchemaRegistry> schema_registry = CreateSchemaRegistry(); scoped_ptr<policy::AsyncPolicyProvider> policy_provider( new policy::AsyncPolicyProvider(schema_registry.get(), - async_policy_loader.Pass())); + std::move(async_policy_loader))); policy_provider->Init(schema_registry.get()); policy::PolicyServiceImpl::Providers providers; @@ -331,9 +333,9 @@ scoped_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoader( new policy::PolicyServiceImpl(providers)); policy::PolicyService* borrowed_policy_service = policy_service.get(); - return make_scoped_ptr( - new PolicyWatcher(borrowed_policy_service, policy_service.Pass(), - policy_provider.Pass(), schema_registry.Pass())); + return make_scoped_ptr(new PolicyWatcher( + borrowed_policy_service, std::move(policy_service), + std::move(policy_provider), std::move(schema_registry))); } scoped_ptr<PolicyWatcher> PolicyWatcher::Create( @@ -370,7 +372,7 @@ scoped_ptr<PolicyWatcher> PolicyWatcher::Create( #error OS that is not yet supported by PolicyWatcher code. #endif - return PolicyWatcher::CreateFromPolicyLoader(policy_loader.Pass()); + return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader)); #endif // !(OS_CHROMEOS) } diff --git a/remoting/host/register_support_host_request.cc b/remoting/host/register_support_host_request.cc index 33d931a..01955a6 100644 --- a/remoting/host/register_support_host_request.cc +++ b/remoting/host/register_support_host_request.cc @@ -65,7 +65,7 @@ void RegisterSupportHostRequest::OnSignalStrategyStateChange( request_ = iq_sender_->SendIq( buzz::STR_SET, directory_bot_jid_, - CreateRegistrationRequest(signal_strategy_->GetLocalJid()).Pass(), + CreateRegistrationRequest(signal_strategy_->GetLocalJid()), base::Bind(&RegisterSupportHostRequest::ProcessResponse, base::Unretained(this))); } else if (state == SignalStrategy::DISCONNECTED) { @@ -90,7 +90,7 @@ scoped_ptr<XmlElement> RegisterSupportHostRequest::CreateRegistrationRequest( public_key->AddText(key_pair_->GetPublicKey()); query->AddElement(public_key); query->AddElement(CreateSignature(jid).release()); - return query.Pass(); + return query; } scoped_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( @@ -107,7 +107,7 @@ scoped_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( std::string signature(key_pair_->SignMessage(message)); signature_tag->AddText(signature); - return signature_tag.Pass(); + return signature_tag; } void RegisterSupportHostRequest::ParseResponse(const XmlElement* response, diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index d5b7d31..04be3d3 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -8,6 +8,7 @@ #include <stdint.h> #include <string> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -471,7 +472,7 @@ class HostProcess : public ConfigWatcher::Delegate, HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, int* exit_code_out, ShutdownWatchdog* shutdown_watchdog) - : context_(context.Pass()), + : context_(std::move(context)), state_(HOST_STARTING), use_service_account_(false), enable_vp9_(false), @@ -780,7 +781,7 @@ void HostProcess::CreateAuthenticatorFactory() { if (delegate) pairing_registry_ = new PairingRegistry(context_->file_task_runner(), - delegate.Pass()); + std::move(delegate)); } #endif // defined(OS_WIN) @@ -802,14 +803,14 @@ void HostProcess::CreateAuthenticatorFactory() { key_pair_, context_->url_request_context_getter())); factory = protocol::Me2MeHostAuthenticatorFactory::CreateWithThirdPartyAuth( use_service_account_, host_owner_, local_certificate, key_pair_, - token_validator_factory.Pass()); + std::move(token_validator_factory)); } #if defined(OS_POSIX) // On Linux and Mac, perform a PAM authorization step after authentication. - factory.reset(new PamAuthorizationFactory(factory.Pass())); + factory.reset(new PamAuthorizationFactory(std::move(factory))); #endif - host_->SetAuthenticatorFactory(factory.Pass()); + host_->SetAuthenticatorFactory(std::move(factory)); } // IPC::Listener implementation. @@ -997,7 +998,7 @@ void HostProcess::InitializePairingRegistry( delegate->SetRootKeys(privileged_hkey, unprivileged_hkey); pairing_registry_ = new PairingRegistry(context_->file_task_runner(), - delegate.Pass()); + std::move(delegate)); // (Re)Create the authenticator factory now that |pairing_registry_| has been // initialized. @@ -1425,10 +1426,11 @@ void HostProcess::InitializeSignaling() { new OAuthTokenGetter::OAuthCredentials(xmpp_server_config_.username, oauth_refresh_token_, use_service_account_)); - oauth_token_getter_.reset(new OAuthTokenGetterImpl( - oauth_credentials.Pass(), context_->url_request_context_getter(), false)); + oauth_token_getter_.reset( + new OAuthTokenGetterImpl(std::move(oauth_credentials), + context_->url_request_context_getter(), false)); signaling_connector_.reset(new SignalingConnector( - xmpp_signal_strategy, dns_blackhole_checker.Pass(), + xmpp_signal_strategy, std::move(dns_blackhole_checker), oauth_token_getter_.get(), base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this)))); @@ -1438,12 +1440,10 @@ void HostProcess::InitializeSignaling() { scoped_ptr<GcdRestClient> gcd_rest_client(new GcdRestClient( service_urls->gcd_base_url(), host_id_, context_->url_request_context_getter(), oauth_token_getter_.get())); - gcd_state_updater_.reset( - new GcdStateUpdater(base::Bind(&HostProcess::OnHeartbeatSuccessful, - base::Unretained(this)), - base::Bind(&HostProcess::OnUnknownHostIdError, - base::Unretained(this)), - signal_strategy_.get(), gcd_rest_client.Pass())); + gcd_state_updater_.reset(new GcdStateUpdater( + base::Bind(&HostProcess::OnHeartbeatSuccessful, base::Unretained(this)), + base::Bind(&HostProcess::OnUnknownHostIdError, base::Unretained(this)), + signal_strategy_.get(), std::move(gcd_rest_client))); PushNotificationSubscriber::Subscription sub; sub.channel = "cloud_devices"; PushNotificationSubscriber::SubscriptionList subs; @@ -1528,7 +1528,7 @@ void HostProcess::StartHost() { new protocol::IceTransportFactory(transport_context)); } scoped_ptr<protocol::SessionManager> session_manager( - new protocol::JingleSessionManager(transport_factory.Pass(), + new protocol::JingleSessionManager(std::move(transport_factory), signal_strategy_.get())); scoped_ptr<protocol::CandidateSessionConfig> protocol_config = @@ -1542,12 +1542,12 @@ void HostProcess::StartHost() { protocol_config->set_webrtc_supported(true); } #endif // !defined(NDEBUG) - session_manager->set_protocol_config(protocol_config.Pass()); + session_manager->set_protocol_config(std::move(protocol_config)); host_.reset(new ChromotingHost( - desktop_environment_factory_.get(), - session_manager.Pass(), context_->audio_task_runner(), - context_->input_task_runner(), context_->video_capture_task_runner(), + desktop_environment_factory_.get(), std::move(session_manager), + context_->audio_task_runner(), context_->input_task_runner(), + context_->video_capture_task_runner(), context_->video_encode_task_runner(), context_->network_task_runner(), context_->ui_task_runner())); @@ -1555,7 +1555,7 @@ void HostProcess::StartHost() { scoped_ptr<VideoFrameRecorderHostExtension> frame_recorder_extension( new VideoFrameRecorderHostExtension()); frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_); - host_->AddExtension(frame_recorder_extension.Pass()); + host_->AddExtension(std::move(frame_recorder_extension)); } // TODO(simonmorris): Get the maximum session duration from a policy. @@ -1750,7 +1750,7 @@ int HostProcessMain() { int exit_code = kSuccessExitCode; ShutdownWatchdog shutdown_watchdog( base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); - new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); + new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); // Run the main (also UI) message loop until the host no longer needs it. message_loop.Run(); diff --git a/remoting/host/resizing_host_observer.cc b/remoting/host/resizing_host_observer.cc index 31edab9..04129be3 100644 --- a/remoting/host/resizing_host_observer.cc +++ b/remoting/host/resizing_host_observer.cc @@ -7,6 +7,7 @@ #include <stdint.h> #include <list> +#include <utility> #include "base/bind.h" #include "base/logging.h" @@ -118,10 +119,9 @@ class CandidateResolution { ResizingHostObserver::ResizingHostObserver( scoped_ptr<DesktopResizer> desktop_resizer) - : desktop_resizer_(desktop_resizer.Pass()), + : desktop_resizer_(std::move(desktop_resizer)), now_function_(base::Bind(base::Time::Now)), - weak_factory_(this) { -} + weak_factory_(this) {} ResizingHostObserver::~ResizingHostObserver() { if (!original_resolution_.IsEmpty()) diff --git a/remoting/host/resizing_host_observer_unittest.cc b/remoting/host/resizing_host_observer_unittest.cc index a6fe300..488fd16 100644 --- a/remoting/host/resizing_host_observer_unittest.cc +++ b/remoting/host/resizing_host_observer_unittest.cc @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "remoting/host/resizing_host_observer.h" + #include <list> +#include <utility> #include "base/compiler_specific.h" #include "base/logging.h" @@ -11,7 +14,6 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "remoting/host/desktop_resizer.h" -#include "remoting/host/resizing_host_observer.h" #include "remoting/host/screen_resolution.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" @@ -109,7 +111,7 @@ class ResizingHostObserverTest : public testing::Test { desktop_resizer_ = desktop_resizer.get(); resizing_host_observer_.reset( - new ResizingHostObserver(desktop_resizer.Pass())); + new ResizingHostObserver(std::move(desktop_resizer))); resizing_host_observer_->SetNowFunctionForTesting( base::Bind(&ResizingHostObserverTest::GetTimeAndIncrement, base::Unretained(this))); @@ -148,7 +150,7 @@ TEST_F(ResizingHostObserverTest, NoRestoreResolution) { scoped_ptr<FakeDesktopResizer> desktop_resizer( new FakeDesktopResizer(initial, false, nullptr, 0, &restore_resolution_call_count)); - SetDesktopResizer(desktop_resizer.Pass()); + SetDesktopResizer(std::move(desktop_resizer)); VerifySizes(nullptr, nullptr, 0); resizing_host_observer_.reset(); EXPECT_EQ(0, restore_resolution_call_count); @@ -162,7 +164,7 @@ TEST_F(ResizingHostObserverTest, EmptyGetSupportedSizes) { scoped_ptr<FakeDesktopResizer> desktop_resizer( new FakeDesktopResizer(initial, false, nullptr, 0, &restore_resolution_call_count)); - SetDesktopResizer(desktop_resizer.Pass()); + SetDesktopResizer(std::move(desktop_resizer)); ScreenResolution client_sizes[] = { MakeResolution(200, 100), MakeResolution(100, 200) }; @@ -179,7 +181,7 @@ TEST_F(ResizingHostObserverTest, SelectExactSize) { scoped_ptr<FakeDesktopResizer> desktop_resizer( new FakeDesktopResizer(MakeResolution(640, 480), true, nullptr, 0, &restore_resolution_call_count)); - SetDesktopResizer(desktop_resizer.Pass()); + SetDesktopResizer(std::move(desktop_resizer)); ScreenResolution client_sizes[] = { MakeResolution(200, 100), MakeResolution(100, 200), @@ -200,7 +202,7 @@ TEST_F(ResizingHostObserverTest, SelectBestSmallerSize) { new FakeDesktopResizer(MakeResolution(640, 480), false, supported_sizes, arraysize(supported_sizes), nullptr)); - SetDesktopResizer(desktop_resizer.Pass()); + SetDesktopResizer(std::move(desktop_resizer)); ScreenResolution client_sizes[] = { MakeResolution(639, 479), MakeResolution(640, 480), @@ -220,7 +222,7 @@ TEST_F(ResizingHostObserverTest, SelectBestScaleFactor) { new FakeDesktopResizer(MakeResolution(200, 100), false, supported_sizes, arraysize(supported_sizes), nullptr)); - SetDesktopResizer(desktop_resizer.Pass()); + SetDesktopResizer(std::move(desktop_resizer)); ScreenResolution client_sizes[] = { MakeResolution(1, 1), MakeResolution(99, 99), @@ -239,7 +241,7 @@ TEST_F(ResizingHostObserverTest, SelectWidest) { new FakeDesktopResizer(MakeResolution(480, 640), false, supported_sizes, arraysize(supported_sizes), nullptr)); - SetDesktopResizer(desktop_resizer.Pass()); + SetDesktopResizer(std::move(desktop_resizer)); ScreenResolution client_sizes[] = { MakeResolution(100, 100), MakeResolution(480, 480), diff --git a/remoting/host/server_log_entry_host.cc b/remoting/host/server_log_entry_host.cc index f864496..2ede7e8 100644 --- a/remoting/host/server_log_entry_host.cc +++ b/remoting/host/server_log_entry_host.cc @@ -39,14 +39,14 @@ scoped_ptr<ServerLogEntry> MakeLogEntryForSessionStateChange( entry->AddRoleField(kValueRoleHost); entry->AddEventNameField(kValueEventNameSessionState); entry->Set(kKeySessionState, GetValueSessionState(connected)); - return entry.Pass(); + return entry; } scoped_ptr<ServerLogEntry> MakeLogEntryForHeartbeat() { scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); entry->AddRoleField(kValueRoleHost); entry->AddEventNameField(kValueEventNameHeartbeat); - return entry.Pass(); + return entry; } void AddHostFieldsToLogEntry(ServerLogEntry* entry) { diff --git a/remoting/host/setup/daemon_controller.cc b/remoting/host/setup/daemon_controller.cc index 34403ef..f871d43 100644 --- a/remoting/host/setup/daemon_controller.cc +++ b/remoting/host/setup/daemon_controller.cc @@ -4,6 +4,8 @@ #include "remoting/host/setup/daemon_controller.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/single_thread_task_runner.h" @@ -20,7 +22,7 @@ const char kDaemonControllerThreadName[] = "Daemon Controller thread"; DaemonController::DaemonController(scoped_ptr<Delegate> delegate) : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), - delegate_(delegate.Pass()) { + delegate_(std::move(delegate)) { // Launch the delegate thread. delegate_thread_.reset(new AutoThread(kDaemonControllerThreadName)); #if defined(OS_WIN) @@ -118,7 +120,7 @@ void DaemonController::DoSetConfigAndStart( const CompletionCallback& done) { DCHECK(delegate_task_runner_->BelongsToCurrentThread()); - delegate_->SetConfigAndStart(config.Pass(), consent, done); + delegate_->SetConfigAndStart(std::move(config), consent, done); } void DaemonController::DoUpdateConfig( @@ -126,7 +128,7 @@ void DaemonController::DoUpdateConfig( const CompletionCallback& done) { DCHECK(delegate_task_runner_->BelongsToCurrentThread()); - delegate_->UpdateConfig(config.Pass(), done); + delegate_->UpdateConfig(std::move(config), done); } void DaemonController::DoStop(const CompletionCallback& done) { @@ -164,7 +166,7 @@ void DaemonController::InvokeConfigCallbackAndScheduleNext( scoped_ptr<base::DictionaryValue> config) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); - done.Run(config.Pass()); + done.Run(std::move(config)); ScheduleNext(); } diff --git a/remoting/host/setup/daemon_controller_delegate_linux.cc b/remoting/host/setup/daemon_controller_delegate_linux.cc index 57de922..2e40132 100644 --- a/remoting/host/setup/daemon_controller_delegate_linux.cc +++ b/remoting/host/setup/daemon_controller_delegate_linux.cc @@ -139,7 +139,7 @@ scoped_ptr<base::DictionaryValue> DaemonControllerDelegateLinux::GetConfig() { if (config->GetString(kXmppLoginConfigPath, &value)) { result->SetString(kXmppLoginConfigPath, value); } - return result.Pass(); + return result; } void DaemonControllerDelegateLinux::SetConfigAndStart( @@ -229,9 +229,8 @@ DaemonControllerDelegateLinux::GetUsageStatsConsent() { } scoped_refptr<DaemonController> DaemonController::Create() { - scoped_ptr<DaemonController::Delegate> delegate( - new DaemonControllerDelegateLinux()); - return new DaemonController(delegate.Pass()); + return new DaemonController( + make_scoped_ptr(new DaemonControllerDelegateLinux())); } } // namespace remoting diff --git a/remoting/host/setup/daemon_controller_delegate_mac.mm b/remoting/host/setup/daemon_controller_delegate_mac.mm index aa4703c..4363a40 100644 --- a/remoting/host/setup/daemon_controller_delegate_mac.mm +++ b/remoting/host/setup/daemon_controller_delegate_mac.mm @@ -61,7 +61,7 @@ scoped_ptr<base::DictionaryValue> DaemonControllerDelegateMac::GetConfig() { config->SetString(kHostIdConfigPath, value); if (host_config->GetString(kXmppLoginConfigPath, &value)) config->SetString(kXmppLoginConfigPath, value); - return config.Pass(); + return config; } void DaemonControllerDelegateMac::SetConfigAndStart( @@ -249,9 +249,8 @@ void DaemonControllerDelegateMac::PreferencePaneCallback( } scoped_refptr<DaemonController> DaemonController::Create() { - scoped_ptr<DaemonController::Delegate> delegate( - new DaemonControllerDelegateMac()); - return new DaemonController(delegate.Pass()); + return new DaemonController( + make_scoped_ptr(new DaemonControllerDelegateMac())); } } // namespace remoting diff --git a/remoting/host/setup/daemon_controller_delegate_win.cc b/remoting/host/setup/daemon_controller_delegate_win.cc index ef0627f..baab288 100644 --- a/remoting/host/setup/daemon_controller_delegate_win.cc +++ b/remoting/host/setup/daemon_controller_delegate_win.cc @@ -256,7 +256,7 @@ ScopedScHandle OpenService(DWORD access) { << "' service"; } - return service.Pass(); + return service; } void InvokeCompletionCallback( @@ -468,9 +468,8 @@ void DaemonControllerDelegateWin::SetConfigAndStart( } scoped_refptr<DaemonController> DaemonController::Create() { - scoped_ptr<DaemonController::Delegate> delegate( - new DaemonControllerDelegateWin()); - return new DaemonController(delegate.Pass()); + return new DaemonController( + make_scoped_ptr(new DaemonControllerDelegateWin())); } } // namespace remoting diff --git a/remoting/host/setup/host_starter.cc b/remoting/host/setup/host_starter.cc index 5eda05c..078a98c 100644 --- a/remoting/host/setup/host_starter.cc +++ b/remoting/host/setup/host_starter.cc @@ -4,6 +4,8 @@ #include "remoting/host/setup/host_starter.h" +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/guid.h" @@ -24,8 +26,8 @@ HostStarter::HostStarter( scoped_ptr<gaia::GaiaOAuthClient> oauth_client, scoped_ptr<remoting::ServiceClient> service_client, scoped_refptr<remoting::DaemonController> daemon_controller) - : oauth_client_(oauth_client.Pass()), - service_client_(service_client.Pass()), + : oauth_client_(std::move(oauth_client)), + service_client_(std::move(service_client)), daemon_controller_(daemon_controller), consent_to_data_collection_(false), unregistering_host_(false), @@ -34,21 +36,16 @@ HostStarter::HostStarter( main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); } -HostStarter::~HostStarter() { -} +HostStarter::~HostStarter() {} scoped_ptr<HostStarter> HostStarter::Create( const std::string& chromoting_hosts_url, net::URLRequestContextGetter* url_request_context_getter) { - scoped_ptr<gaia::GaiaOAuthClient> oauth_client( - new gaia::GaiaOAuthClient(url_request_context_getter)); - scoped_ptr<remoting::ServiceClient> service_client( - new remoting::ServiceClient( - chromoting_hosts_url, url_request_context_getter)); - scoped_refptr<remoting::DaemonController> daemon_controller( - remoting::DaemonController::Create()); return make_scoped_ptr(new HostStarter( - oauth_client.Pass(), service_client.Pass(), daemon_controller)); + make_scoped_ptr(new gaia::GaiaOAuthClient(url_request_context_getter)), + make_scoped_ptr(new remoting::ServiceClient(chromoting_hosts_url, + url_request_context_getter)), + remoting::DaemonController::Create())); } void HostStarter::StartHost( @@ -170,7 +167,7 @@ void HostStarter::StartHostProcess() { config->SetString("private_key", key_pair_->ToString()); config->SetString("host_secret_hash", host_secret_hash); daemon_controller_->SetConfigAndStart( - config.Pass(), consent_to_data_collection_, + std::move(config), consent_to_data_collection_, base::Bind(&HostStarter::OnHostStarted, base::Unretained(this))); } diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc index 554008b..59ceadc 100644 --- a/remoting/host/setup/me2me_native_messaging_host.cc +++ b/remoting/host/setup/me2me_native_messaging_host.cc @@ -5,6 +5,7 @@ #include "remoting/host/setup/me2me_native_messaging_host.h" #include <string> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -66,7 +67,7 @@ scoped_ptr<base::DictionaryValue> ConfigDictionaryFromMessage( } else { LOG(ERROR) << "'config' dictionary not found"; } - return result.Pass(); + return result; } } // namespace @@ -84,13 +85,13 @@ Me2MeNativeMessagingHost::Me2MeNativeMessagingHost( #if defined(OS_WIN) parent_window_handle_(parent_window_handle), #endif - channel_(channel.Pass()), + channel_(std::move(channel)), log_message_handler_( base::Bind(&extensions::NativeMessagingChannel::SendMessage, base::Unretained(channel_.get()))), daemon_controller_(daemon_controller), pairing_registry_(pairing_registry), - oauth_client_(oauth_client.Pass()), + oauth_client_(std::move(oauth_client)), weak_factory_(this) { weak_ptr_ = weak_factory_.GetWeakPtr(); } @@ -138,39 +139,39 @@ void Me2MeNativeMessagingHost::OnMessage(scoped_ptr<base::Value> message) { response->SetString("type", type + "Response"); if (type == "hello") { - ProcessHello(message_dict.Pass(), response.Pass()); + ProcessHello(std::move(message_dict), std::move(response)); } else if (type == "clearPairedClients") { - ProcessClearPairedClients(message_dict.Pass(), response.Pass()); + ProcessClearPairedClients(std::move(message_dict), std::move(response)); } else if (type == "deletePairedClient") { - ProcessDeletePairedClient(message_dict.Pass(), response.Pass()); + ProcessDeletePairedClient(std::move(message_dict), std::move(response)); } else if (type == "getHostName") { - ProcessGetHostName(message_dict.Pass(), response.Pass()); + ProcessGetHostName(std::move(message_dict), std::move(response)); } else if (type == "getPinHash") { - ProcessGetPinHash(message_dict.Pass(), response.Pass()); + ProcessGetPinHash(std::move(message_dict), std::move(response)); } else if (type == "generateKeyPair") { - ProcessGenerateKeyPair(message_dict.Pass(), response.Pass()); + ProcessGenerateKeyPair(std::move(message_dict), std::move(response)); } else if (type == "updateDaemonConfig") { - ProcessUpdateDaemonConfig(message_dict.Pass(), response.Pass()); + ProcessUpdateDaemonConfig(std::move(message_dict), std::move(response)); } else if (type == "getDaemonConfig") { - ProcessGetDaemonConfig(message_dict.Pass(), response.Pass()); + ProcessGetDaemonConfig(std::move(message_dict), std::move(response)); } else if (type == "getPairedClients") { - ProcessGetPairedClients(message_dict.Pass(), response.Pass()); + ProcessGetPairedClients(std::move(message_dict), std::move(response)); } else if (type == "getUsageStatsConsent") { - ProcessGetUsageStatsConsent(message_dict.Pass(), response.Pass()); + ProcessGetUsageStatsConsent(std::move(message_dict), std::move(response)); } else if (type == "startDaemon") { - ProcessStartDaemon(message_dict.Pass(), response.Pass()); + ProcessStartDaemon(std::move(message_dict), std::move(response)); } else if (type == "stopDaemon") { - ProcessStopDaemon(message_dict.Pass(), response.Pass()); + ProcessStopDaemon(std::move(message_dict), std::move(response)); } else if (type == "getDaemonState") { - ProcessGetDaemonState(message_dict.Pass(), response.Pass()); + ProcessGetDaemonState(std::move(message_dict), std::move(response)); } else if (type == "getHostClientId") { - ProcessGetHostClientId(message_dict.Pass(), response.Pass()); + ProcessGetHostClientId(std::move(message_dict), std::move(response)); } else if (type == "getCredentialsFromAuthCode") { ProcessGetCredentialsFromAuthCode( - message_dict.Pass(), response.Pass(), true); + std::move(message_dict), std::move(response), true); } else if (type == "getRefreshTokenFromAuthCode") { ProcessGetCredentialsFromAuthCode( - message_dict.Pass(), response.Pass(), false); + std::move(message_dict), std::move(response), false); } else { LOG(ERROR) << "Unsupported request type: " << type; OnError(); @@ -192,7 +193,7 @@ void Me2MeNativeMessagingHost::ProcessHello( supported_features_list->AppendStrings(std::vector<std::string>( kSupportedFeatures, kSupportedFeatures + arraysize(kSupportedFeatures))); response->Set("supportedFeatures", supported_features_list.release()); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::ProcessClearPairedClients( @@ -201,8 +202,8 @@ void Me2MeNativeMessagingHost::ProcessClearPairedClients( DCHECK(thread_checker_.CalledOnValidThread()); if (needs_elevation_) { - if (!DelegateToElevatedHost(message.Pass())) - SendBooleanResult(response.Pass(), false); + if (!DelegateToElevatedHost(std::move(message))) + SendBooleanResult(std::move(response), false); return; } @@ -211,7 +212,7 @@ void Me2MeNativeMessagingHost::ProcessClearPairedClients( base::Bind(&Me2MeNativeMessagingHost::SendBooleanResult, weak_ptr_, base::Passed(&response))); } else { - SendBooleanResult(response.Pass(), false); + SendBooleanResult(std::move(response), false); } } @@ -221,8 +222,8 @@ void Me2MeNativeMessagingHost::ProcessDeletePairedClient( DCHECK(thread_checker_.CalledOnValidThread()); if (needs_elevation_) { - if (!DelegateToElevatedHost(message.Pass())) - SendBooleanResult(response.Pass(), false); + if (!DelegateToElevatedHost(std::move(message))) + SendBooleanResult(std::move(response), false); return; } @@ -240,7 +241,7 @@ void Me2MeNativeMessagingHost::ProcessDeletePairedClient( client_id, base::Bind(&Me2MeNativeMessagingHost::SendBooleanResult, weak_ptr_, base::Passed(&response))); } else { - SendBooleanResult(response.Pass(), false); + SendBooleanResult(std::move(response), false); } } @@ -250,7 +251,7 @@ void Me2MeNativeMessagingHost::ProcessGetHostName( DCHECK(thread_checker_.CalledOnValidThread()); response->SetString("hostname", net::GetHostName()); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::ProcessGetPinHash( @@ -271,7 +272,7 @@ void Me2MeNativeMessagingHost::ProcessGetPinHash( return; } response->SetString("hash", MakeHostPinHash(host_id, pin)); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::ProcessGenerateKeyPair( @@ -282,7 +283,7 @@ void Me2MeNativeMessagingHost::ProcessGenerateKeyPair( scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::Generate(); response->SetString("privateKey", key_pair->ToString()); response->SetString("publicKey", key_pair->GetPublicKey()); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::ProcessUpdateDaemonConfig( @@ -291,20 +292,20 @@ void Me2MeNativeMessagingHost::ProcessUpdateDaemonConfig( DCHECK(thread_checker_.CalledOnValidThread()); if (needs_elevation_) { - if (!DelegateToElevatedHost(message.Pass())) - SendAsyncResult(response.Pass(), DaemonController::RESULT_FAILED); + if (!DelegateToElevatedHost(std::move(message))) + SendAsyncResult(std::move(response), DaemonController::RESULT_FAILED); return; } scoped_ptr<base::DictionaryValue> config_dict = - ConfigDictionaryFromMessage(message.Pass()); + ConfigDictionaryFromMessage(std::move(message)); if (!config_dict) { OnError(); return; } daemon_controller_->UpdateConfig( - config_dict.Pass(), + std::move(config_dict), base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, base::Passed(&response))); } @@ -330,7 +331,8 @@ void Me2MeNativeMessagingHost::ProcessGetPairedClients( weak_ptr_, base::Passed(&response))); } else { scoped_ptr<base::ListValue> no_paired_clients(new base::ListValue); - SendPairedClientsResponse(response.Pass(), no_paired_clients.Pass()); + SendPairedClientsResponse(std::move(response), + std::move(no_paired_clients)); } } @@ -350,8 +352,8 @@ void Me2MeNativeMessagingHost::ProcessStartDaemon( DCHECK(thread_checker_.CalledOnValidThread()); if (needs_elevation_) { - if (!DelegateToElevatedHost(message.Pass())) - SendAsyncResult(response.Pass(), DaemonController::RESULT_FAILED); + if (!DelegateToElevatedHost(std::move(message))) + SendAsyncResult(std::move(response), DaemonController::RESULT_FAILED); return; } @@ -363,14 +365,14 @@ void Me2MeNativeMessagingHost::ProcessStartDaemon( } scoped_ptr<base::DictionaryValue> config_dict = - ConfigDictionaryFromMessage(message.Pass()); + ConfigDictionaryFromMessage(std::move(message)); if (!config_dict) { OnError(); return; } daemon_controller_->SetConfigAndStart( - config_dict.Pass(), consent, + std::move(config_dict), consent, base::Bind(&Me2MeNativeMessagingHost::SendAsyncResult, weak_ptr_, base::Passed(&response))); } @@ -381,8 +383,8 @@ void Me2MeNativeMessagingHost::ProcessStopDaemon( DCHECK(thread_checker_.CalledOnValidThread()); if (needs_elevation_) { - if (!DelegateToElevatedHost(message.Pass())) - SendAsyncResult(response.Pass(), DaemonController::RESULT_FAILED); + if (!DelegateToElevatedHost(std::move(message))) + SendAsyncResult(std::move(response), DaemonController::RESULT_FAILED); return; } @@ -417,7 +419,7 @@ void Me2MeNativeMessagingHost::ProcessGetDaemonState( response->SetString("state", "UNKNOWN"); break; } - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::ProcessGetHostClientId( @@ -427,7 +429,7 @@ void Me2MeNativeMessagingHost::ProcessGetHostClientId( response->SetString("clientId", google_apis::GetOAuth2ClientID( google_apis::CLIENT_REMOTING_HOST)); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::ProcessGetCredentialsFromAuthCode( @@ -465,7 +467,7 @@ void Me2MeNativeMessagingHost::SendConfigResponse( } else { response->Set("config", base::Value::CreateNullValue()); } - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::SendPairedClientsResponse( @@ -474,7 +476,7 @@ void Me2MeNativeMessagingHost::SendPairedClientsResponse( DCHECK(thread_checker_.CalledOnValidThread()); response->Set("pairedClients", pairings.release()); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::SendUsageStatsConsentResponse( @@ -485,7 +487,7 @@ void Me2MeNativeMessagingHost::SendUsageStatsConsentResponse( response->SetBoolean("supported", consent.supported); response->SetBoolean("allowed", consent.allowed); response->SetBoolean("setByPolicy", consent.set_by_policy); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::SendAsyncResult( @@ -507,7 +509,7 @@ void Me2MeNativeMessagingHost::SendAsyncResult( response->SetString("result", "FAILED_DIRECTORY"); break; } - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::SendBooleanResult( @@ -515,7 +517,7 @@ void Me2MeNativeMessagingHost::SendBooleanResult( DCHECK(thread_checker_.CalledOnValidThread()); response->SetBoolean("result", result); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::SendCredentialsResponse( @@ -528,7 +530,7 @@ void Me2MeNativeMessagingHost::SendCredentialsResponse( response->SetString("userEmail", user_email); } response->SetString("refreshToken", refresh_token); - channel_->SendMessage(response.Pass()); + channel_->SendMessage(std::move(response)); } void Me2MeNativeMessagingHost::OnError() { @@ -554,7 +556,7 @@ void Me2MeNativeMessagingHost::ElevatedChannelEventHandler::OnMessage( DCHECK(parent_->thread_checker_.CalledOnValidThread()); // Simply pass along the response from the elevated host to the client. - parent_->channel_->SendMessage(message.Pass()); + parent_->channel_->SendMessage(std::move(message)); } void Me2MeNativeMessagingHost::ElevatedChannelEventHandler::OnDisconnect() { @@ -569,7 +571,7 @@ bool Me2MeNativeMessagingHost::DelegateToElevatedHost( // elevated_channel_ will be null if user rejects the UAC request. if (elevated_channel_) - elevated_channel_->SendMessage(message.Pass()); + elevated_channel_->SendMessage(std::move(message)); return elevated_channel_ != nullptr; } diff --git a/remoting/host/setup/me2me_native_messaging_host_main.cc b/remoting/host/setup/me2me_native_messaging_host_main.cc index bac5198..75fd590 100644 --- a/remoting/host/setup/me2me_native_messaging_host_main.cc +++ b/remoting/host/setup/me2me_native_messaging_host_main.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <utility> + #include "base/at_exit.h" #include "base/command_line.h" #include "base/files/file.h" @@ -248,7 +250,7 @@ int StartMe2MeNativeMessagingHost() { return kInitializationFailed; pairing_registry = - new PairingRegistry(io_thread.task_runner(), delegate.Pass()); + new PairingRegistry(io_thread.task_runner(), std::move(delegate)); #else // defined(OS_WIN) pairing_registry = CreatePairingRegistry(io_thread.task_runner()); @@ -256,17 +258,13 @@ int StartMe2MeNativeMessagingHost() { // Set up the native messaging channel. scoped_ptr<extensions::NativeMessagingChannel> channel( - new PipeMessagingChannel(read_file.Pass(), write_file.Pass())); + new PipeMessagingChannel(std::move(read_file), std::move(write_file))); // Create the native messaging host. - scoped_ptr<Me2MeNativeMessagingHost> host( - new Me2MeNativeMessagingHost( - needs_elevation, - static_cast<intptr_t>(native_view_handle), - channel.Pass(), - daemon_controller, - pairing_registry, - oauth_client.Pass())); + scoped_ptr<Me2MeNativeMessagingHost> host(new Me2MeNativeMessagingHost( + needs_elevation, static_cast<intptr_t>(native_view_handle), + std::move(channel), daemon_controller, pairing_registry, + std::move(oauth_client))); host->Start(run_loop.QuitClosure()); // Run the loop until channel is alive. diff --git a/remoting/host/setup/me2me_native_messaging_host_unittest.cc b/remoting/host/setup/me2me_native_messaging_host_unittest.cc index 31a261d..4e0553a 100644 --- a/remoting/host/setup/me2me_native_messaging_host_unittest.cc +++ b/remoting/host/setup/me2me_native_messaging_host_unittest.cc @@ -7,6 +7,8 @@ #include <stddef.h> #include <stdint.h> +#include <utility> + #include "base/compiler_specific.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -327,15 +329,15 @@ void Me2MeNativeMessagingHostTest::StartHost() { make_scoped_ptr(new MockPairingRegistryDelegate())); scoped_ptr<extensions::NativeMessagingChannel> channel( - new PipeMessagingChannel(input_read_file.Pass(), - output_write_file.Pass())); + new PipeMessagingChannel(std::move(input_read_file), + std::move(output_write_file))); scoped_ptr<OAuthClient> oauth_client( new MockOAuthClient("fake_user_email", "fake_refresh_token")); - host_.reset(new Me2MeNativeMessagingHost(false, 0, channel.Pass(), + host_.reset(new Me2MeNativeMessagingHost(false, 0, std::move(channel), daemon_controller, pairing_registry, - oauth_client.Pass())); + std::move(oauth_client))); host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost, base::Unretained(this))); @@ -441,7 +443,7 @@ void Me2MeNativeMessagingHostTest::TestBadRequest(const base::Value& message) { // Read from output pipe, and verify responses. scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); - VerifyHelloResponse(response.Pass()); + VerifyHelloResponse(std::move(response)); response = ReadMessageFromOutputPipe(); EXPECT_FALSE(response); @@ -534,7 +536,7 @@ TEST_F(Me2MeNativeMessagingHostTest, All) { // Call the verification routine corresponding to the message id. ASSERT_TRUE(verify_routines[id]); - verify_routines[id](response.Pass()); + verify_routines[id](std::move(response)); // Clear the pointer so that the routine cannot be called the second time. verify_routines[id] = nullptr; diff --git a/remoting/host/shaped_desktop_capturer.cc b/remoting/host/shaped_desktop_capturer.cc index 8cfbcbc..5976c0c 100644 --- a/remoting/host/shaped_desktop_capturer.cc +++ b/remoting/host/shaped_desktop_capturer.cc @@ -4,6 +4,8 @@ #include "remoting/host/shaped_desktop_capturer.h" +#include <utility> + #include "base/logging.h" #include "remoting/host/desktop_shape_tracker.h" #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" @@ -13,10 +15,9 @@ namespace remoting { ShapedDesktopCapturer::ShapedDesktopCapturer( scoped_ptr<webrtc::DesktopCapturer> desktop_capturer, scoped_ptr<DesktopShapeTracker> shape_tracker) - : desktop_capturer_(desktop_capturer.Pass()), - shape_tracker_(shape_tracker.Pass()), - callback_(nullptr) { -} + : desktop_capturer_(std::move(desktop_capturer)), + shape_tracker_(std::move(shape_tracker)), + callback_(nullptr) {} ShapedDesktopCapturer::~ShapedDesktopCapturer() {} diff --git a/remoting/host/signaling_connector.cc b/remoting/host/signaling_connector.cc index cf1d149..ac5bbaf 100644 --- a/remoting/host/signaling_connector.cc +++ b/remoting/host/signaling_connector.cc @@ -4,6 +4,8 @@ #include "remoting/host/signaling_connector.h" +#include <utility> + #include "base/bind.h" #include "base/callback.h" #include "base/strings/string_util.h" @@ -45,7 +47,7 @@ SignalingConnector::SignalingConnector( const base::Closure& auth_failed_callback) : signal_strategy_(signal_strategy), auth_failed_callback_(auth_failed_callback), - dns_blackhole_checker_(dns_blackhole_checker.Pass()), + dns_blackhole_checker_(std::move(dns_blackhole_checker)), oauth_token_getter_(oauth_token_getter), reconnect_attempts_(0) { DCHECK(!auth_failed_callback_.is_null()); diff --git a/remoting/host/single_window_desktop_environment.cc b/remoting/host/single_window_desktop_environment.cc index 2fe5457..d120932 100644 --- a/remoting/host/single_window_desktop_environment.cc +++ b/remoting/host/single_window_desktop_environment.cc @@ -4,6 +4,8 @@ #include "remoting/host/single_window_desktop_environment.h" +#include <utility> + #include "base/logging.h" #include "base/macros.h" #include "base/single_thread_task_runner.h" @@ -38,8 +40,7 @@ class SingleWindowDesktopEnvironment : public BasicDesktopEnvironment { DISALLOW_COPY_AND_ASSIGN(SingleWindowDesktopEnvironment); }; -SingleWindowDesktopEnvironment::~SingleWindowDesktopEnvironment() { -} +SingleWindowDesktopEnvironment::~SingleWindowDesktopEnvironment() {} scoped_ptr<webrtc::DesktopCapturer> SingleWindowDesktopEnvironment::CreateVideoCapturer() { @@ -49,11 +50,11 @@ SingleWindowDesktopEnvironment::CreateVideoCapturer() { webrtc::DesktopCaptureOptions::CreateDefault(); options.set_use_update_notifications(true); - scoped_ptr<webrtc::WindowCapturer>window_capturer( + scoped_ptr<webrtc::WindowCapturer> window_capturer( webrtc::WindowCapturer::Create(options)); window_capturer->SelectWindow(window_id_); - return window_capturer.Pass(); + return std::move(window_capturer); } scoped_ptr<InputInjector> @@ -64,7 +65,7 @@ SingleWindowDesktopEnvironment::CreateInputInjector() { InputInjector::Create(input_task_runner(), ui_task_runner())); return SingleWindowInputInjector::CreateForWindow( - window_id_, input_injector.Pass()).Pass(); + window_id_, std::move(input_injector)); } SingleWindowDesktopEnvironment::SingleWindowDesktopEnvironment( @@ -105,7 +106,7 @@ scoped_ptr<DesktopEnvironment> SingleWindowDesktopEnvironmentFactory::Create( ui_task_runner(), window_id_, supports_touch_events())); - return desktop_environment.Pass(); + return std::move(desktop_environment); } } // namespace remoting diff --git a/remoting/host/single_window_input_injector_mac.cc b/remoting/host/single_window_input_injector_mac.cc index fe64312..3954fe7 100644 --- a/remoting/host/single_window_input_injector_mac.cc +++ b/remoting/host/single_window_input_injector_mac.cc @@ -7,6 +7,8 @@ #include <ApplicationServices/ApplicationServices.h> #include <Carbon/Carbon.h> +#include <utility> + #include "base/mac/foundation_util.h" #include "base/mac/scoped_cftyperef.h" #include "base/macros.h" @@ -49,15 +51,13 @@ SingleWindowInputInjectorMac::SingleWindowInputInjectorMac( webrtc::WindowId window_id, scoped_ptr<InputInjector> input_injector) : window_id_(static_cast<CGWindowID>(window_id)), - input_injector_(input_injector.Pass()) { -} + input_injector_(std::move(input_injector)) {} -SingleWindowInputInjectorMac::~SingleWindowInputInjectorMac() { -} +SingleWindowInputInjectorMac::~SingleWindowInputInjectorMac() {} void SingleWindowInputInjectorMac::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { - input_injector_->Start(client_clipboard.Pass()); + input_injector_->Start(std::move(client_clipboard)); } void SingleWindowInputInjectorMac::InjectKeyEvent(const KeyEvent& event) { @@ -164,9 +164,8 @@ CGRect SingleWindowInputInjectorMac::FindCGRectOfWindow() { scoped_ptr<InputInjector> SingleWindowInputInjector::CreateForWindow( webrtc::WindowId window_id, scoped_ptr<InputInjector> input_injector) { - scoped_ptr<SingleWindowInputInjectorMac> injector( - new SingleWindowInputInjectorMac(window_id, input_injector.Pass())); - return injector.Pass(); + return make_scoped_ptr( + new SingleWindowInputInjectorMac(window_id, std::move(input_injector))); } } // namespace remoting diff --git a/remoting/host/token_validator_factory_impl.cc b/remoting/host/token_validator_factory_impl.cc index a66d9e5..321722d 100644 --- a/remoting/host/token_validator_factory_impl.cc +++ b/remoting/host/token_validator_factory_impl.cc @@ -6,6 +6,8 @@ #include <stddef.h> +#include <utility> + #include "base/base64.h" #include "base/bind.h" #include "base/callback.h" @@ -94,7 +96,7 @@ void TokenValidatorImpl::StartValidateRequest(const std::string& token) { new net::UploadBytesElementReader( post_body_.data(), post_body_.size())); request_->set_upload( - net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); + net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); request_->Start(); } diff --git a/remoting/host/token_validator_factory_impl_unittest.cc b/remoting/host/token_validator_factory_impl_unittest.cc index 49a9f87..3623039 100644 --- a/remoting/host/token_validator_factory_impl_unittest.cc +++ b/remoting/host/token_validator_factory_impl_unittest.cc @@ -60,7 +60,7 @@ class SetResponseURLRequestContext: public net::TestURLRequestContext { make_scoped_ptr(new net::URLRequestJobFactoryImpl()); factory->SetProtocolHandler( "https", make_scoped_ptr(new FakeProtocolHandler(headers, response))); - context_storage_.set_job_factory(factory.Pass()); + context_storage_.set_job_factory(std::move(factory)); } }; @@ -91,10 +91,9 @@ class TokenValidatorFactoryImplTest : public testing::Test { protected: void SetUp() override { key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); - scoped_ptr<net::TestURLRequestContext> context( - new SetResponseURLRequestContext()); request_context_getter_ = new net::TestURLRequestContextGetter( - message_loop_.task_runner(), context.Pass()); + message_loop_.task_runner(), + make_scoped_ptr(new SetResponseURLRequestContext())); ThirdPartyAuthConfig config; config.token_url = GURL(kTokenUrl); config.token_validation_url = GURL(kTokenValidationUrl); diff --git a/remoting/host/touch_injector_win.cc b/remoting/host/touch_injector_win.cc index 0607e48..6c7c262 100644 --- a/remoting/host/touch_injector_win.cc +++ b/remoting/host/touch_injector_win.cc @@ -4,6 +4,8 @@ #include "remoting/host/touch_injector_win.h" +#include <utility> + #include "base/files/file_path.h" #include "base/logging.h" #include "base/native_library.h" @@ -189,7 +191,7 @@ void TouchInjectorWin::InjectTouchEvent(const TouchEvent& event) { void TouchInjectorWin::SetInjectorDelegateForTest( scoped_ptr<TouchInjectorWinDelegate> functions) { - delegate_ = functions.Pass(); + delegate_ = std::move(functions); } void TouchInjectorWin::AddNewTouchPoints(const TouchEvent& event) { diff --git a/remoting/host/touch_injector_win_unittest.cc b/remoting/host/touch_injector_win_unittest.cc index 326f8b0..785ae65 100644 --- a/remoting/host/touch_injector_win_unittest.cc +++ b/remoting/host/touch_injector_win_unittest.cc @@ -8,6 +8,7 @@ #include <stdint.h> #include <map> +#include <utility> #include "base/stl_util.h" #include "remoting/proto/event.pb.h" @@ -139,7 +140,7 @@ TEST(TouchInjectorWinTest, CheckConversionWithPressure) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(event); @@ -193,7 +194,7 @@ TEST(TouchInjectorWinTest, CheckConversionNoPressure) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(event); } @@ -212,7 +213,7 @@ TEST(TouchInjectorWinTest, InitFailed) { EXPECT_CALL(*delegate_mock, InjectTouchInput(_, _)).Times(0); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_FALSE(injector.Init()); injector.InjectTouchEvent(event); } @@ -258,13 +259,15 @@ TEST(TouchInjectorWinTest, Reinitialize) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock_before_deinitialize.Pass()); + injector.SetInjectorDelegateForTest( + std::move(delegate_mock_before_deinitialize)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(first_event); injector.Deinitialize(); - injector.SetInjectorDelegateForTest(delegate_mock_after_deinitialize.Pass()); + injector.SetInjectorDelegateForTest( + std::move(delegate_mock_after_deinitialize)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(second_event); } @@ -291,7 +294,7 @@ TEST(TouchInjectorWinTest, StartTouchPoint) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(event); } @@ -325,7 +328,7 @@ TEST(TouchInjectorWinTest, MoveTouchPoint) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(event); event.set_event_type(TouchEvent::TOUCH_POINT_MOVE); @@ -360,7 +363,7 @@ TEST(TouchInjectorWinTest, EndTouchPoint) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(event); event.set_event_type(TouchEvent::TOUCH_POINT_END); @@ -395,7 +398,7 @@ TEST(TouchInjectorWinTest, CancelTouchPoint) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_TRUE(injector.Init()); injector.InjectTouchEvent(event); event.set_event_type(TouchEvent::TOUCH_POINT_CANCEL); @@ -464,7 +467,7 @@ TEST(TouchInjectorWinTest, MultiTouch) { .WillOnce(Return(1)); TouchInjectorWin injector; - injector.SetInjectorDelegateForTest(delegate_mock.Pass()); + injector.SetInjectorDelegateForTest(std::move(delegate_mock)); EXPECT_TRUE(injector.Init()); // Start first touch point. diff --git a/remoting/host/video_frame_recorder.cc b/remoting/host/video_frame_recorder.cc index aa48986..3cec5b7 100644 --- a/remoting/host/video_frame_recorder.cc +++ b/remoting/host/video_frame_recorder.cc @@ -4,6 +4,8 @@ #include "remoting/host/video_frame_recorder.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/macros.h" @@ -60,7 +62,7 @@ VideoFrameRecorder::RecordingVideoEncoder::RecordingVideoEncoder( scoped_ptr<VideoEncoder> encoder, scoped_refptr<base::TaskRunner> recorder_task_runner, base::WeakPtr<VideoFrameRecorder> recorder) - : encoder_(encoder.Pass()), + : encoder_(std::move(encoder)), recorder_task_runner_(recorder_task_runner), recorder_(recorder), enable_recording_(false), @@ -134,12 +136,12 @@ scoped_ptr<VideoEncoder> VideoFrameRecorder::WrapVideoEncoder( caller_task_runner_ = base::ThreadTaskRunnerHandle::Get(); scoped_ptr<RecordingVideoEncoder> recording_encoder( - new RecordingVideoEncoder(encoder.Pass(), + new RecordingVideoEncoder(std::move(encoder), caller_task_runner_, weak_factory_.GetWeakPtr())); recording_encoder_ = recording_encoder->AsWeakPtr(); - return recording_encoder.Pass(); + return std::move(recording_encoder); } void VideoFrameRecorder::DetachVideoEncoderWrapper() { @@ -201,7 +203,7 @@ scoped_ptr<webrtc::DesktopFrame> VideoFrameRecorder::NextFrame() { DCHECK_GE(content_bytes_, 0); } - return frame.Pass(); + return frame; } void VideoFrameRecorder::SetEncoderTaskRunner( diff --git a/remoting/host/video_frame_recorder_unittest.cc b/remoting/host/video_frame_recorder_unittest.cc index 27644c8..c005165 100644 --- a/remoting/host/video_frame_recorder_unittest.cc +++ b/remoting/host/video_frame_recorder_unittest.cc @@ -7,6 +7,8 @@ #include <stddef.h> #include <stdint.h> +#include <utility> + #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -123,16 +125,15 @@ void VideoFrameRecorderTest::TearDown() { void VideoFrameRecorderTest::CreateAndWrapEncoder() { scoped_ptr<VideoEncoder> encoder(new VideoEncoderVerbatim()); - encoder_ = recorder_->WrapVideoEncoder(encoder.Pass()); + encoder_ = recorder_->WrapVideoEncoder(std::move(encoder)); // Encode a dummy frame to bind the wrapper to the TaskRunner. EncodeDummyFrame(); } scoped_ptr<webrtc::DesktopFrame> VideoFrameRecorderTest::CreateNextFrame() { - scoped_ptr<webrtc::DesktopFrame> frame( - new webrtc::BasicDesktopFrame(webrtc::DesktopSize(kFrameWidth, - kFrameHeight))); + scoped_ptr<webrtc::DesktopFrame> frame(new webrtc::BasicDesktopFrame( + webrtc::DesktopSize(kFrameWidth, kFrameHeight))); // Fill content, DPI and updated-region based on |frame_count_| so that each // generated frame is different. @@ -142,7 +143,7 @@ scoped_ptr<webrtc::DesktopFrame> VideoFrameRecorderTest::CreateNextFrame() { frame->mutable_updated_region()->SetRect( webrtc::DesktopRect::MakeWH(frame_count_, frame_count_)); - return frame.Pass(); + return frame; } void VideoFrameRecorderTest::CreateTestFrames() { diff --git a/remoting/host/win/launch_process_with_token.cc b/remoting/host/win/launch_process_with_token.cc index 27689ad..a274b33 100644 --- a/remoting/host/win/launch_process_with_token.cc +++ b/remoting/host/win/launch_process_with_token.cc @@ -9,6 +9,7 @@ #include <winternl.h> #include <limits> +#include <utility> #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -117,7 +118,7 @@ bool ConnectToExecutionServer(uint32_t session_id, return false; } - *pipe_out = pipe.Pass(); + *pipe_out = std::move(pipe); return true; } @@ -172,7 +173,7 @@ bool CreatePrivilegedToken(ScopedHandle* token_out) { return false; } - *token_out = privileged_token.Pass(); + *token_out = std::move(privileged_token); return true; } @@ -444,7 +445,7 @@ bool CreateSessionToken(uint32_t session_id, ScopedHandle* token_out) { // Revert to the default token. CHECK(RevertToSelf()); - *token_out = session_token.Pass(); + *token_out = std::move(session_token); return true; } diff --git a/remoting/host/win/security_descriptor.cc b/remoting/host/win/security_descriptor.cc index fffefe5..c316ff7 100644 --- a/remoting/host/win/security_descriptor.cc +++ b/remoting/host/win/security_descriptor.cc @@ -24,7 +24,7 @@ ScopedSd ConvertSddlToSd(const std::string& sddl) { memcpy(sd.get(), raw_sd, length); LocalFree(raw_sd); - return sd.Pass(); + return sd; } // Converts a SID into a text string. @@ -59,7 +59,7 @@ ScopedSid GetLogonSid(HANDLE token) { if (!CopySid(length, logon_sid.get(), groups->Groups[i].Sid)) return ScopedSid(); - return logon_sid.Pass(); + return logon_sid; } } diff --git a/remoting/host/win/session_desktop_environment.cc b/remoting/host/win/session_desktop_environment.cc index b903fa0..045562f 100644 --- a/remoting/host/win/session_desktop_environment.cc +++ b/remoting/host/win/session_desktop_environment.cc @@ -4,6 +4,8 @@ #include "remoting/host/win/session_desktop_environment.h" +#include <utility> + #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "remoting/host/audio_capturer.h" @@ -14,19 +16,15 @@ namespace remoting { -SessionDesktopEnvironment::~SessionDesktopEnvironment() { -} +SessionDesktopEnvironment::~SessionDesktopEnvironment() {} scoped_ptr<InputInjector> SessionDesktopEnvironment::CreateInputInjector() { DCHECK(caller_task_runner()->BelongsToCurrentThread()); - scoped_ptr<InputInjector> input_injector = InputInjector::Create( - input_task_runner(), ui_task_runner()); - input_injector.reset(new SessionInputInjectorWin(input_task_runner(), - input_injector.Pass(), - ui_task_runner(), - inject_sas_)); - return input_injector.Pass(); + return make_scoped_ptr(new SessionInputInjectorWin( + input_task_runner(), + InputInjector::Create(input_task_runner(), ui_task_runner()), + ui_task_runner(), inject_sas_)); } SessionDesktopEnvironment::SessionDesktopEnvironment( @@ -62,17 +60,15 @@ scoped_ptr<DesktopEnvironment> SessionDesktopEnvironmentFactory::Create( DCHECK(caller_task_runner()->BelongsToCurrentThread()); scoped_ptr<SessionDesktopEnvironment> desktop_environment( - new SessionDesktopEnvironment(caller_task_runner(), - input_task_runner(), - ui_task_runner(), - inject_sas_, + new SessionDesktopEnvironment(caller_task_runner(), input_task_runner(), + ui_task_runner(), inject_sas_, supports_touch_events())); if (!desktop_environment->InitializeSecurity(client_session_control, curtain_enabled())) { return nullptr; } - return desktop_environment.Pass(); + return std::move(desktop_environment); } } // namespace remoting diff --git a/remoting/host/win/session_input_injector.cc b/remoting/host/win/session_input_injector.cc index 22c88b9..ce0ec31 100644 --- a/remoting/host/win/session_input_injector.cc +++ b/remoting/host/win/session_input_injector.cc @@ -8,6 +8,7 @@ #include <set> #include <string> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -100,10 +101,9 @@ SessionInputInjectorWin::Core::Core( scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, const base::Closure& inject_sas) : input_task_runner_(input_task_runner), - nested_executor_(nested_executor.Pass()), + nested_executor_(std::move(nested_executor)), inject_sas_task_runner_(inject_sas_task_runner), - inject_sas_(inject_sas) { -} + inject_sas_(inject_sas) {} void SessionInputInjectorWin::Core::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { @@ -114,7 +114,7 @@ void SessionInputInjectorWin::Core::Start( return; } - nested_executor_->Start(client_clipboard.Pass()); + nested_executor_->Start(std::move(client_clipboard)); } void SessionInputInjectorWin::Core::InjectClipboardEvent( @@ -219,7 +219,7 @@ SessionInputInjectorWin::SessionInputInjectorWin( scoped_ptr<InputInjector> nested_executor, scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, const base::Closure& inject_sas) { - core_ = new Core(input_task_runner, nested_executor.Pass(), + core_ = new Core(input_task_runner, std::move(nested_executor), inject_sas_task_runner, inject_sas); } @@ -228,7 +228,7 @@ SessionInputInjectorWin::~SessionInputInjectorWin() { void SessionInputInjectorWin::Start( scoped_ptr<protocol::ClipboardStub> client_clipboard) { - core_->Start(client_clipboard.Pass()); + core_->Start(std::move(client_clipboard)); } void SessionInputInjectorWin::InjectClipboardEvent( diff --git a/remoting/host/win/unprivileged_process_delegate.cc b/remoting/host/win/unprivileged_process_delegate.cc index 3290d9d..b7fb879 100644 --- a/remoting/host/win/unprivileged_process_delegate.cc +++ b/remoting/host/win/unprivileged_process_delegate.cc @@ -10,6 +10,8 @@ #include <sddl.h> +#include <utility> + #include "base/command_line.h" #include "base/files/file.h" #include "base/logging.h" @@ -237,9 +239,8 @@ UnprivilegedProcessDelegate::UnprivilegedProcessDelegate( scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, scoped_ptr<base::CommandLine> target_command) : io_task_runner_(io_task_runner), - target_command_(target_command.Pass()), - event_handler_(nullptr) { -} + target_command_(std::move(target_command)), + event_handler_(nullptr) {} UnprivilegedProcessDelegate::~UnprivilegedProcessDelegate() { DCHECK(CalledOnValidThread()); @@ -316,7 +317,7 @@ void UnprivilegedProcessDelegate::LaunchProcess( // Create our own window station and desktop accessible by |logon_sid|. WindowStationAndDesktop handles; - if (!CreateWindowStationAndDesktop(logon_sid.Pass(), &handles)) { + if (!CreateWindowStationAndDesktop(std::move(logon_sid), &handles)) { PLOG(ERROR) << "Failed to create a window station and desktop"; ReportFatalError(); return; @@ -325,23 +326,17 @@ void UnprivilegedProcessDelegate::LaunchProcess( // Try to launch the worker process. The launched process inherits // the window station, desktop and pipe handles, created above. ScopedHandle worker_thread; - if (!LaunchProcessWithToken(command_line.GetProgram(), - command_line.GetCommandLineString(), - token.Get(), - &process_attributes, - &thread_attributes, - true, - 0, - nullptr, - &worker_process, - &worker_thread)) { + if (!LaunchProcessWithToken( + command_line.GetProgram(), command_line.GetCommandLineString(), + token.Get(), &process_attributes, &thread_attributes, true, 0, + nullptr, &worker_process, &worker_thread)) { ReportFatalError(); return; } } - channel_ = server.Pass(); - ReportProcessLaunched(worker_process.Pass()); + channel_ = std::move(server); + ReportProcessLaunched(std::move(worker_process)); } void UnprivilegedProcessDelegate::Send(IPC::Message* message) { @@ -415,19 +410,15 @@ void UnprivilegedProcessDelegate::ReportProcessLaunched( DCHECK(CalledOnValidThread()); DCHECK(!worker_process_.IsValid()); - worker_process_ = worker_process.Pass(); + worker_process_ = std::move(worker_process); // Report a handle that can be used to wait for the worker process completion, // query information about the process and duplicate handles. DWORD desired_access = SYNCHRONIZE | PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION; HANDLE temp_handle; - if (!DuplicateHandle(GetCurrentProcess(), - worker_process_.Get(), - GetCurrentProcess(), - &temp_handle, - desired_access, - FALSE, + if (!DuplicateHandle(GetCurrentProcess(), worker_process_.Get(), + GetCurrentProcess(), &temp_handle, desired_access, FALSE, 0)) { PLOG(ERROR) << "Failed to duplicate a handle"; ReportFatalError(); @@ -435,7 +426,7 @@ void UnprivilegedProcessDelegate::ReportProcessLaunched( } ScopedHandle limited_handle(temp_handle); - event_handler_->OnProcessLaunched(limited_handle.Pass()); + event_handler_->OnProcessLaunched(std::move(limited_handle)); } } // namespace remoting diff --git a/remoting/host/win/worker_process_launcher.cc b/remoting/host/win/worker_process_launcher.cc index ebb69dd..941fefb 100644 --- a/remoting/host/win/worker_process_launcher.cc +++ b/remoting/host/win/worker_process_launcher.cc @@ -4,6 +4,8 @@ #include "remoting/host/win/worker_process_launcher.h" +#include <utility> + #include "base/location.h" #include "base/logging.h" #include "base/single_thread_task_runner.h" @@ -48,14 +50,13 @@ const int kLaunchResultTimeoutSeconds = 5; namespace remoting { -WorkerProcessLauncher::Delegate::~Delegate() { -} +WorkerProcessLauncher::Delegate::~Delegate() {} WorkerProcessLauncher::WorkerProcessLauncher( scoped_ptr<WorkerProcessLauncher::Delegate> launcher_delegate, WorkerProcessIpcDelegate* ipc_handler) : ipc_handler_(ipc_handler), - launcher_delegate_(launcher_delegate.Pass()), + launcher_delegate_(std::move(launcher_delegate)), exit_code_(CONTROL_C_EXIT), ipc_enabled_(false), kill_process_timeout_( @@ -119,7 +120,7 @@ void WorkerProcessLauncher::OnProcessLaunched( } ipc_enabled_ = true; - worker_process_ = worker_process.Pass(); + worker_process_ = std::move(worker_process); } void WorkerProcessLauncher::OnFatalError() { diff --git a/remoting/host/win/worker_process_launcher_unittest.cc b/remoting/host/win/worker_process_launcher_unittest.cc index 47496be..840c2d5 100644 --- a/remoting/host/win/worker_process_launcher_unittest.cc +++ b/remoting/host/win/worker_process_launcher_unittest.cc @@ -2,8 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "remoting/host/win/worker_process_launcher.h" + #include <stdint.h> +#include <utility> + #include "base/bind.h" #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -19,7 +23,6 @@ #include "remoting/host/host_exit_codes.h" #include "remoting/host/ipc_util.h" #include "remoting/host/win/launch_process_with_token.h" -#include "remoting/host/win/worker_process_launcher.h" #include "remoting/host/worker_process_ipc_delegate.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock_mutant.h" @@ -316,9 +319,8 @@ void WorkerProcessLauncherTest::CrashWorker() { } void WorkerProcessLauncherTest::StartWorker() { - launcher_.reset(new WorkerProcessLauncher( - launcher_delegate_.Pass(), - &server_listener_)); + launcher_.reset(new WorkerProcessLauncher(std::move(launcher_delegate_), + &server_listener_)); launcher_->SetKillProcessTimeoutForTest(base::TimeDelta::FromMilliseconds(0)); } @@ -371,16 +373,10 @@ void WorkerProcessLauncherTest::DoLaunchProcess() { task_runner_); HANDLE temp_handle; - ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), - worker_process_.Get(), - GetCurrentProcess(), - &temp_handle, - 0, - FALSE, + ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), worker_process_.Get(), + GetCurrentProcess(), &temp_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)); - ScopedHandle copy(temp_handle); - - event_handler_->OnProcessLaunched(copy.Pass()); + event_handler_->OnProcessLaunched(ScopedHandle(temp_handle)); } TEST_F(WorkerProcessLauncherTest, Start) { diff --git a/remoting/host/win/wts_session_process_delegate.cc b/remoting/host/win/wts_session_process_delegate.cc index 4a2a30d..c2ba5d6 100644 --- a/remoting/host/win/wts_session_process_delegate.cc +++ b/remoting/host/win/wts_session_process_delegate.cc @@ -7,6 +7,8 @@ #include "remoting/host/win/wts_session_process_delegate.h" +#include <utility> + #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_path.h" @@ -89,10 +91,10 @@ class WtsSessionProcessDelegate::Core // Creates and initializes the job object that will sandbox the launched child // processes. - void InitializeJob(scoped_ptr<base::win::ScopedHandle> job); + void InitializeJob(ScopedHandle job); // Notified that the job object initialization is complete. - void InitializeJobCompleted(scoped_ptr<base::win::ScopedHandle> job); + void InitializeJobCompleted(ScopedHandle job); // Called when the number of processes running in the job reaches zero. void OnActiveProcessZero(); @@ -155,8 +157,7 @@ WtsSessionProcessDelegate::Core::Core( get_named_pipe_client_pid_(nullptr), launch_elevated_(launch_elevated), launch_pending_(false), - target_command_(target_command.Pass()) { -} + target_command_(std::move(target_command)) {} bool WtsSessionProcessDelegate::Core::Initialize(uint32_t session_id) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); @@ -198,19 +199,13 @@ bool WtsSessionProcessDelegate::Core::Initialize(uint32_t session_id) { return false; } - // ScopedHandle is not compatible with base::Passed, so we wrap it to - // a scoped pointer. - scoped_ptr<ScopedHandle> job_wrapper(new ScopedHandle()); - *job_wrapper = job.Pass(); - // To receive job object notifications the job object is registered with // the completion port represented by |io_task_runner|. The registration has // to be done on the I/O thread because // MessageLoopForIO::RegisterJobObject() can only be called via // MessageLoopForIO::current(). io_task_runner_->PostTask( - FROM_HERE, - base::Bind(&Core::InitializeJob, this, base::Passed(&job_wrapper))); + FROM_HERE, base::Bind(&Core::InitializeJob, this, base::Passed(&job))); } // Create a session token for the launched process. @@ -331,7 +326,7 @@ void WtsSessionProcessDelegate::Core::OnChannelConnected(int32_t peer_pid) { return; } - ReportProcessLaunched(worker_process.Pass()); + ReportProcessLaunched(std::move(worker_process)); } if (event_handler_) @@ -422,14 +417,14 @@ void WtsSessionProcessDelegate::Core::DoLaunchProcess() { return; } - channel_ = channel.Pass(); - pipe_ = pipe.Pass(); + channel_ = std::move(channel); + pipe_ = std::move(pipe); // Report success if the worker process is lauched directly. Otherwise, PID of // the client connected to the pipe will be used later. See // OnChannelConnected(). if (!launch_elevated_) - ReportProcessLaunched(worker_process.Pass()); + ReportProcessLaunched(std::move(worker_process)); } void WtsSessionProcessDelegate::Core::DrainJobNotifications() { @@ -455,12 +450,11 @@ void WtsSessionProcessDelegate::Core::DrainJobNotificationsCompleted() { } } -void WtsSessionProcessDelegate::Core::InitializeJob( - scoped_ptr<base::win::ScopedHandle> job) { +void WtsSessionProcessDelegate::Core::InitializeJob(ScopedHandle job) { DCHECK(io_task_runner_->BelongsToCurrentThread()); // Register to receive job notifications via the I/O thread's completion port. - if (!base::MessageLoopForIO::current()->RegisterJobObject(job->Get(), this)) { + if (!base::MessageLoopForIO::current()->RegisterJobObject(job.Get(), this)) { PLOG(ERROR) << "Failed to associate the job object with a completion port"; return; } @@ -470,12 +464,11 @@ void WtsSessionProcessDelegate::Core::InitializeJob( &Core::InitializeJobCompleted, this, base::Passed(&job))); } -void WtsSessionProcessDelegate::Core::InitializeJobCompleted( - scoped_ptr<ScopedHandle> job) { +void WtsSessionProcessDelegate::Core::InitializeJobCompleted(ScopedHandle job) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); DCHECK(!job_.IsValid()); - job_ = job->Pass(); + job_ = std::move(job); if (launch_pending_) DoLaunchProcess(); @@ -507,19 +500,15 @@ void WtsSessionProcessDelegate::Core::ReportProcessLaunched( DCHECK(caller_task_runner_->BelongsToCurrentThread()); DCHECK(!worker_process_.IsValid()); - worker_process_ = worker_process.Pass(); + worker_process_ = std::move(worker_process); // Report a handle that can be used to wait for the worker process completion, // query information about the process and duplicate handles. DWORD desired_access = SYNCHRONIZE | PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION; HANDLE temp_handle; - if (!DuplicateHandle(GetCurrentProcess(), - worker_process_.Get(), - GetCurrentProcess(), - &temp_handle, - desired_access, - FALSE, + if (!DuplicateHandle(GetCurrentProcess(), worker_process_.Get(), + GetCurrentProcess(), &temp_handle, desired_access, FALSE, 0)) { PLOG(ERROR) << "Failed to duplicate a handle"; ReportFatalError(); @@ -527,7 +516,7 @@ void WtsSessionProcessDelegate::Core::ReportProcessLaunched( } ScopedHandle limited_handle(temp_handle); - event_handler_->OnProcessLaunched(limited_handle.Pass()); + event_handler_->OnProcessLaunched(std::move(limited_handle)); } WtsSessionProcessDelegate::WtsSessionProcessDelegate( @@ -535,9 +524,7 @@ WtsSessionProcessDelegate::WtsSessionProcessDelegate( scoped_ptr<base::CommandLine> target_command, bool launch_elevated, const std::string& channel_security) { - core_ = new Core(io_task_runner, - target_command.Pass(), - launch_elevated, + core_ = new Core(io_task_runner, std::move(target_command), launch_elevated, channel_security); } |