| Index: webkit/fileapi/quota_file_util.cc
|
| diff --git a/webkit/fileapi/quota_file_util.cc b/webkit/fileapi/quota_file_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..542483f25d273c0cd5add7c2107440898d2f9505
|
| --- /dev/null
|
| +++ b/webkit/fileapi/quota_file_util.cc
|
| @@ -0,0 +1,39 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "webkit/fileapi/file_system_file_util_base.h"
|
| +#include "webkit/fileapi/file_system_operation_context.h"
|
| +
|
| +#include "base/file_util.h"
|
| +
|
| +namespace fileapi {
|
| +
|
| +// static
|
| +QuotaFileUtil* QuotaFileUtil::GetInstance() {
|
| + QuotaFileUtil* self = Singleton<QuotaFileUtil>::get();
|
| + self->next_file_util_to_quota = FileSystemFileUtilBase::GetInstance();
|
| + return self;
|
| +}
|
| +
|
| +base::PlatformFileError QuotaFileUtil::Copy(
|
| + const FileSystemOperationContext& fs_context,
|
| + const FilePath& src_file_path,
|
| + const FilePath& dest_file_path) {
|
| + int allowed_growth = fs_context.GetAllowedGrowth();
|
| +
|
| + if (allowed_growth < SIZE_MAX) {
|
| + const char* path_str = src_file_path.value().c_str();
|
| + stat_wrapper_t file_info;
|
| + int test = CallStat(path_str, &file_info);
|
| + if (test != 0)
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| + if (file_info.st_size > allowed_growth)
|
| + return base::PLATFORM_FILE_ERROR_NO_SPACE;
|
| + }
|
| +
|
| + return next_file_util_to_quota->Copy(
|
| + fs_context, src_file_path, dest_file_path);
|
| +}
|
| +
|
| +} // namespace fileapi
|
|
|