| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return result; | 100 return result; |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool WriteStringToFile(const base::FilePath path, const std::string& data) { | 103 bool WriteStringToFile(const base::FilePath path, const std::string& data) { |
| 104 if (!base::CreateDirectory(path.DirName())) { | 104 if (!base::CreateDirectory(path.DirName())) { |
| 105 DLOG(WARNING) << "Failed to create directory " << path.DirName().value(); | 105 DLOG(WARNING) << "Failed to create directory " << path.DirName().value(); |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 int size = data.size(); | 109 int size = data.size(); |
| 110 if (file_util::WriteFile(path, data.c_str(), size) != size) { | 110 if (base::WriteFile(path, data.c_str(), size) != size) { |
| 111 DLOG(WARNING) << "Failed to write " << path.value(); | 111 DLOG(WARNING) << "Failed to write " << path.value(); |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 | 114 |
| 115 return true; | 115 return true; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Stores policy to the backing file (must be called via a task on | 118 // Stores policy to the backing file (must be called via a task on |
| 119 // the background thread). | 119 // the background thread). |
| 120 void StorePolicyToDiskOnBackgroundThread( | 120 void StorePolicyToDiskOnBackgroundThread( |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass()); | 434 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass()); |
| 435 | 435 |
| 436 // If the key was rotated, update our local cache of the key. | 436 // If the key was rotated, update our local cache of the key. |
| 437 if (validator->policy()->has_new_public_key()) | 437 if (validator->policy()->has_new_public_key()) |
| 438 policy_key_ = validator->policy()->new_public_key(); | 438 policy_key_ = validator->policy()->new_public_key(); |
| 439 status_ = STATUS_OK; | 439 status_ = STATUS_OK; |
| 440 NotifyStoreLoaded(); | 440 NotifyStoreLoaded(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 } // namespace policy | 443 } // namespace policy |
| OLD | NEW |