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

Unified Diff: chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc

Issue 2817643002: Make CloudPolicyValidator memory management clearer (Closed)
Patch Set: Cleaner memory management in CloudPolicyValidator Created 3 years, 8 months 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: chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
diff --git a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
index a626d90f3ec0ebb88359eb865a528eb40c26f047..23e9cf982ca6e83c6f415eeca70d9b51726f0105 100644
--- a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
+++ b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/browser_process.h"
@@ -195,8 +196,7 @@ void EnrollmentHandlerChromeOS::OnPolicyFetched(CloudPolicyClient* client) {
std::unique_ptr<DeviceCloudPolicyValidator> validator(
DeviceCloudPolicyValidator::Create(
- std::unique_ptr<em::PolicyFetchResponse>(
- new em::PolicyFetchResponse(*policy)),
+ base::MakeUnique<em::PolicyFetchResponse>(*policy),
background_task_runner_));
validator->ValidateTimestamp(
@@ -221,7 +221,8 @@ void EnrollmentHandlerChromeOS::OnPolicyFetched(CloudPolicyClient* client) {
// can validate the username on the resulting policy, and use the domain from
// that username to validate the key below (http://crbug.com/343074).
validator->ValidateInitialKey(domain);
- validator.release()->StartValidation(
+ DeviceCloudPolicyValidator::StartValidation(
+ std::move(validator),
base::Bind(&EnrollmentHandlerChromeOS::HandlePolicyValidationResult,
weak_ptr_factory_.GetWeakPtr()));
}

Powered by Google App Engine
This is Rietveld 408576698