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

Unified Diff: remoting/host/setup/me2me_native_messaging_host.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/setup/me2me_native_messaging_host.cc
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc
index 37c004d0453f0422c5044e5110e4ce094c6d6fa1..ebf0f7b9c5803be31115d3d8ef1c95d955b0f2d6 100644
--- a/remoting/host/setup/me2me_native_messaging_host.cc
+++ b/remoting/host/setup/me2me_native_messaging_host.cc
@@ -64,7 +64,7 @@ scoped_ptr<base::DictionaryValue> ConfigDictionaryFromMessage(
} else {
LOG(ERROR) << "'config' dictionary not found";
}
- return result.Pass();
+ return result;
}
} // namespace
@@ -82,13 +82,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();
}
@@ -136,39 +136,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();
@@ -190,7 +190,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(
@@ -199,8 +199,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;
}
@@ -209,7 +209,7 @@ void Me2MeNativeMessagingHost::ProcessClearPairedClients(
base::Bind(&Me2MeNativeMessagingHost::SendBooleanResult, weak_ptr_,
base::Passed(&response)));
} else {
- SendBooleanResult(response.Pass(), false);
+ SendBooleanResult(std::move(response), false);
}
}
@@ -219,8 +219,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;
}
@@ -238,7 +238,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);
}
}
@@ -248,7 +248,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(
@@ -269,7 +269,7 @@ void Me2MeNativeMessagingHost::ProcessGetPinHash(
return;
}
response->SetString("hash", MakeHostPinHash(host_id, pin));
- channel_->SendMessage(response.Pass());
+ channel_->SendMessage(std::move(response));
}
void Me2MeNativeMessagingHost::ProcessGenerateKeyPair(
@@ -280,7 +280,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(
@@ -289,20 +289,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)));
}
@@ -328,7 +328,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));
}
}
@@ -348,8 +349,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;
}
@@ -361,14 +362,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)));
}
@@ -379,8 +380,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;
}
@@ -415,7 +416,7 @@ void Me2MeNativeMessagingHost::ProcessGetDaemonState(
response->SetString("state", "UNKNOWN");
break;
}
- channel_->SendMessage(response.Pass());
+ channel_->SendMessage(std::move(response));
}
void Me2MeNativeMessagingHost::ProcessGetHostClientId(
@@ -425,7 +426,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(
@@ -463,7 +464,7 @@ void Me2MeNativeMessagingHost::SendConfigResponse(
} else {
response->Set("config", base::Value::CreateNullValue());
}
- channel_->SendMessage(response.Pass());
+ channel_->SendMessage(std::move(response));
}
void Me2MeNativeMessagingHost::SendPairedClientsResponse(
@@ -472,7 +473,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(
@@ -483,7 +484,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(
@@ -505,7 +506,7 @@ void Me2MeNativeMessagingHost::SendAsyncResult(
response->SetString("result", "FAILED_DIRECTORY");
break;
}
- channel_->SendMessage(response.Pass());
+ channel_->SendMessage(std::move(response));
}
void Me2MeNativeMessagingHost::SendBooleanResult(
@@ -513,7 +514,7 @@ void Me2MeNativeMessagingHost::SendBooleanResult(
DCHECK(thread_checker_.CalledOnValidThread());
response->SetBoolean("result", result);
- channel_->SendMessage(response.Pass());
+ channel_->SendMessage(std::move(response));
}
void Me2MeNativeMessagingHost::SendCredentialsResponse(
@@ -526,7 +527,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() {
@@ -552,7 +553,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() {
@@ -567,7 +568,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;
}

Powered by Google App Engine
This is Rietveld 408576698