summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
authordmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 10:50:50 +0000
committerdmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 10:50:50 +0000
commitccb14ed1454d0c8a891cc980ece99b23a748492b (patch)
treebec6a3d91102444bc5b3dc1b8b3a09de92a78a6c /webkit/fileapi
parent563b93997b780ce2ea1683c23acf4c41cebc665e (diff)
downloadchromium_src-ccb14ed1454d0c8a891cc980ece99b23a748492b.zip
chromium_src-ccb14ed1454d0c8a891cc980ece99b23a748492b.tar.gz
chromium_src-ccb14ed1454d0c8a891cc980ece99b23a748492b.tar.bz2
Change {Obfuscated|Local}FileSystemFileUtil non-Singleton to take an underlying *FileUtil.
This change : * reduces dependency between FileUtils, and * enables more flexible stacking of FileSystemFileUtil, such as {Obfuscated|Local}FSFU without any quota operation. BUG=none TEST=*FileUtilTest.*,FileSystemPathManagerTest.*,SandboxMountPointProvider.*,FileSystem*OperationTest.*,FileWriterDelegateTest.*,FileSystemQuotaTest.* Review URL: http://codereview.chromium.org/7174002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91547 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/file_system_file_util_unittest.cc6
-rw-r--r--webkit/fileapi/file_system_mount_point_provider.h3
-rw-r--r--webkit/fileapi/file_system_operation_unittest.cc7
-rw-r--r--webkit/fileapi/file_system_operation_write_unittest.cc8
-rw-r--r--webkit/fileapi/file_system_path_manager.cc8
-rw-r--r--webkit/fileapi/file_system_quota_unittest.cc8
-rw-r--r--webkit/fileapi/file_system_test_helper.cc4
-rw-r--r--webkit/fileapi/local_file_system_file_util.cc34
-rw-r--r--webkit/fileapi/local_file_system_file_util.h18
-rw-r--r--webkit/fileapi/local_file_system_file_util_unittest.cc10
-rw-r--r--webkit/fileapi/obfuscated_file_system_file_util.cc37
-rw-r--r--webkit/fileapi/obfuscated_file_system_file_util.h8
-rw-r--r--webkit/fileapi/obfuscated_file_system_file_util_unittest.cc4
-rw-r--r--webkit/fileapi/sandbox_mount_point_provider.cc4
-rw-r--r--webkit/fileapi/sandbox_mount_point_provider.h2
15 files changed, 89 insertions, 72 deletions
diff --git a/webkit/fileapi/file_system_file_util_unittest.cc b/webkit/fileapi/file_system_file_util_unittest.cc
index 4203024..9becaaa 100644
--- a/webkit/fileapi/file_system_file_util_unittest.cc
+++ b/webkit/fileapi/file_system_file_util_unittest.cc
@@ -11,7 +11,6 @@
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation_context.h"
#include "webkit/fileapi/file_system_test_helper.h"
-#include "webkit/fileapi/local_file_system_file_util.h"
#include "webkit/fileapi/obfuscated_file_system_file_util.h"
using namespace fileapi;
@@ -65,7 +64,6 @@ class FileSystemFileUtilTest : public testing::Test {
FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) {
FileSystemOperationContext* context = helper->NewOperationContext();
- context->set_allowed_bytes_growth(1024 * 1024);
return context;
}
@@ -76,7 +74,8 @@ class FileSystemFileUtilTest : public testing::Test {
ScopedTempDir base_dir;
ASSERT_TRUE(base_dir.CreateUniqueTempDir());
scoped_refptr<ObfuscatedFileSystemFileUtil> file_util(
- new ObfuscatedFileSystemFileUtil(base_dir.path()));
+ new ObfuscatedFileSystemFileUtil(base_dir.path(),
+ FileSystemFileUtil::GetInstance()));
FileSystemTestOriginHelper src_helper(src_origin, src_type);
src_helper.SetUp(base_dir.path(),
false, // incognito
@@ -118,7 +117,6 @@ class FileSystemFileUtilTest : public testing::Test {
copy_context->set_dest_origin_url(dest_helper.origin());
copy_context->set_src_type(src_helper.type());
copy_context->set_dest_type(dest_helper.type());
- copy_context->set_allowed_bytes_growth(1024 * 1024);
if (copy)
ASSERT_EQ(base::PLATFORM_FILE_OK,
diff --git a/webkit/fileapi/file_system_mount_point_provider.h b/webkit/fileapi/file_system_mount_point_provider.h
index edf158f..bb42649 100644
--- a/webkit/fileapi/file_system_mount_point_provider.h
+++ b/webkit/fileapi/file_system_mount_point_provider.h
@@ -51,6 +51,8 @@ class FileSystemMountPointProvider {
// provider. This list is used to set appropriate child process file access
// permissions.
virtual std::vector<FilePath> GetRootDirectories() const = 0;
+
+ virtual FileSystemFileUtil* GetFileSystemFileUtil() = 0;
};
// An interface to control external file system access permissions.
@@ -80,4 +82,3 @@ class ExternalFileSystemMountPointProvider
} // namespace fileapi
#endif // WEBKIT_FILEAPI_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_
-
diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc
index 9cd6103..e1ece0ec 100644
--- a/webkit/fileapi/file_system_operation_unittest.cc
+++ b/webkit/fileapi/file_system_operation_unittest.cc
@@ -154,7 +154,9 @@ FilePath ASCIIToFilePath(const std::string& str) {
class FileSystemOperationTest : public testing::Test {
public:
FileSystemOperationTest()
- : status_(kFileOperationStatusNotSet) {
+ : status_(kFileOperationStatusNotSet),
+ local_file_util_(
+ new LocalFileSystemFileUtil(QuotaFileUtil::GetInstance())) {
EXPECT_TRUE(base_.CreateUniqueTempDir());
}
@@ -248,6 +250,7 @@ class FileSystemOperationTest : public testing::Test {
std::vector<base::FileUtilProxy::Entry> entries_;
private:
+ scoped_ptr<LocalFileSystemFileUtil> local_file_util_;
scoped_refptr<QuotaManager> quota_manager_;
scoped_refptr<QuotaManagerProxy> quota_manager_proxy_;
DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest);
@@ -304,7 +307,7 @@ void FileSystemOperationTest::SetUp() {
false /* incognito */,
false /* unlimited quota */,
quota_manager_proxy_.get(),
- LocalFileSystemFileUtil::GetInstance());
+ local_file_util_.get());
}
void FileSystemOperationTest::TearDown() {
diff --git a/webkit/fileapi/file_system_operation_write_unittest.cc b/webkit/fileapi/file_system_operation_write_unittest.cc
index b079859..6d33626 100644
--- a/webkit/fileapi/file_system_operation_write_unittest.cc
+++ b/webkit/fileapi/file_system_operation_write_unittest.cc
@@ -29,6 +29,7 @@
#include "webkit/fileapi/file_system_test_helper.h"
#include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/local_file_system_file_util.h"
+#include "webkit/fileapi/quota_file_util.h"
#include "webkit/quota/quota_manager.h"
using quota::QuotaManager;
@@ -66,7 +67,9 @@ class MockQuotaManager : public QuotaManager {
class FileSystemOperationWriteTest : public testing::Test {
public:
FileSystemOperationWriteTest()
- : loop_(MessageLoop::TYPE_IO),
+ : local_file_util_(
+ new LocalFileSystemFileUtil(QuotaFileUtil::GetInstance())),
+ loop_(MessageLoop::TYPE_IO),
status_(base::PLATFORM_FILE_OK),
bytes_written_(0),
complete_(false) {}
@@ -97,6 +100,7 @@ class FileSystemOperationWriteTest : public testing::Test {
return test_helper_.GetURLForPath(path);
}
+ scoped_ptr<LocalFileSystemFileUtil> local_file_util_;
scoped_refptr<MockQuotaManager> quota_manager_;
FileSystemTestOriginHelper test_helper_;
@@ -188,7 +192,7 @@ void FileSystemOperationWriteTest::SetUp() {
false /* incognito */,
false /* unlimited quota */,
quota_manager_->proxy(),
- LocalFileSystemFileUtil::GetInstance());
+ local_file_util_.get());
filesystem_dir_ = test_helper_.GetOriginRootPath();
ASSERT_TRUE(file_util::CreateTemporaryFileInDir(filesystem_dir_, &file_));
diff --git a/webkit/fileapi/file_system_path_manager.cc b/webkit/fileapi/file_system_path_manager.cc
index 1013352..2db5045 100644
--- a/webkit/fileapi/file_system_path_manager.cc
+++ b/webkit/fileapi/file_system_path_manager.cc
@@ -16,7 +16,6 @@
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h"
#include "webkit/fileapi/file_system_util.h"
-#include "webkit/fileapi/local_file_system_file_util.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
#include "webkit/glue/webkit_glue.h"
@@ -169,7 +168,12 @@ FileSystemFileUtil* FileSystemPathManager::GetFileSystemFileUtil(
case kFileSystemTypePersistent:
return sandbox_provider_->GetFileSystemFileUtil();
case kFileSystemTypeExternal:
- return LocalFileSystemFileUtil::GetInstance();
+ if (external_provider_.get()) {
+ return external_provider_->GetFileSystemFileUtil();
+ } else {
+ NOTREACHED();
+ return NULL;
+ }
case kFileSystemTypeUnknown:
default:
NOTREACHED();
diff --git a/webkit/fileapi/file_system_quota_unittest.cc b/webkit/fileapi/file_system_quota_unittest.cc
index dbbef66..a2dd58cd 100644
--- a/webkit/fileapi/file_system_quota_unittest.cc
+++ b/webkit/fileapi/file_system_quota_unittest.cc
@@ -21,6 +21,7 @@
#include "webkit/fileapi/file_system_usage_cache.h"
#include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/local_file_system_file_util.h"
+#include "webkit/fileapi/quota_file_util.h"
#include "webkit/quota/quota_manager.h"
namespace fileapi {
@@ -30,7 +31,9 @@ const int kFileOperationStatusNotSet = 1;
class FileSystemQuotaTest : public testing::Test {
public:
FileSystemQuotaTest()
- : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ : local_file_util_(
+ new LocalFileSystemFileUtil(QuotaFileUtil::GetInstance())),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
status_(kFileOperationStatusNotSet),
quota_status_(quota::kQuotaStatusUnknown),
usage_(-1),
@@ -118,6 +121,7 @@ class FileSystemQuotaTest : public testing::Test {
ScopedTempDir work_dir_;
scoped_refptr<quota::QuotaManager> quota_manager_;
+ scoped_ptr<LocalFileSystemFileUtil> local_file_util_;
base::ScopedCallbackFactory<FileSystemQuotaTest> callback_factory_;
@@ -190,7 +194,7 @@ void FileSystemQuotaTest::SetUp() {
false /* incognito */,
false /* unlimited quota */,
quota_manager_->proxy(),
- LocalFileSystemFileUtil::GetInstance());
+ local_file_util_.get());
}
void FileSystemQuotaTest::TearDown() {
diff --git a/webkit/fileapi/file_system_test_helper.cc b/webkit/fileapi/file_system_test_helper.cc
index 648f7109..6eb3538 100644
--- a/webkit/fileapi/file_system_test_helper.cc
+++ b/webkit/fileapi/file_system_test_helper.cc
@@ -13,8 +13,6 @@
#include "webkit/fileapi/file_system_operation_context.h"
#include "webkit/fileapi/file_system_usage_cache.h"
#include "webkit/fileapi/file_system_util.h"
-#include "webkit/fileapi/local_file_system_file_util.h"
-#include "webkit/fileapi/quota_file_util.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
#include "webkit/quota/special_storage_policy.h"
@@ -93,7 +91,7 @@ void FileSystemTestOriginHelper::SetUp(
bool unlimited_quota,
quota::QuotaManagerProxy* quota_manager_proxy,
FileSystemFileUtil* file_util) {
- file_util_ = file_util ? file_util : LocalFileSystemFileUtil::GetInstance();
+ file_util_ = file_util;
DCHECK(file_util_);
file_system_context_ = new FileSystemContext(
base::MessageLoopProxy::CreateForCurrentThread(),
diff --git a/webkit/fileapi/local_file_system_file_util.cc b/webkit/fileapi/local_file_system_file_util.cc
index 8b9e5d7..729da6a 100644
--- a/webkit/fileapi/local_file_system_file_util.cc
+++ b/webkit/fileapi/local_file_system_file_util.cc
@@ -11,12 +11,12 @@
#include "webkit/fileapi/file_system_path_manager.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/file_system_util.h"
-#include "webkit/fileapi/quota_file_util.h"
namespace fileapi {
-LocalFileSystemFileUtil* LocalFileSystemFileUtil::GetInstance() {
- return Singleton<LocalFileSystemFileUtil>::get();
+LocalFileSystemFileUtil::LocalFileSystemFileUtil(
+ FileSystemFileUtil* underlying_file_util)
+ : underlying_file_util_(underlying_file_util) {
}
PlatformFileError LocalFileSystemFileUtil::CreateOrOpen(
@@ -28,7 +28,7 @@ PlatformFileError LocalFileSystemFileUtil::CreateOrOpen(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->CreateOrOpen(
+ return underlying_file_util_->CreateOrOpen(
context, local_path, file_flags, file_handle, created);
}
@@ -41,7 +41,7 @@ PlatformFileError LocalFileSystemFileUtil::EnsureFileExists(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->EnsureFileExists(
+ return underlying_file_util_->EnsureFileExists(
context, local_path, created);
}
@@ -69,7 +69,7 @@ PlatformFileError LocalFileSystemFileUtil::GetFileInfo(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->GetFileInfo(
+ return underlying_file_util_->GetFileInfo(
context, local_path, file_info, platform_file_path);
}
@@ -83,7 +83,7 @@ PlatformFileError LocalFileSystemFileUtil::ReadDirectory(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->ReadDirectory(
+ return underlying_file_util_->ReadDirectory(
context, local_path, entries);
}
@@ -97,7 +97,7 @@ PlatformFileError LocalFileSystemFileUtil::CreateDirectory(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->CreateDirectory(
+ return underlying_file_util_->CreateDirectory(
context, local_path, exclusive, recursive);
}
@@ -117,7 +117,7 @@ PlatformFileError LocalFileSystemFileUtil::CopyOrMoveFile(
dest_file_path);
if (local_dest_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->CopyOrMoveFile(
+ return underlying_file_util_->CopyOrMoveFile(
context, local_src_path, local_dest_path, copy);
}
@@ -132,7 +132,7 @@ PlatformFileError LocalFileSystemFileUtil::CopyInForeignFile(
dest_file_path);
if (local_dest_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->CopyOrMoveFile(
+ return underlying_file_util_->CopyOrMoveFile(
context, src_file_path, local_dest_path, true);
}
@@ -144,7 +144,7 @@ PlatformFileError LocalFileSystemFileUtil::DeleteFile(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->DeleteFile(
+ return underlying_file_util_->DeleteFile(
context, local_path);
}
@@ -156,7 +156,7 @@ PlatformFileError LocalFileSystemFileUtil::DeleteSingleDirectory(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->DeleteSingleDirectory(
+ return underlying_file_util_->DeleteSingleDirectory(
context, local_path);
}
@@ -170,7 +170,7 @@ PlatformFileError LocalFileSystemFileUtil::Touch(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->Touch(
+ return underlying_file_util_->Touch(
context, local_path, last_access_time, last_modified_time);
}
@@ -183,7 +183,7 @@ PlatformFileError LocalFileSystemFileUtil::Truncate(
file_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- return QuotaFileUtil::GetInstance()->Truncate(
+ return underlying_file_util_->Truncate(
context, local_path, length);
}
@@ -195,7 +195,7 @@ bool LocalFileSystemFileUtil::PathExists(
file_path);
if (local_path.empty())
return false;
- return QuotaFileUtil::GetInstance()->PathExists(
+ return underlying_file_util_->PathExists(
context, local_path);
}
@@ -207,7 +207,7 @@ bool LocalFileSystemFileUtil::DirectoryExists(
file_path);
if (local_path.empty())
return false;
- return QuotaFileUtil::GetInstance()->DirectoryExists(
+ return underlying_file_util_->DirectoryExists(
context, local_path);
}
@@ -219,7 +219,7 @@ bool LocalFileSystemFileUtil::IsDirectoryEmpty(
file_path);
if (local_path.empty())
return true;
- return QuotaFileUtil::GetInstance()->IsDirectoryEmpty(
+ return underlying_file_util_->IsDirectoryEmpty(
context, local_path);
}
diff --git a/webkit/fileapi/local_file_system_file_util.h b/webkit/fileapi/local_file_system_file_util.h
index 8b18f68..6d9ef74 100644
--- a/webkit/fileapi/local_file_system_file_util.h
+++ b/webkit/fileapi/local_file_system_file_util.h
@@ -12,10 +12,7 @@
#include "base/file_util.h"
#include "base/file_util_proxy.h"
#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/singleton.h"
#include "base/platform_file.h"
-#include "base/tracked_objects.h"
#include "webkit/fileapi/file_system_file_util.h"
#include "webkit/fileapi/file_system_types.h"
@@ -34,9 +31,12 @@ using base::PlatformFileError;
class FileSystemOperationContext;
+// An instance of this class is created and owned by *MountPointProvider.
class LocalFileSystemFileUtil : public FileSystemFileUtil {
public:
- static LocalFileSystemFileUtil* GetInstance();
+ // |underlying_file_util| is not owned by the instance. It will need to be
+ // a singleton or to be deleted by someone else.
+ explicit LocalFileSystemFileUtil(FileSystemFileUtil* underlying_file_util);
virtual PlatformFileError CreateOrOpen(
FileSystemOperationContext* context,
@@ -117,12 +117,6 @@ class LocalFileSystemFileUtil : public FileSystemFileUtil {
FileSystemOperationContext* context,
const FilePath& root_path);
- protected:
- LocalFileSystemFileUtil() { }
-
- friend struct DefaultSingletonTraits<LocalFileSystemFileUtil>;
- DISALLOW_COPY_AND_ASSIGN(LocalFileSystemFileUtil);
-
private:
// Given the filesystem's root URL and a virtual path, produces a real, full
// local path.
@@ -131,6 +125,10 @@ class LocalFileSystemFileUtil : public FileSystemFileUtil {
const GURL& origin_url,
FileSystemType type,
const FilePath& virtual_path);
+
+ FileSystemFileUtil* underlying_file_util_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocalFileSystemFileUtil);
};
} // namespace fileapi
diff --git a/webkit/fileapi/local_file_system_file_util_unittest.cc b/webkit/fileapi/local_file_system_file_util_unittest.cc
index a446c87..1e8109d 100644
--- a/webkit/fileapi/local_file_system_file_util_unittest.cc
+++ b/webkit/fileapi/local_file_system_file_util_unittest.cc
@@ -19,8 +19,6 @@
#include "webkit/fileapi/file_system_test_helper.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/local_file_system_file_util.h"
-#include "webkit/fileapi/quota_file_util.h"
-#include "webkit/quota/quota_manager.h"
namespace fileapi {
@@ -28,7 +26,9 @@ namespace fileapi {
class LocalFileSystemFileUtilTest : public testing::Test {
public:
LocalFileSystemFileUtilTest()
- : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ : local_file_util_(
+ new LocalFileSystemFileUtil(FileSystemFileUtil::GetInstance())),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
void SetUp() {
@@ -43,12 +43,11 @@ class LocalFileSystemFileUtilTest : public testing::Test {
protected:
FileSystemOperationContext* NewContext() {
FileSystemOperationContext* context = test_helper_.NewOperationContext();
- context->set_allowed_bytes_growth(QuotaFileUtil::kNoLimit);
return context;
}
LocalFileSystemFileUtil* FileUtil() {
- return LocalFileSystemFileUtil::GetInstance();
+ return local_file_util_.get();
}
static FilePath Path(const std::string& file_name) {
@@ -95,6 +94,7 @@ class LocalFileSystemFileUtilTest : public testing::Test {
}
private:
+ scoped_ptr<LocalFileSystemFileUtil> local_file_util_;
ScopedTempDir data_dir_;
FileSystemTestOriginHelper test_helper_;
diff --git a/webkit/fileapi/obfuscated_file_system_file_util.cc b/webkit/fileapi/obfuscated_file_system_file_util.cc
index a9c1c94..ce8c501 100644
--- a/webkit/fileapi/obfuscated_file_system_file_util.cc
+++ b/webkit/fileapi/obfuscated_file_system_file_util.cc
@@ -20,7 +20,6 @@
#include "webkit/fileapi/file_system_operation_context.h"
#include "webkit/fileapi/file_system_path_manager.h"
#include "webkit/fileapi/file_system_util.h"
-#include "webkit/fileapi/quota_file_util.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
// TODO(ericu): Make deleting an origin [or a type under the origin, if it's the
@@ -54,8 +53,10 @@ using base::PlatformFile;
using base::PlatformFileError;
ObfuscatedFileSystemFileUtil::ObfuscatedFileSystemFileUtil(
- const FilePath& file_system_directory)
- : file_system_directory_(file_system_directory) {
+ const FilePath& file_system_directory,
+ FileSystemFileUtil* underlying_file_util)
+ : file_system_directory_(file_system_directory),
+ underlying_file_util_(underlying_file_util) {
}
ObfuscatedFileSystemFileUtil::~ObfuscatedFileSystemFileUtil() {
@@ -103,7 +104,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CreateOrOpen(
return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
FilePath data_path = DataPathToLocalPath(context->src_origin_url(),
context->src_type(), file_info.data_path);
- return QuotaFileUtil::GetInstance()->CreateOrOpen(
+ return underlying_file_util_->CreateOrOpen(
context, data_path, file_flags, file_handle, created);
}
@@ -184,7 +185,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::GetFileInfo(
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
FilePath data_path = DataPathToLocalPath(context->src_origin_url(),
context->src_type(), local_info.data_path);
- return QuotaFileUtil::GetInstance()->GetFileInfo(
+ return underlying_file_util_->GetFileInfo(
context, data_path, file_info, platform_file_path);
}
@@ -327,7 +328,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CopyOrMoveFile(
if (overwrite) {
FilePath dest_data_path = DataPathToLocalPath(context->src_origin_url(),
context->src_type(), dest_file_info.data_path);
- return QuotaFileUtil::GetInstance()->CopyOrMoveFile(context,
+ return underlying_file_util_->CopyOrMoveFile(context,
src_data_path, dest_data_path, copy);
} else {
FileId dest_parent_id;
@@ -348,7 +349,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CopyOrMoveFile(
FilePath dest_data_path = DataPathToLocalPath(context->src_origin_url(),
context->src_type(), dest_file_info.data_path);
if (base::PLATFORM_FILE_OK !=
- QuotaFileUtil::GetInstance()->DeleteFile(context, dest_data_path))
+ underlying_file_util_->DeleteFile(context, dest_data_path))
LOG(WARNING) << "Leaked a backing file.";
return base::PLATFORM_FILE_OK;
} else {
@@ -387,7 +388,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CopyInForeignFile(
}
FilePath dest_data_path = DataPathToLocalPath(context->dest_origin_url(),
context->dest_type(), dest_file_info.data_path);
- return QuotaFileUtil::GetInstance()->CopyOrMoveFile(context,
+ return underlying_file_util_->CopyOrMoveFile(context,
src_file_path, dest_data_path, true /* copy */);
} else {
FileId dest_parent_id;
@@ -425,7 +426,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::DeleteFile(
FilePath data_path = DataPathToLocalPath(context->src_origin_url(),
context->src_type(), file_info.data_path);
if (base::PLATFORM_FILE_OK !=
- QuotaFileUtil::GetInstance()->DeleteFile(context, data_path))
+ underlying_file_util_->DeleteFile(context, data_path))
LOG(WARNING) << "Leaked a backing file.";
return base::PLATFORM_FILE_OK;
}
@@ -474,7 +475,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::Touch(
}
FilePath data_path = DataPathToLocalPath(context->src_origin_url(),
context->src_type(), file_info.data_path);
- return QuotaFileUtil::GetInstance()->Touch(
+ return underlying_file_util_->Touch(
context, data_path, last_access_time, last_modified_time);
}
FileId parent_id;
@@ -492,7 +493,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::Touch(
FilePath data_path = DataPathToLocalPath(context->src_origin_url(),
context->src_type(), file_info.data_path);
- return QuotaFileUtil::GetInstance()->Touch(context, data_path,
+ return underlying_file_util_->Touch(context, data_path,
last_access_time, last_modified_time);
}
@@ -505,7 +506,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::Truncate(
virtual_path);
if (local_path.empty())
return base::PLATFORM_FILE_ERROR_NOT_FOUND;
- return QuotaFileUtil::GetInstance()->Truncate(
+ return underlying_file_util_->Truncate(
context, local_path, length);
}
@@ -718,7 +719,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CreateFile(
path = path.AppendASCII(StringPrintf("%02" PRIu64, directory_number));
PlatformFileError error;
- error = QuotaFileUtil::GetInstance()->CreateDirectory(
+ error = underlying_file_util_->CreateDirectory(
context, path, false /* exclusive */, false /* recursive */);
if (base::PLATFORM_FILE_OK != error)
return error;
@@ -730,17 +731,17 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CreateFile(
if (!source_path.empty()) {
DCHECK(!file_flags);
DCHECK(!handle);
- error = QuotaFileUtil::GetInstance()->CopyOrMoveFile(
+ error = underlying_file_util_->CopyOrMoveFile(
context, source_path, path, true /* copy */);
created = true;
} else {
if (handle) {
- error = QuotaFileUtil::GetInstance()->CreateOrOpen(
+ error = underlying_file_util_->CreateOrOpen(
context, path, file_flags, handle, &created);
// If this succeeds, we must close handle on any subsequent error.
} else {
DCHECK(!file_flags); // file_flags is only used by CreateOrOpen.
- error = QuotaFileUtil::GetInstance()->EnsureFileExists(
+ error = underlying_file_util_->EnsureFileExists(
context, path, &created);
}
}
@@ -752,7 +753,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CreateFile(
if (handle) {
DCHECK_NE(base::kInvalidPlatformFileValue, *handle);
base::ClosePlatformFile(*handle);
- QuotaFileUtil::GetInstance()->DeleteFile(context, path);
+ underlying_file_util_->DeleteFile(context, path);
}
return base::PLATFORM_FILE_ERROR_FAILED;
}
@@ -763,7 +764,7 @@ PlatformFileError ObfuscatedFileSystemFileUtil::CreateFile(
DCHECK_NE(base::kInvalidPlatformFileValue, *handle);
base::ClosePlatformFile(*handle);
}
- QuotaFileUtil::GetInstance()->DeleteFile(context, path);
+ underlying_file_util_->DeleteFile(context, path);
return base::PLATFORM_FILE_ERROR_FAILED;
}
diff --git a/webkit/fileapi/obfuscated_file_system_file_util.h b/webkit/fileapi/obfuscated_file_system_file_util.h
index 88caa65..6b0aa62 100644
--- a/webkit/fileapi/obfuscated_file_system_file_util.h
+++ b/webkit/fileapi/obfuscated_file_system_file_util.h
@@ -47,8 +47,11 @@ class FileSystemOperationContext;
class ObfuscatedFileSystemFileUtil : public FileSystemFileUtil,
public base::RefCountedThreadSafe<ObfuscatedFileSystemFileUtil> {
public:
-
- ObfuscatedFileSystemFileUtil(const FilePath& file_system_directory);
+ // |underlying_file_util| is not owned by the instance. It will need to be
+ // a singleton or to be deleted by someone else.
+ ObfuscatedFileSystemFileUtil(
+ const FilePath& file_system_directory,
+ FileSystemFileUtil* underlying_file_util);
virtual ~ObfuscatedFileSystemFileUtil();
virtual base::PlatformFileError CreateOrOpen(
@@ -224,6 +227,7 @@ class ObfuscatedFileSystemFileUtil : public FileSystemFileUtil,
scoped_ptr<FileSystemOriginDatabase> origin_database_;
FilePath file_system_directory_;
base::OneShotTimer<ObfuscatedFileSystemFileUtil> timer_;
+ FileSystemFileUtil* underlying_file_util_;
DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileSystemFileUtil);
};
diff --git a/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc b/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
index 4d5b1f5..f865393 100644
--- a/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
+++ b/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
@@ -133,7 +133,8 @@ class ObfuscatedFileSystemFileUtilTest : public testing::Test {
ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
obfuscated_file_system_file_util_ =
- new ObfuscatedFileSystemFileUtil(data_dir_.path());
+ new ObfuscatedFileSystemFileUtil(data_dir_.path(),
+ FileSystemFileUtil::GetInstance());
test_helper_.SetUp(data_dir_.path(),
false, // incognito
false, // unlimited quota
@@ -143,7 +144,6 @@ class ObfuscatedFileSystemFileUtilTest : public testing::Test {
FileSystemOperationContext* NewContext() {
FileSystemOperationContext* context = test_helper_.NewOperationContext();
- context->set_allowed_bytes_growth(1024 * 1024);
return context;
}
diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc
index ca900ba..792b77d 100644
--- a/webkit/fileapi/sandbox_mount_point_provider.cc
+++ b/webkit/fileapi/sandbox_mount_point_provider.cc
@@ -21,6 +21,7 @@
#include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/local_file_system_file_util.h"
#include "webkit/fileapi/obfuscated_file_system_file_util.h"
+#include "webkit/fileapi/quota_file_util.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/quota/quota_manager.h"
@@ -279,7 +280,8 @@ SandboxMountPointProvider::SandboxMountPointProvider(
profile_path_(profile_path),
sandbox_file_util_(
new ObfuscatedFileSystemFileUtil(
- profile_path.Append(kNewFileSystemDirectory))) {
+ profile_path.Append(kNewFileSystemDirectory),
+ QuotaFileUtil::GetInstance())) {
}
SandboxMountPointProvider::~SandboxMountPointProvider() {
diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h
index 6ea001b..b390fe5 100644
--- a/webkit/fileapi/sandbox_mount_point_provider.h
+++ b/webkit/fileapi/sandbox_mount_point_provider.h
@@ -115,7 +115,7 @@ class SandboxMountPointProvider
FileSystemType type,
bool create) const;
- FileSystemFileUtil* GetFileSystemFileUtil();
+ virtual FileSystemFileUtil* GetFileSystemFileUtil();
// Deletes the data on the origin and reports the amount of deleted data
// to the quota manager via |proxy|.