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

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/settings/session_manager_operation.h" 5 #include "chrome/browser/chromeos/settings/session_manager_operation.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 base::SequencedWorkerPool* pool = 160 base::SequencedWorkerPool* pool =
161 content::BrowserThread::GetBlockingPool(); 161 content::BrowserThread::GetBlockingPool();
162 scoped_refptr<base::SequencedTaskRunner> background_task_runner = 162 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
163 pool->GetSequencedTaskRunnerWithShutdownBehavior( 163 pool->GetSequencedTaskRunnerWithShutdownBehavior(
164 pool->GetSequenceToken(), 164 pool->GetSequenceToken(),
165 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 165 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
166 166
167 std::unique_ptr<policy::DeviceCloudPolicyValidator> validator = 167 std::unique_ptr<policy::DeviceCloudPolicyValidator> validator =
168 base::WrapUnique<policy::DeviceCloudPolicyValidator>( 168 policy::DeviceCloudPolicyValidator::Create(std::move(policy),
169 policy::DeviceCloudPolicyValidator::Create(std::move(policy), 169 background_task_runner);
170 background_task_runner));
171 170
172 if (cloud_validations_) { 171 if (cloud_validations_) {
173 // Policy auto-generated by session manager doesn't include a timestamp, so 172 // Policy auto-generated by session manager doesn't include a timestamp, so
174 // the timestamp shouldn't be verified in that case. 173 // the timestamp shouldn't be verified in that case.
175 // 174 //
176 // Additionally, offline devices can get their clock set backwards in time 175 // Additionally, offline devices can get their clock set backwards in time
177 // under some hardware conditions; checking the timestamp now could likely 176 // under some hardware conditions; checking the timestamp now could likely
178 // find a value in the future, and prevent the user from signing-in or 177 // find a value in the future, and prevent the user from signing-in or
179 // starting guest mode. Tlsdate will eventually fix the clock when the 178 // starting guest mode. Tlsdate will eventually fix the clock when the
180 // device is back online, but the network configuration may come from device 179 // device is back online, but the network configuration may come from device
(...skipping 18 matching lines...) Expand all
199 // key is validated when it is installed. 198 // key is validated when it is installed.
200 validator->ValidateSignature(public_key_->as_string()); 199 validator->ValidateSignature(public_key_->as_string());
201 } 200 }
202 201
203 validator->ValidatePolicyType(policy::dm_protocol::kChromeDevicePolicyType); 202 validator->ValidatePolicyType(policy::dm_protocol::kChromeDevicePolicyType);
204 validator->ValidatePayload(); 203 validator->ValidatePayload();
205 if (force_immediate_load_) { 204 if (force_immediate_load_) {
206 validator->RunValidation(); 205 validator->RunValidation();
207 ReportValidatorStatus(validator.get()); 206 ReportValidatorStatus(validator.get());
208 } else { 207 } else {
209 // The Validator will delete itself once validation is complete. 208 policy::DeviceCloudPolicyValidator::StartValidation(
210 validator.release()->StartValidation( 209 std::move(validator),
211 base::Bind(&SessionManagerOperation::ReportValidatorStatus, 210 base::Bind(&SessionManagerOperation::ReportValidatorStatus,
212 weak_factory_.GetWeakPtr())); 211 weak_factory_.GetWeakPtr()));
213 } 212 }
214 } 213 }
215 214
216 void SessionManagerOperation::ReportValidatorStatus( 215 void SessionManagerOperation::ReportValidatorStatus(
217 policy::DeviceCloudPolicyValidator* validator) { 216 policy::DeviceCloudPolicyValidator* validator) {
218 DeviceSettingsService::Status status = 217 DeviceSettingsService::Status status =
219 DeviceSettingsService::STORE_VALIDATION_ERROR; 218 DeviceSettingsService::STORE_VALIDATION_ERROR;
220 if (validator->success()) { 219 if (validator->success()) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 272 }
274 273
275 void StoreSettingsOperation::HandleStoreResult(bool success) { 274 void StoreSettingsOperation::HandleStoreResult(bool success) {
276 if (!success) 275 if (!success)
277 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); 276 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED);
278 else 277 else
279 StartLoading(); 278 StartLoading();
280 } 279 }
281 280
282 } // namespace chromeos 281 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698