Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: chrome/browser/policy/cloud/resource_cache.cc

Issue 19052005: Move PathIsWritable, DirectoryExists, ContentsEqual, and TextContentsEqual to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/platform_util_linux.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698