Skip to content

Commit

Permalink
Use std::move() instead of .Pass() in remoting/*
Browse files Browse the repository at this point in the history
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/1545723002

Cr-Commit-Position: refs/heads/master@{#366778}
  • Loading branch information
SergeyUlanov authored and Commit bot committed Dec 24, 2015
1 parent 2e53cb5 commit 42ad7c0
Show file tree
Hide file tree
Showing 46 changed files with 227 additions and 203 deletions.
2 changes: 1 addition & 1 deletion remoting/base/auto_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ scoped_ptr<base::win::ScopedCOMInitializer> CreateComInitializer(
} else if (type == AutoThread::COM_INIT_STA) {
initializer.reset(new base::win::ScopedCOMInitializer());
}
return initializer.Pass();
return initializer;
}
#endif

Expand Down
5 changes: 2 additions & 3 deletions remoting/base/buffered_socket_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ scoped_ptr<BufferedSocketWriter> BufferedSocketWriter::CreateForSocket(
const WriteFailedCallback& write_failed_callback) {
scoped_ptr<BufferedSocketWriter> result(new BufferedSocketWriter());
result->Init(base::Bind(&WriteNetSocket, socket), write_failed_callback);
return result.Pass();
return result;
}

BufferedSocketWriter::BufferedSocketWriter() : weak_factory_(this) {
}
BufferedSocketWriter::BufferedSocketWriter() : weak_factory_(this) {}

BufferedSocketWriter::~BufferedSocketWriter() {
STLDeleteElements(&queue_);
Expand Down
7 changes: 4 additions & 3 deletions remoting/base/rsa_key_pair.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <limits>
#include <string>
#include <utility>
#include <vector>

#include "base/base64.h"
Expand All @@ -21,7 +22,7 @@
namespace remoting {

RsaKeyPair::RsaKeyPair(scoped_ptr<crypto::RSAPrivateKey> key)
: key_(key.Pass()){
: key_(std::move(key)){
DCHECK(key_);
}

Expand All @@ -34,7 +35,7 @@ scoped_refptr<RsaKeyPair> RsaKeyPair::Generate() {
LOG(ERROR) << "Cannot generate private key.";
return NULL;
}
return new RsaKeyPair(key.Pass());
return new RsaKeyPair(std::move(key));
}

// static
Expand All @@ -54,7 +55,7 @@ scoped_refptr<RsaKeyPair> RsaKeyPair::FromString(
return NULL;
}

return new RsaKeyPair(key.Pass());
return new RsaKeyPair(std::move(key));
}

std::string RsaKeyPair::ToString() const {
Expand Down
5 changes: 4 additions & 1 deletion remoting/base/typed_buffer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// found in the LICENSE file.

#include "remoting/base/typed_buffer.h"

#include <utility>

#include "testing/gtest/include/gtest/gtest.h"

namespace remoting {
Expand Down Expand Up @@ -57,7 +60,7 @@ TEST(TypedBufferTest, Pass) {
EXPECT_EQ(right.length(), sizeof(int));

Data* raw_ptr = right.get();
left = right.Pass();
left = std::move(right);

// Verify that passing ownership transfers both the buffer pointer and its
// length.
Expand Down
6 changes: 4 additions & 2 deletions remoting/base/url_request_context_getter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "remoting/base/url_request_context_getter.h"

#include <utility>

#include "base/single_thread_task_runner.h"
#include "net/proxy/proxy_config_service.h"
#include "net/url_request/url_request_context.h"
Expand All @@ -28,8 +30,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
net_log_.reset(new VlogNetLog());
builder.set_net_log(net_log_.get());
builder.DisableHttpCache();
builder.set_proxy_config_service(proxy_config_service_.Pass());
url_request_context_ = builder.Build().Pass();
builder.set_proxy_config_service(std::move(proxy_config_service_));
url_request_context_ = builder.Build();
}
return url_request_context_.get();
}
Expand Down
16 changes: 8 additions & 8 deletions remoting/client/audio_decode_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "remoting/client/audio_decode_scheduler.h"

#include <utility>

#include "base/bind.h"
#include "base/location.h"
#include "base/macros.h"
Expand Down Expand Up @@ -53,11 +55,9 @@ AudioDecodeScheduler::Core::Core(
scoped_ptr<AudioPlayer> audio_player)
: main_task_runner_(main_task_runner),
audio_decode_task_runner_(audio_decode_task_runner),
audio_player_(audio_player.Pass()) {
}
audio_player_(std::move(audio_player)) {}

AudioDecodeScheduler::Core::~Core() {
}
AudioDecodeScheduler::Core::~Core() {}

void AudioDecodeScheduler::Core::Initialize(
const protocol::SessionConfig& config) {
Expand All @@ -83,7 +83,7 @@ void AudioDecodeScheduler::Core::DecodePacket(
scoped_ptr<AudioPacket> packet,
const base::Closure& done) {
DCHECK(audio_decode_task_runner_->BelongsToCurrentThread());
scoped_ptr<AudioPacket> decoded_packet = decoder_->Decode(packet.Pass());
scoped_ptr<AudioPacket> decoded_packet = decoder_->Decode(std::move(packet));

main_task_runner_->PostTask(FROM_HERE, base::Bind(
&AudioDecodeScheduler::Core::ProcessDecodedPacket, this,
Expand All @@ -96,7 +96,7 @@ void AudioDecodeScheduler::Core::ProcessDecodedPacket(
DCHECK(main_task_runner_->BelongsToCurrentThread());
// Only process |packet| if it is non-null.
if (packet.get() && audio_player_.get())
audio_player_->ProcessAudioPacket(packet.Pass());
audio_player_->ProcessAudioPacket(std::move(packet));
done.Run();
}

Expand All @@ -105,7 +105,7 @@ AudioDecodeScheduler::AudioDecodeScheduler(
scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner,
scoped_ptr<AudioPlayer> audio_player)
: core_(new Core(main_task_runner, audio_decode_task_runner,
audio_player.Pass())) {
std::move(audio_player))) {
}

AudioDecodeScheduler::~AudioDecodeScheduler() {
Expand All @@ -118,7 +118,7 @@ void AudioDecodeScheduler::Initialize(const protocol::SessionConfig& config) {

void AudioDecodeScheduler::ProcessAudioPacket(scoped_ptr<AudioPacket> packet,
const base::Closure& done) {
core_->ProcessAudioPacket(packet.Pass(), done);
core_->ProcessAudioPacket(std::move(packet), done);
}

} // namespace remoting
2 changes: 1 addition & 1 deletion remoting/client/audio_player_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ scoped_ptr<AudioPacket> CreatePacketWithSamplingRate(
data.resize(samples * kAudioSampleBytes, kDummyAudioData);
packet->add_data(data);

return packet.Pass();
return packet;
}

scoped_ptr<AudioPacket> CreatePacket44100Hz(int samples) {
Expand Down
17 changes: 12 additions & 5 deletions remoting/client/chromoting_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "remoting/client/chromoting_client.h"

#include <utility>

#include "remoting/base/capabilities.h"
#include "remoting/client/audio_decode_scheduler.h"
#include "remoting/client/audio_player.h"
Expand Down Expand Up @@ -32,7 +34,7 @@ ChromotingClient::ChromotingClient(ClientContext* client_context,
if (audio_player) {
audio_decode_scheduler_.reset(new AudioDecodeScheduler(
client_context->main_task_runner(),
client_context->audio_decode_task_runner(), audio_player.Pass()));
client_context->audio_decode_task_runner(), std::move(audio_player)));
}
}

Expand All @@ -41,9 +43,14 @@ ChromotingClient::~ChromotingClient() {
signal_strategy_->RemoveListener(this);
}

void ChromotingClient::set_protocol_config(
scoped_ptr<protocol::CandidateSessionConfig> config) {
protocol_config_ = std::move(config);
}

void ChromotingClient::SetConnectionToHostForTests(
scoped_ptr<protocol::ConnectionToHost> connection_to_host) {
connection_ = connection_to_host.Pass();
connection_ = std::move(connection_to_host);
}

void ChromotingClient::Start(
Expand Down Expand Up @@ -71,9 +78,9 @@ void ChromotingClient::Start(
protocol_config_ = protocol::CandidateSessionConfig::CreateDefault();
if (!audio_decode_scheduler_)
protocol_config_->DisableAudioChannel();
session_manager_->set_protocol_config(protocol_config_.Pass());
session_manager_->set_protocol_config(std::move(protocol_config_));

authenticator_ = authenticator.Pass();
authenticator_ = std::move(authenticator);

signal_strategy_ = signal_strategy;
signal_strategy_->AddListener(this);
Expand Down Expand Up @@ -195,7 +202,7 @@ bool ChromotingClient::OnSignalStrategyIncomingStanza(
void ChromotingClient::StartConnection() {
DCHECK(thread_checker_.CalledOnValidThread());
connection_->Connect(
session_manager_->Connect(host_jid_, authenticator_.Pass()), this);
session_manager_->Connect(host_jid_, std::move(authenticator_)), this);
}

void ChromotingClient::OnAuthenticated() {
Expand Down
5 changes: 1 addition & 4 deletions remoting/client/chromoting_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ class ChromotingClient : public SignalStrategy::Listener,

~ChromotingClient() override;

void set_protocol_config(
scoped_ptr<protocol::CandidateSessionConfig> config) {
protocol_config_ = config.Pass();
}
void set_protocol_config(scoped_ptr<protocol::CandidateSessionConfig> config);

// Used to set fake/mock objects for tests which use the ChromotingClient.
void SetConnectionToHostForTests(
Expand Down
8 changes: 5 additions & 3 deletions remoting/client/jni/chromoting_jni_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <android/log.h>
#include <stdint.h>

#include <utility>

#include "base/bind.h"
#include "base/logging.h"
#include "jingle/glue/thread_wrapper.h"
Expand Down Expand Up @@ -86,7 +88,7 @@ ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime,
authenticator_.reset(new protocol::NegotiatingClientAuthenticator(
pairing_id, pairing_secret, host_id_,
base::Bind(&ChromotingJniInstance::FetchSecret, this),
token_fetcher.Pass(), auth_methods));
std::move(token_fetcher), auth_methods));

// Post a task to start connection
jni_runtime_->network_task_runner()->PostTask(
Expand Down Expand Up @@ -430,10 +432,10 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() {

scoped_refptr<protocol::TransportContext> transport_context =
new protocol::TransportContext(
signaling_.get(), port_allocator_factory.Pass(), network_settings,
signaling_.get(), std::move(port_allocator_factory), network_settings,
protocol::TransportRole::CLIENT);

client_->Start(signaling_.get(), authenticator_.Pass(), transport_context,
client_->Start(signaling_.get(), std::move(authenticator_), transport_context,
host_jid_, capabilities_);
}

Expand Down
Loading

0 comments on commit 42ad7c0

Please sign in to comment.