OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/policy/core/common/cloud/user_cloud_policy_store.h" | 5 #include "components/policy/core/common/cloud/user_cloud_policy_store.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 216 } |
217 | 217 |
218 void UserCloudPolicyStore::Load() { | 218 void UserCloudPolicyStore::Load() { |
219 DVLOG(1) << "Initiating policy load from disk"; | 219 DVLOG(1) << "Initiating policy load from disk"; |
220 // Cancel any pending Load/Store/Validate operations. | 220 // Cancel any pending Load/Store/Validate operations. |
221 weak_factory_.InvalidateWeakPtrs(); | 221 weak_factory_.InvalidateWeakPtrs(); |
222 | 222 |
223 // Start a new Load operation and have us get called back when it is | 223 // Start a new Load operation and have us get called back when it is |
224 // complete. | 224 // complete. |
225 base::PostTaskAndReplyWithResult( | 225 base::PostTaskAndReplyWithResult( |
226 background_task_runner(), | 226 background_task_runner().get(), |
227 FROM_HERE, | 227 FROM_HERE, |
228 base::Bind(&LoadPolicyFromDisk, policy_path_, key_path_), | 228 base::Bind(&LoadPolicyFromDisk, policy_path_, key_path_), |
229 base::Bind(&UserCloudPolicyStore::PolicyLoaded, | 229 base::Bind(&UserCloudPolicyStore::PolicyLoaded, |
230 weak_factory_.GetWeakPtr(), true)); | 230 weak_factory_.GetWeakPtr(), |
| 231 true)); |
231 } | 232 } |
232 | 233 |
233 void UserCloudPolicyStore::PolicyLoaded(bool validate_in_background, | 234 void UserCloudPolicyStore::PolicyLoaded(bool validate_in_background, |
234 PolicyLoadResult result) { | 235 PolicyLoadResult result) { |
235 UMA_HISTOGRAM_ENUMERATION("Enterprise.UserCloudPolicyStore.LoadStatus", | 236 UMA_HISTOGRAM_ENUMERATION("Enterprise.UserCloudPolicyStore.LoadStatus", |
236 result.status, | 237 result.status, |
237 LOAD_RESULT_SIZE); | 238 LOAD_RESULT_SIZE); |
238 switch (result.status) { | 239 switch (result.status) { |
239 case LOAD_RESULT_LOAD_ERROR: | 240 case LOAD_RESULT_LOAD_ERROR: |
240 status_ = STATUS_LOAD_ERROR; | 241 status_ = STATUS_LOAD_ERROR; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass()); | 452 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass()); |
452 | 453 |
453 // If the key was rotated, update our local cache of the key. | 454 // If the key was rotated, update our local cache of the key. |
454 if (validator->policy()->has_new_public_key()) | 455 if (validator->policy()->has_new_public_key()) |
455 policy_key_ = validator->policy()->new_public_key(); | 456 policy_key_ = validator->policy()->new_public_key(); |
456 status_ = STATUS_OK; | 457 status_ = STATUS_OK; |
457 NotifyStoreLoaded(); | 458 NotifyStoreLoaded(); |
458 } | 459 } |
459 | 460 |
460 } // namespace policy | 461 } // namespace policy |
OLD | NEW |