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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 bool ResourceCache::VerifyKeyPath(const std::string& key, | 149 bool ResourceCache::VerifyKeyPath(const std::string& key, |
150 bool allow_create, | 150 bool allow_create, |
151 base::FilePath* path) { | 151 base::FilePath* path) { |
152 std::string encoded; | 152 std::string encoded; |
153 if (!Base64Encode(key, &encoded)) | 153 if (!Base64Encode(key, &encoded)) |
154 return false; | 154 return false; |
155 *path = cache_dir_.AppendASCII(encoded); | 155 *path = cache_dir_.AppendASCII(encoded); |
156 return allow_create ? file_util::CreateDirectory(*path) : | 156 return allow_create ? file_util::CreateDirectory(*path) : |
157 file_util::DirectoryExists(*path); | 157 base::DirectoryExists(*path); |
158 } | 158 } |
159 | 159 |
160 bool ResourceCache::VerifyKeyPathAndGetSubkeyPath(const std::string& key, | 160 bool ResourceCache::VerifyKeyPathAndGetSubkeyPath(const std::string& key, |
161 bool allow_create_key, | 161 bool allow_create_key, |
162 const std::string& subkey, | 162 const std::string& subkey, |
163 base::FilePath* path) { | 163 base::FilePath* path) { |
164 base::FilePath key_path; | 164 base::FilePath key_path; |
165 std::string encoded; | 165 std::string encoded; |
166 if (!VerifyKeyPath(key, allow_create_key, &key_path) || | 166 if (!VerifyKeyPath(key, allow_create_key, &key_path) || |
167 !Base64Encode(subkey, &encoded)) { | 167 !Base64Encode(subkey, &encoded)) { |
168 return false; | 168 return false; |
169 } | 169 } |
170 *path = key_path.AppendASCII(encoded); | 170 *path = key_path.AppendASCII(encoded); |
171 return true; | 171 return true; |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 } // namespace policy | 175 } // namespace policy |
OLD | NEW |