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

Unified Diff: webkit/fileapi/sandbox_file_system_test_helper.cc

Issue 15810004: Cleanup: Rename LocalFileSystemTestOriginHelper (aka test_helper_) to SandboxFileSystemTestHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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/sandbox_file_system_test_helper.cc
diff --git a/webkit/fileapi/local_file_system_test_helper.cc b/webkit/fileapi/sandbox_file_system_test_helper.cc
similarity index 62%
rename from webkit/fileapi/local_file_system_test_helper.cc
rename to webkit/fileapi/sandbox_file_system_test_helper.cc
index aa438d4c2dfed1d23eca2790edbe344323f59422..e7bb93756cfb96c720417d790bb937af7fdb9061 100644
--- a/webkit/fileapi/local_file_system_test_helper.cc
+++ b/webkit/fileapi/sandbox_file_system_test_helper.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/fileapi/local_file_system_test_helper.h"
+#include "webkit/fileapi/sandbox_file_system_test_helper.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -22,72 +22,51 @@
namespace fileapi {
-LocalFileSystemTestOriginHelper::LocalFileSystemTestOriginHelper(
+SandboxFileSystemTestHelper::SandboxFileSystemTestHelper(
const GURL& origin, FileSystemType type)
: origin_(origin), type_(type), file_util_(NULL) {
}
-LocalFileSystemTestOriginHelper::LocalFileSystemTestOriginHelper()
+SandboxFileSystemTestHelper::SandboxFileSystemTestHelper()
: origin_(GURL("http://foo.com")),
type_(kFileSystemTypeTemporary),
file_util_(NULL) {
}
-LocalFileSystemTestOriginHelper::~LocalFileSystemTestOriginHelper() {
+SandboxFileSystemTestHelper::~SandboxFileSystemTestHelper() {
}
-void LocalFileSystemTestOriginHelper::SetUp(const base::FilePath& base_dir) {
+void SandboxFileSystemTestHelper::SetUp(const base::FilePath& base_dir) {
SetUp(base_dir, NULL);
}
-void LocalFileSystemTestOriginHelper::SetUp(
+void SandboxFileSystemTestHelper::SetUp(
FileSystemContext* file_system_context) {
file_system_context_ = file_system_context;
- SetUpFileUtil();
-
- // Prepare the origin's root directory.
- file_system_context_->GetMountPointProvider(type_)->
- GetFileSystemRootPathOnFileThread(CreateURL(base::FilePath()),
- true /* create */);
-
- // Initialize the usage cache file.
- base::FilePath usage_cache_path = GetUsageCachePath();
- if (!usage_cache_path.empty())
- usage_cache()->UpdateUsage(usage_cache_path, 0);
+ SetUpFileSystem();
}
-void LocalFileSystemTestOriginHelper::SetUp(
+void SandboxFileSystemTestHelper::SetUp(
const base::FilePath& base_dir,
quota::QuotaManagerProxy* quota_manager_proxy) {
file_system_context_ = CreateFileSystemContextForTesting(
quota_manager_proxy, base_dir);
- SetUpFileUtil();
-
- // Prepare the origin's root directory.
- FileSystemMountPointProvider* mount_point_provider =
- file_system_context_->GetMountPointProvider(type_);
- mount_point_provider->GetFileSystemRootPathOnFileThread(
- CreateURL(base::FilePath()), true /* create */);
-
- // Initialize the usage cache file.
- base::FilePath usage_cache_path = GetUsageCachePath();
- if (!usage_cache_path.empty())
- usage_cache()->UpdateUsage(usage_cache_path, 0);
+ SetUpFileSystem();
}
-void LocalFileSystemTestOriginHelper::TearDown() {
+void SandboxFileSystemTestHelper::TearDown() {
file_system_context_ = NULL;
base::MessageLoop::current()->RunUntilIdle();
}
-base::FilePath LocalFileSystemTestOriginHelper::GetOriginRootPath() const {
- return file_system_context_->GetMountPointProvider(type_)->
- GetFileSystemRootPathOnFileThread(CreateURL(base::FilePath()), false);
+base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() const {
+ return file_system_context_->sandbox_provider()->
+ GetBaseDirectoryForOriginAndType(origin_, type_, false);
}
-base::FilePath LocalFileSystemTestOriginHelper::GetLocalPath(
+base::FilePath SandboxFileSystemTestHelper::GetLocalPath(
const base::FilePath& path) {
DCHECK(file_util_);
base::FilePath local_path;
@@ -96,31 +75,27 @@ base::FilePath LocalFileSystemTestOriginHelper::GetLocalPath(
return local_path;
}
-base::FilePath LocalFileSystemTestOriginHelper::GetLocalPathFromASCII(
+base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII(
const std::string& path) {
return GetLocalPath(base::FilePath().AppendASCII(path));
}
-base::FilePath LocalFileSystemTestOriginHelper::GetUsageCachePath() const {
- if (type_ != kFileSystemTypeTemporary &&
- type_ != kFileSystemTypePersistent &&
- type_ != kFileSystemTypeSyncable)
- return base::FilePath();
+base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const {
return file_system_context_->
sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_);
}
-FileSystemURL LocalFileSystemTestOriginHelper::CreateURL(
+FileSystemURL SandboxFileSystemTestHelper::CreateURL(
const base::FilePath& path) const {
return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path);
}
-int64 LocalFileSystemTestOriginHelper::GetCachedOriginUsage() const {
+int64 SandboxFileSystemTestHelper::GetCachedOriginUsage() const {
return file_system_context_->GetQuotaUtil(type_)->GetOriginUsageOnFileThread(
file_system_context_, origin_, type_);
}
-int64 LocalFileSystemTestOriginHelper::ComputeCurrentOriginUsage() {
+int64 SandboxFileSystemTestHelper::ComputeCurrentOriginUsage() {
usage_cache()->CloseCacheFiles();
int64 size = file_util::ComputeDirectorySize(GetOriginRootPath());
if (file_util::PathExists(GetUsageCachePath()))
@@ -129,16 +104,14 @@ int64 LocalFileSystemTestOriginHelper::ComputeCurrentOriginUsage() {
}
int64
-LocalFileSystemTestOriginHelper::ComputeCurrentDirectoryDatabaseUsage() const {
+SandboxFileSystemTestHelper::ComputeCurrentDirectoryDatabaseUsage() const {
return file_util::ComputeDirectorySize(
GetOriginRootPath().AppendASCII("Paths"));
}
-LocalFileSystemOperation* LocalFileSystemTestOriginHelper::NewOperation() {
+LocalFileSystemOperation* SandboxFileSystemTestHelper::NewOperation() {
DCHECK(file_system_context_.get());
DCHECK(file_util_);
- scoped_ptr<FileSystemOperationContext> operation_context(
- NewOperationContext());
LocalFileSystemOperation* operation = static_cast<LocalFileSystemOperation*>(
file_system_context_->CreateFileSystemOperation(
CreateURL(base::FilePath()), NULL));
@@ -146,7 +119,7 @@ LocalFileSystemOperation* LocalFileSystemTestOriginHelper::NewOperation() {
}
FileSystemOperationContext*
-LocalFileSystemTestOriginHelper::NewOperationContext() {
+SandboxFileSystemTestHelper::NewOperationContext() {
DCHECK(file_system_context_.get());
FileSystemOperationContext* context =
new FileSystemOperationContext(file_system_context_.get());
@@ -155,14 +128,26 @@ LocalFileSystemTestOriginHelper::NewOperationContext() {
return context;
}
-FileSystemUsageCache* LocalFileSystemTestOriginHelper::usage_cache() {
+FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() {
return file_system_context()->sandbox_provider()->usage_cache();
}
-void LocalFileSystemTestOriginHelper::SetUpFileUtil() {
+void SandboxFileSystemTestHelper::SetUpFileSystem() {
DCHECK(file_system_context_);
+ DCHECK(file_system_context_->sandbox_provider()->CanHandleType(type_));
+
file_util_ = file_system_context_->GetFileUtil(type_);
DCHECK(file_util_);
+
+ // Prepare the origin's root directory.
+ file_system_context_->sandbox_provider()->
+ GetFileSystemRootPathOnFileThread(CreateURL(base::FilePath()),
+ true /* create */);
+
+ // Initialize the usage cache file.
+ base::FilePath usage_cache_path = GetUsageCachePath();
+ if (!usage_cache_path.empty())
+ usage_cache()->UpdateUsage(usage_cache_path, 0);
}
} // namespace fileapi
« no previous file with comments | « webkit/fileapi/sandbox_file_system_test_helper.h ('k') | webkit/fileapi/syncable/syncable_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698