diff options
author | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-21 05:04:51 +0000 |
---|---|---|
committer | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-21 05:04:51 +0000 |
commit | 078c6971a60c9a375e433ded4399a23a57382053 (patch) | |
tree | 94b9294bcb406857553f34cb4520a89e4231a5ee /webkit/fileapi/file_system_file_util.cc | |
parent | cbf61bccc4488871222e616065b1104e57c5e9ac (diff) | |
download | chromium_src-078c6971a60c9a375e433ded4399a23a57382053.zip chromium_src-078c6971a60c9a375e433ded4399a23a57382053.tar.gz chromium_src-078c6971a60c9a375e433ded4399a23a57382053.tar.bz2 |
Add "allowed growth" for writing operations, such as copy, move, write and truncate.
A writing operation which increases the file size more than "allowed growth" results in PLATFORM_FILE_ERROR_NO_SPACE.
BUG=74841
TEST=FileWriterDelegateTest.*,QuotaFileUtilTest.*,FileSystemOperationTest.*
Review URL: http://codereview.chromium.org/6725021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_file_util.cc')
-rw-r--r-- | webkit/fileapi/file_system_file_util.cc | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/webkit/fileapi/file_system_file_util.cc b/webkit/fileapi/file_system_file_util.cc index f012a33..3e4e6c6 100644 --- a/webkit/fileapi/file_system_file_util.cc +++ b/webkit/fileapi/file_system_file_util.cc @@ -142,9 +142,11 @@ PlatformFileError FileSystemFileUtil::Copy( return error_code; if (file_util::DirectoryExists(src_file_path)) - return CopyDirectory(context, src_file_path, dest_file_path); + return CopyOrMoveDirectory(context, src_file_path, dest_file_path, + true /* copy */); else - return CopyOrMoveFile(context, src_file_path, dest_file_path, true); + return CopyOrMoveFile(context, src_file_path, dest_file_path, + true /* copy */); } PlatformFileError FileSystemFileUtil::Move( @@ -158,15 +160,13 @@ PlatformFileError FileSystemFileUtil::Move( if (error_code != base::PLATFORM_FILE_OK) return error_code; - // TODO(dmikurube): ReplaceFile if in the same filesystem. + // TODO(dmikurube): ReplaceFile if in the same domain and filesystem type. if (file_util::DirectoryExists(src_file_path)) { - PlatformFileError error = - CopyDirectory(context, src_file_path, dest_file_path); - if (error != base::PLATFORM_FILE_OK) - return error; - return Delete(context, src_file_path, true); + return CopyOrMoveDirectory(context, src_file_path, dest_file_path, + false /* copy */); } else - return CopyOrMoveFile(context, src_file_path, dest_file_path, false); + return CopyOrMoveFile(context, src_file_path, dest_file_path, + false /* copy */); } PlatformFileError FileSystemFileUtil::Delete( @@ -285,10 +285,11 @@ PlatformFileError FileSystemFileUtil::CopyOrMoveFile( return base::PLATFORM_FILE_ERROR_FAILED; } -PlatformFileError FileSystemFileUtil::CopyDirectory( +PlatformFileError FileSystemFileUtil::CopyOrMoveDirectory( FileSystemOperationContext* context, const FilePath& src_file_path, - const FilePath& dest_file_path) { + const FilePath& dest_file_path, + bool copy) { // Re-check PerformCommonCheckAndPreparationForMoveAndCopy() by DCHECK. DCHECK(DirectoryExists(context, src_file_path)); DCHECK(DirectoryExists(context, dest_file_path.DirName())); @@ -317,11 +318,17 @@ PlatformFileError FileSystemFileUtil::CopyDirectory( } else { // CopyOrMoveFile here is the virtual overridden member function. PlatformFileError error = CopyOrMoveFile( - context, src_file_path_each, dest_file_path_each, true); + context, src_file_path_each, dest_file_path_each, copy); if (error != base::PLATFORM_FILE_OK) return error; } } + + if (!copy) { + PlatformFileError error = Delete(context, src_file_path, true); + if (error != base::PLATFORM_FILE_OK) + return error; + } return base::PLATFORM_FILE_OK; } |