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

Unified Diff: components/policy/core/common/cloud/cloud_policy_validator_unittest.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: components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc b/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
index c3112952ebe1ee86a0c62f24d2bb896bddd3630f..c61675fc630072c5251c9b056ffa108410a3d28f 100644
--- a/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
@@ -72,7 +72,8 @@ class CloudPolicyValidatorTest : public testing::Test {
// Run validation and check the result.
EXPECT_CALL(*this, ValidationCompletion(validator.get())).WillOnce(
check_action);
- validator.release()->StartValidation(
+ UserCloudPolicyValidator::StartValidation(
+ std::move(validator),
base::Bind(&CloudPolicyValidatorTest::ValidationCompletion,
base::Unretained(this)));
base::RunLoop().RunUntilIdle();
@@ -84,8 +85,9 @@ class CloudPolicyValidatorTest : public testing::Test {
std::string public_key = PolicyBuilder::GetPublicTestKeyAsString();
EXPECT_FALSE(public_key.empty());
- UserCloudPolicyValidator* validator = UserCloudPolicyValidator::Create(
- std::move(policy_response), base::ThreadTaskRunnerHandle::Get());
+ std::unique_ptr<UserCloudPolicyValidator> validator =
+ UserCloudPolicyValidator::Create(std::move(policy_response),
+ base::ThreadTaskRunnerHandle::Get());
validator->ValidateTimestamp(timestamp_, timestamp_,
timestamp_option_);
validator->ValidateUsername(PolicyBuilder::kFakeUsername, true);
@@ -104,7 +106,7 @@ class CloudPolicyValidatorTest : public testing::Test {
} else {
validator->ValidateSignature(public_key);
}
- return base::WrapUnique(validator);
+ return validator;
}

Powered by Google App Engine
This is Rietveld 408576698