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

Unified Diff: webkit/fileapi/quota_file_util.cc

Issue 7470037: [Refactor] to rename and re-layer the file_util stack layers. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebased. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/quota_file_util.cc
diff --git a/webkit/fileapi/quota_file_util.cc b/webkit/fileapi/quota_file_util.cc
index 2ab4f79b934c7f4560349a8bf6cef3b33f712970..c6979c5141c76d88783c0080688503ee6dfdf8d5 100644
--- a/webkit/fileapi/quota_file_util.cc
+++ b/webkit/fileapi/quota_file_util.cc
@@ -10,6 +10,7 @@
#include "webkit/fileapi/file_system_operation_context.h"
#include "webkit/fileapi/file_system_path_manager.h"
#include "webkit/fileapi/file_system_quota_util.h"
+#include "webkit/fileapi/native_file_util.h"
#include "webkit/quota/quota_manager.h"
using quota::QuotaManagerProxy;
@@ -91,7 +92,7 @@ class ScopedOriginUpdateHelper {
} // namespace (anonymous)
QuotaFileUtil::QuotaFileUtil(FileSystemFileUtil* underlying_file_util)
- : underlying_file_util_(underlying_file_util) {
+ : FileSystemFileUtil(underlying_file_util) {
}
QuotaFileUtil::~QuotaFileUtil() {
@@ -99,7 +100,36 @@ QuotaFileUtil::~QuotaFileUtil() {
// static
QuotaFileUtil* QuotaFileUtil::CreateDefault() {
- return new QuotaFileUtil(new FileSystemFileUtil());
+ return new QuotaFileUtil(new NativeFileUtil());
+}
+
+base::PlatformFileError QuotaFileUtil::Truncate(
+ FileSystemOperationContext* fs_context,
+ const FilePath& path,
+ int64 length) {
+ int64 allowed_bytes_growth = fs_context->allowed_bytes_growth();
+ ScopedOriginUpdateHelper helper(
+ fs_context,
+ fs_context->src_origin_url(),
+ fs_context->src_type());
+
+ int64 growth = 0;
+ base::PlatformFileInfo file_info;
+ if (!file_util::GetFileInfo(path, &file_info))
+ return base::PLATFORM_FILE_ERROR_FAILED;
+
+ growth = length - file_info.size;
+ if (allowed_bytes_growth != kNoLimit &&
+ growth > 0 && growth > allowed_bytes_growth)
+ return base::PLATFORM_FILE_ERROR_NO_SPACE;
+
+ base::PlatformFileError error = underlying_file_util()->Truncate(
+ fs_context, path, length);
+
+ if (error == base::PLATFORM_FILE_OK)
+ helper.NotifyUpdate(growth);
+
+ return error;
}
base::PlatformFileError QuotaFileUtil::CopyOrMoveFile(
@@ -132,7 +162,7 @@ base::PlatformFileError QuotaFileUtil::CopyOrMoveFile(
growth = -dest_file_info.size;
}
- base::PlatformFileError error = underlying_file_util_->CopyOrMoveFile(
+ base::PlatformFileError error = underlying_file_util()->CopyOrMoveFile(
fs_context, src_file_path, dest_file_path, copy);
if (error == base::PLATFORM_FILE_OK) {
@@ -159,7 +189,7 @@ base::PlatformFileError QuotaFileUtil::DeleteFile(
file_info.size = 0;
growth = -file_info.size;
- base::PlatformFileError error = underlying_file_util_->DeleteFile(
+ base::PlatformFileError error = underlying_file_util()->DeleteFile(
fs_context, file_path);
if (error == base::PLATFORM_FILE_OK)
@@ -168,33 +198,4 @@ base::PlatformFileError QuotaFileUtil::DeleteFile(
return error;
}
-base::PlatformFileError QuotaFileUtil::Truncate(
- FileSystemOperationContext* fs_context,
- const FilePath& path,
- int64 length) {
- int64 allowed_bytes_growth = fs_context->allowed_bytes_growth();
- ScopedOriginUpdateHelper helper(
- fs_context,
- fs_context->src_origin_url(),
- fs_context->src_type());
-
- int64 growth = 0;
- base::PlatformFileInfo file_info;
- if (!file_util::GetFileInfo(path, &file_info))
- return base::PLATFORM_FILE_ERROR_FAILED;
-
- growth = length - file_info.size;
- if (allowed_bytes_growth != kNoLimit &&
- growth > 0 && growth > allowed_bytes_growth)
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
-
- base::PlatformFileError error = underlying_file_util_->Truncate(
- fs_context, path, length);
-
- if (error == base::PLATFORM_FILE_OK)
- helper.NotifyUpdate(growth);
-
- return error;
-}
-
} // namespace fileapi

Powered by Google App Engine
This is Rietveld 408576698