diff options
author | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 06:06:43 +0000 |
---|---|---|
committer | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 06:06:43 +0000 |
commit | b0e2a4f2793a60b8979b738758f63a4df7539665 (patch) | |
tree | f917b27caf5fba78f0bf1ec721ad3c3bc5fa2fd4 /webkit/fileapi/quota_file_util.cc | |
parent | 7e494c6d13267fe91a649c81ca858a58c449d6c4 (diff) | |
download | chromium_src-b0e2a4f2793a60b8979b738758f63a4df7539665.zip chromium_src-b0e2a4f2793a60b8979b738758f63a4df7539665.tar.gz chromium_src-b0e2a4f2793a60b8979b738758f63a4df7539665.tar.bz2 |
Refactoring: Change all -FileUtils non-Singleton and to own underlying FileUtils.
Based on the discussion at http://codereview.chromium.org/7174002/diff/26001/webkit/fileapi/local_file_system_file_util.h#newcode38, this change
* also reduces dependency between FileUtils,
* enables more flexible stacking of -FileUtils, such as QuotaFileUtil over other -FileUtils, and
* makes -FileUtils symmetry so owner handling for these objects gets unified.
BUG=none
TEST=FileSystemFileUtilTest.*,FileSystemOperationTest.*,FileSystemOperationWriteTest.*,FileSystemQuotaTest.*,FileWriterDelegateTest.*,LocalFileSystemFileUtilTest.*,ObfuscatedFileSystemFileUtil.*,QuotaFileUtil.*,SandboxMountPointProviderTest.*
Review URL: http://codereview.chromium.org/7312023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94251 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/quota_file_util.cc')
-rw-r--r-- | webkit/fileapi/quota_file_util.cc | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/webkit/fileapi/quota_file_util.cc b/webkit/fileapi/quota_file_util.cc index 83daf74..56fbcb7 100644 --- a/webkit/fileapi/quota_file_util.cc +++ b/webkit/fileapi/quota_file_util.cc @@ -70,9 +70,16 @@ class ScopedOriginUpdateHelper { } // namespace (anonymous) +QuotaFileUtil::QuotaFileUtil(FileSystemFileUtil* underlying_file_util) + : underlying_file_util_(underlying_file_util) { +} + +QuotaFileUtil::~QuotaFileUtil() { +} + // static -QuotaFileUtil* QuotaFileUtil::GetInstance() { - return Singleton<QuotaFileUtil>::get(); +QuotaFileUtil* QuotaFileUtil::CreateDefault() { + return new QuotaFileUtil(new FileSystemFileUtil()); } int64 QuotaFileUtil::ComputeFilePathCost(const FilePath& file_path) const { @@ -103,8 +110,8 @@ PlatformFileError QuotaFileUtil::CreateOrOpen( return base::PLATFORM_FILE_ERROR_NO_SPACE; } - base::PlatformFileError error = FileSystemFileUtil::GetInstance()-> - CreateOrOpen(fs_context, file_path, file_flags, file_handle, created); + base::PlatformFileError error = underlying_file_util_->CreateOrOpen( + fs_context, file_path, file_flags, file_handle, created); if (growth > 0) { if (error == base::PLATFORM_FILE_OK) @@ -137,8 +144,8 @@ PlatformFileError QuotaFileUtil::EnsureFileExists( return base::PLATFORM_FILE_ERROR_NO_SPACE; } - base::PlatformFileError error = FileSystemFileUtil::GetInstance()-> - EnsureFileExists(fs_context, file_path, created); + base::PlatformFileError error = underlying_file_util_->EnsureFileExists( + fs_context, file_path, created); if (growth > 0 &&error == base::PLATFORM_FILE_OK) helper->NotifyUpdate(growth); @@ -184,8 +191,8 @@ PlatformFileError QuotaFileUtil::CreateDirectory( } base::PlatformFileError error = base::PLATFORM_FILE_OK; - error = FileSystemFileUtil::GetInstance()-> - CreateDirectory(fs_context, file_path, exclusive, recursive); + error = underlying_file_util_->CreateDirectory( + fs_context, file_path, exclusive, recursive); if (growth > 0 && error == base::PLATFORM_FILE_OK) helper->NotifyUpdate(growth); @@ -231,8 +238,8 @@ base::PlatformFileError QuotaFileUtil::CopyOrMoveFile( return base::PLATFORM_FILE_ERROR_NO_SPACE; } - base::PlatformFileError error = FileSystemFileUtil::GetInstance()-> - CopyOrMoveFile(fs_context, src_file_path, dest_file_path, copy); + base::PlatformFileError error = underlying_file_util_->CopyOrMoveFile( + fs_context, src_file_path, dest_file_path, copy); if (error == base::PLATFORM_FILE_OK) { // TODO(kinuko): For cross-filesystem move case, call this with -growth @@ -259,8 +266,8 @@ base::PlatformFileError QuotaFileUtil::DeleteFile( ComputeFilePathCost(fs_context->src_virtual_path()); } - base::PlatformFileError error = FileSystemFileUtil::GetInstance()-> - DeleteFile(fs_context, file_path); + base::PlatformFileError error = underlying_file_util_->DeleteFile( + fs_context, file_path); if (error == base::PLATFORM_FILE_OK) helper.NotifyUpdate(growth); @@ -281,8 +288,8 @@ base::PlatformFileError QuotaFileUtil::DeleteSingleDirectory( if (file_util::DirectoryExists(file_path)) growth -= ComputeFilePathCost(fs_context->src_virtual_path()); - base::PlatformFileError error = FileSystemFileUtil::GetInstance()-> - DeleteSingleDirectory(fs_context, file_path); + base::PlatformFileError error = underlying_file_util_->DeleteSingleDirectory( + fs_context, file_path); if (error == base::PLATFORM_FILE_OK) helper.NotifyUpdate(growth); @@ -309,7 +316,7 @@ base::PlatformFileError QuotaFileUtil::Truncate( if (allowed_bytes_growth != kNoLimit && growth > allowed_bytes_growth) return base::PLATFORM_FILE_ERROR_NO_SPACE; - base::PlatformFileError error = FileSystemFileUtil::GetInstance()->Truncate( + base::PlatformFileError error = underlying_file_util_->Truncate( fs_context, path, length); if (error == base::PLATFORM_FILE_OK) |