Commit 94cd4e50 authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Clean up move() in //components/policy/core/common/cloud/

Refactor the code to make it clearer that there's no
use-after-move bug, both for the reader and for the
"bugprone-use-after-move" clang-tidy check.

Bug: 1122844
Change-Id: I9e1983c60ca76992c87d825223e0c24c5b818002
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382114Reviewed-by: default avatarAlexander Hendrich <hendrich@chromium.org>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803081}
parent 7387e33c
...@@ -696,15 +696,16 @@ void CloudPolicyClient::GetDeviceAttributeUpdatePermission( ...@@ -696,15 +696,16 @@ void CloudPolicyClient::GetDeviceAttributeUpdatePermission(
// (https://crbug.com/942013). // (https://crbug.com/942013).
// DCHECK(auth->has_oauth_token() || auth->has_enrollment_token()); // DCHECK(auth->has_oauth_token() || auth->has_enrollment_token());
bool has_oauth_token = auth->has_oauth_token(); const bool has_oauth_token = auth->has_oauth_token();
const std::string oauth_token =
has_oauth_token ? auth->oauth_token() : std::string();
std::unique_ptr<DMServerJobConfiguration> config = std::unique_ptr<DMServerJobConfiguration> config =
std::make_unique<DMServerJobConfiguration>( std::make_unique<DMServerJobConfiguration>(
DeviceManagementService::JobConfiguration:: DeviceManagementService::JobConfiguration::
TYPE_ATTRIBUTE_UPDATE_PERMISSION, TYPE_ATTRIBUTE_UPDATE_PERMISSION,
this, this,
/*critical=*/false, /*critical=*/false,
!has_oauth_token ? std::move(auth) : DMAuth::NoAuth(), !has_oauth_token ? std::move(auth) : DMAuth::NoAuth(), oauth_token,
has_oauth_token ? auth->oauth_token() : std::string(),
base::BindOnce( base::BindOnce(
&CloudPolicyClient::OnDeviceAttributeUpdatePermissionCompleted, &CloudPolicyClient::OnDeviceAttributeUpdatePermissionCompleted,
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
...@@ -723,14 +724,15 @@ void CloudPolicyClient::UpdateDeviceAttributes( ...@@ -723,14 +724,15 @@ void CloudPolicyClient::UpdateDeviceAttributes(
CHECK(is_registered()); CHECK(is_registered());
DCHECK(auth->has_oauth_token() || auth->has_enrollment_token()); DCHECK(auth->has_oauth_token() || auth->has_enrollment_token());
bool has_oauth_token = auth->has_oauth_token(); const bool has_oauth_token = auth->has_oauth_token();
const std::string oauth_token =
has_oauth_token ? auth->oauth_token() : std::string();
std::unique_ptr<DMServerJobConfiguration> config = std::unique_ptr<DMServerJobConfiguration> config =
std::make_unique<DMServerJobConfiguration>( std::make_unique<DMServerJobConfiguration>(
DeviceManagementService::JobConfiguration::TYPE_ATTRIBUTE_UPDATE, DeviceManagementService::JobConfiguration::TYPE_ATTRIBUTE_UPDATE,
this, this,
/*critical=*/false, /*critical=*/false,
!has_oauth_token ? std::move(auth) : DMAuth::NoAuth(), !has_oauth_token ? std::move(auth) : DMAuth::NoAuth(), oauth_token,
has_oauth_token ? auth->oauth_token() : std::string(),
base::BindOnce(&CloudPolicyClient::OnDeviceAttributeUpdated, base::BindOnce(&CloudPolicyClient::OnDeviceAttributeUpdated,
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment