OLD | NEW |
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/policy/cloud/user_cloud_policy_store.h" | 5 #include "chrome/browser/policy/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/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void StorePolicyToDiskOnBackgroundThread( | 70 void StorePolicyToDiskOnBackgroundThread( |
71 const base::FilePath& path, | 71 const base::FilePath& path, |
72 const em::PolicyFetchResponse& policy) { | 72 const em::PolicyFetchResponse& policy) { |
73 DVLOG(1) << "Storing policy to " << path.value(); | 73 DVLOG(1) << "Storing policy to " << path.value(); |
74 std::string data; | 74 std::string data; |
75 if (!policy.SerializeToString(&data)) { | 75 if (!policy.SerializeToString(&data)) { |
76 DLOG(WARNING) << "Failed to serialize policy data"; | 76 DLOG(WARNING) << "Failed to serialize policy data"; |
77 return; | 77 return; |
78 } | 78 } |
79 | 79 |
80 if (!file_util::CreateDirectory(path.DirName())) { | 80 if (!base::CreateDirectory(path.DirName())) { |
81 DLOG(WARNING) << "Failed to create directory " << path.DirName().value(); | 81 DLOG(WARNING) << "Failed to create directory " << path.DirName().value(); |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 int size = data.size(); | 85 int size = data.size(); |
86 if (file_util::WriteFile(path, data.c_str(), size) != size) { | 86 if (file_util::WriteFile(path, data.c_str(), size) != size) { |
87 DLOG(WARNING) << "Failed to write " << path.value(); | 87 DLOG(WARNING) << "Failed to write " << path.value(); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 background_task_runner()->PostTask( | 247 background_task_runner()->PostTask( |
248 FROM_HERE, | 248 FROM_HERE, |
249 base::Bind(&StorePolicyToDiskOnBackgroundThread, | 249 base::Bind(&StorePolicyToDiskOnBackgroundThread, |
250 backing_file_path_, *validator->policy())); | 250 backing_file_path_, *validator->policy())); |
251 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass()); | 251 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass()); |
252 status_ = STATUS_OK; | 252 status_ = STATUS_OK; |
253 NotifyStoreLoaded(); | 253 NotifyStoreLoaded(); |
254 } | 254 } |
255 | 255 |
256 } // namespace policy | 256 } // namespace policy |
OLD | NEW |