Commit ae73fdb9 authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Cleanup: Move unique ptr instead of releasing

Change a few places in the policy code to use std::move() with
std::unique_ptr instead of calling release() on them. It's slightly more
idiomatic and a bit safer.

Bug: none
Change-Id: I7b25af583369cac6234f712a4cadeefad09c47d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035879Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738137}
parent 50dc5f2b
...@@ -423,10 +423,10 @@ void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerConnected() { ...@@ -423,10 +423,10 @@ void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerConnected() {
CHECK(device_cloud_policy_initializer_); CHECK(device_cloud_policy_initializer_);
// DeviceCloudPolicyInitializer might still be on the call stack, so we // DeviceCloudPolicyInitializer might still be on the call stack, so we
// should release the initializer after this function returns. // should delete the initializer after this function returns.
device_cloud_policy_initializer_->Shutdown(); device_cloud_policy_initializer_->Shutdown();
base::ThreadTaskRunnerHandle::Get()->DeleteSoon( base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
FROM_HERE, device_cloud_policy_initializer_.release()); FROM_HERE, std::move(device_cloud_policy_initializer_));
} }
void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerDisconnected() { void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerDisconnected() {
......
...@@ -43,7 +43,7 @@ DeviceLocalAccountExternalDataService:: ...@@ -43,7 +43,7 @@ DeviceLocalAccountExternalDataService::
DCHECK(it->second->HasOneRef()); DCHECK(it->second->HasOneRef());
} }
#endif // !defined(NDEBUG) #endif // !defined(NDEBUG)
backend_task_runner_->DeleteSoon(FROM_HERE, resource_cache_.release()); backend_task_runner_->DeleteSoon(FROM_HERE, std::move(resource_cache_));
} }
void DeviceLocalAccountExternalDataService::OnPolicyUpdated( void DeviceLocalAccountExternalDataService::OnPolicyUpdated(
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -411,9 +410,9 @@ class POLICY_EXPORT CloudPolicyValidator final ...@@ -411,9 +410,9 @@ class POLICY_EXPORT CloudPolicyValidator final
// |completion_callback| is invoked when done. // |completion_callback| is invoked when done.
static void StartValidation(std::unique_ptr<CloudPolicyValidator> validator, static void StartValidation(std::unique_ptr<CloudPolicyValidator> validator,
CompletionCallback completion_callback) { CompletionCallback completion_callback) {
CloudPolicyValidator* const validator_ptr = validator.release(); CloudPolicyValidator* const validator_ptr = validator.get();
PostValidationTask( PostValidationTask(
base::WrapUnique<CloudPolicyValidatorBase>(validator_ptr), std::move(validator),
base::BindOnce(std::move(completion_callback), validator_ptr)); base::BindOnce(std::move(completion_callback), validator_ptr));
} }
......
...@@ -320,7 +320,7 @@ ComponentCloudPolicyService::~ComponentCloudPolicyService() { ...@@ -320,7 +320,7 @@ ComponentCloudPolicyService::~ComponentCloudPolicyService() {
if (core_->client()) if (core_->client())
Disconnect(); Disconnect();
backend_task_runner_->DeleteSoon(FROM_HERE, backend_.release()); backend_task_runner_->DeleteSoon(FROM_HERE, std::move(backend_));
} }
// static // static
......
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