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

Side by Side Diff: webkit/browser/fileapi/obfuscated_file_util.cc

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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) 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 "webkit/browser/fileapi/obfuscated_file_util.h" 5 #include "webkit/browser/fileapi/obfuscated_file_util.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 bool create, 845 bool create,
846 base::PlatformFileError* error_code) { 846 base::PlatformFileError* error_code) {
847 base::FilePath origin_dir = GetDirectoryForOrigin(origin, create, error_code); 847 base::FilePath origin_dir = GetDirectoryForOrigin(origin, create, error_code);
848 if (origin_dir.empty()) 848 if (origin_dir.empty())
849 return base::FilePath(); 849 return base::FilePath();
850 if (type_string.empty()) 850 if (type_string.empty())
851 return origin_dir; 851 return origin_dir;
852 base::FilePath path = origin_dir.AppendASCII(type_string); 852 base::FilePath path = origin_dir.AppendASCII(type_string);
853 base::PlatformFileError error = base::PLATFORM_FILE_OK; 853 base::PlatformFileError error = base::PLATFORM_FILE_OK;
854 if (!base::DirectoryExists(path) && 854 if (!base::DirectoryExists(path) &&
855 (!create || !file_util::CreateDirectory(path))) { 855 (!create || !base::CreateDirectory(path))) {
856 error = create ? 856 error = create ?
857 base::PLATFORM_FILE_ERROR_FAILED : 857 base::PLATFORM_FILE_ERROR_FAILED :
858 base::PLATFORM_FILE_ERROR_NOT_FOUND; 858 base::PLATFORM_FILE_ERROR_NOT_FOUND;
859 } 859 }
860 860
861 if (error_code) 861 if (error_code)
862 *error_code = error; 862 *error_code = error;
863 return path; 863 return path;
864 } 864 }
865 865
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 if (!exists_in_db && exists_in_fs) { 1203 if (!exists_in_db && exists_in_fs) {
1204 if (!base::DeleteFile(path, true)) { 1204 if (!base::DeleteFile(path, true)) {
1205 if (error_code) 1205 if (error_code)
1206 *error_code = base::PLATFORM_FILE_ERROR_FAILED; 1206 *error_code = base::PLATFORM_FILE_ERROR_FAILED;
1207 return base::FilePath(); 1207 return base::FilePath();
1208 } 1208 }
1209 exists_in_fs = false; 1209 exists_in_fs = false;
1210 } 1210 }
1211 1211
1212 if (!exists_in_fs) { 1212 if (!exists_in_fs) {
1213 if (!create || !file_util::CreateDirectory(path)) { 1213 if (!create || !base::CreateDirectory(path)) {
1214 if (error_code) 1214 if (error_code)
1215 *error_code = create ? 1215 *error_code = create ?
1216 base::PLATFORM_FILE_ERROR_FAILED : 1216 base::PLATFORM_FILE_ERROR_FAILED :
1217 base::PLATFORM_FILE_ERROR_NOT_FOUND; 1217 base::PLATFORM_FILE_ERROR_NOT_FOUND;
1218 return base::FilePath(); 1218 return base::FilePath();
1219 } 1219 }
1220 } 1220 }
1221 1221
1222 if (error_code) 1222 if (error_code)
1223 *error_code = base::PLATFORM_FILE_OK; 1223 *error_code = base::PLATFORM_FILE_OK;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 timer_.reset(); 1255 timer_.reset();
1256 } 1256 }
1257 1257
1258 bool ObfuscatedFileUtil::InitOriginDatabase(const GURL& origin_hint, 1258 bool ObfuscatedFileUtil::InitOriginDatabase(const GURL& origin_hint,
1259 bool create) { 1259 bool create) {
1260 if (origin_database_) 1260 if (origin_database_)
1261 return true; 1261 return true;
1262 1262
1263 if (!create && !base::DirectoryExists(file_system_directory_)) 1263 if (!create && !base::DirectoryExists(file_system_directory_))
1264 return false; 1264 return false;
1265 if (!file_util::CreateDirectory(file_system_directory_)) { 1265 if (!base::CreateDirectory(file_system_directory_)) {
1266 LOG(WARNING) << "Failed to create FileSystem directory: " << 1266 LOG(WARNING) << "Failed to create FileSystem directory: " <<
1267 file_system_directory_.value(); 1267 file_system_directory_.value();
1268 return false; 1268 return false;
1269 } 1269 }
1270 1270
1271 SandboxPrioritizedOriginDatabase* prioritized_origin_database = 1271 SandboxPrioritizedOriginDatabase* prioritized_origin_database =
1272 new SandboxPrioritizedOriginDatabase(file_system_directory_); 1272 new SandboxPrioritizedOriginDatabase(file_system_directory_);
1273 origin_database_.reset(prioritized_origin_database); 1273 origin_database_.reset(prioritized_origin_database);
1274 1274
1275 if (origin_hint.is_empty() || !HasIsolatedStorage(origin_hint)) 1275 if (origin_hint.is_empty() || !HasIsolatedStorage(origin_hint))
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 } 1403 }
1404 return error; 1404 return error;
1405 } 1405 }
1406 1406
1407 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { 1407 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) {
1408 return special_storage_policy_.get() && 1408 return special_storage_policy_.get() &&
1409 special_storage_policy_->HasIsolatedStorage(origin); 1409 special_storage_policy_->HasIsolatedStorage(origin);
1410 } 1410 }
1411 1411
1412 } // namespace fileapi 1412 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/native_file_util.cc ('k') | webkit/browser/fileapi/sandbox_directory_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698