OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/policy/cloud/resource_cache.h" | 5 #include "chrome/browser/policy/cloud/resource_cache.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 base::DeleteFile(key_path, false); | 211 base::DeleteFile(key_path, false); |
212 } | 212 } |
213 | 213 |
214 bool ResourceCache::VerifyKeyPath(const std::string& key, | 214 bool ResourceCache::VerifyKeyPath(const std::string& key, |
215 bool allow_create, | 215 bool allow_create, |
216 base::FilePath* path) { | 216 base::FilePath* path) { |
217 std::string encoded; | 217 std::string encoded; |
218 if (!Base64Encode(key, &encoded)) | 218 if (!Base64Encode(key, &encoded)) |
219 return false; | 219 return false; |
220 *path = cache_dir_.AppendASCII(encoded); | 220 *path = cache_dir_.AppendASCII(encoded); |
221 return allow_create ? file_util::CreateDirectory(*path) : | 221 return allow_create ? base::CreateDirectory(*path) : |
222 base::DirectoryExists(*path); | 222 base::DirectoryExists(*path); |
223 } | 223 } |
224 | 224 |
225 bool ResourceCache::VerifyKeyPathAndGetSubkeyPath(const std::string& key, | 225 bool ResourceCache::VerifyKeyPathAndGetSubkeyPath(const std::string& key, |
226 bool allow_create_key, | 226 bool allow_create_key, |
227 const std::string& subkey, | 227 const std::string& subkey, |
228 base::FilePath* path) { | 228 base::FilePath* path) { |
229 base::FilePath key_path; | 229 base::FilePath key_path; |
230 std::string encoded; | 230 std::string encoded; |
231 if (!VerifyKeyPath(key, allow_create_key, &key_path) || | 231 if (!VerifyKeyPath(key, allow_create_key, &key_path) || |
232 !Base64Encode(subkey, &encoded)) { | 232 !Base64Encode(subkey, &encoded)) { |
233 return false; | 233 return false; |
234 } | 234 } |
235 *path = key_path.AppendASCII(encoded); | 235 *path = key_path.AppendASCII(encoded); |
236 return true; | 236 return true; |
237 } | 237 } |
238 | 238 |
239 | 239 |
240 } // namespace policy | 240 } // namespace policy |
OLD | NEW |