summaryrefslogtreecommitdiff
path: root/chromium/webkit/browser/fileapi
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/webkit/browser/fileapi')
-rw-r--r--chromium/webkit/browser/fileapi/file_permission_policy.cc19
-rw-r--r--chromium/webkit/browser/fileapi/file_permission_policy.h2
-rw-r--r--chromium/webkit/browser/fileapi/file_system_context.cc4
-rw-r--r--chromium/webkit/browser/fileapi/file_system_context.h8
-rw-r--r--chromium/webkit/browser/fileapi/file_system_quota_util.h5
-rw-r--r--chromium/webkit/browser/fileapi/obfuscated_file_util.cc4
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_context.cc (renamed from chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc)89
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_context.h (renamed from chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h)33
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_context_unittest.cc (renamed from chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc)36
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_directory_database.cc4
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc76
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_backend.h14
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc28
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc10
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_origin_database.cc4
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_quota_observer.cc4
-rw-r--r--chromium/webkit/browser/fileapi/test_file_system_backend.cc11
17 files changed, 184 insertions, 167 deletions
diff --git a/chromium/webkit/browser/fileapi/file_permission_policy.cc b/chromium/webkit/browser/fileapi/file_permission_policy.cc
index 164548791db..6f1a36c3440 100644
--- a/chromium/webkit/browser/fileapi/file_permission_policy.cc
+++ b/chromium/webkit/browser/fileapi/file_permission_policy.cc
@@ -21,14 +21,17 @@ const int kWriteFilePermissions = base::PLATFORM_FILE_OPEN |
const int kCreateFilePermissions = base::PLATFORM_FILE_CREATE;
-const int kOpenFilePermissions = base::PLATFORM_FILE_CREATE |
- base::PLATFORM_FILE_OPEN_ALWAYS |
- base::PLATFORM_FILE_CREATE_ALWAYS |
- base::PLATFORM_FILE_OPEN_TRUNCATED |
- base::PLATFORM_FILE_WRITE |
- base::PLATFORM_FILE_EXCLUSIVE_WRITE |
- base::PLATFORM_FILE_DELETE_ON_CLOSE |
- base::PLATFORM_FILE_WRITE_ATTRIBUTES;
+const int kOpenPepperFilePermissions = base::PLATFORM_FILE_OPEN |
+ base::PLATFORM_FILE_CREATE |
+ base::PLATFORM_FILE_OPEN_ALWAYS |
+ base::PLATFORM_FILE_CREATE_ALWAYS |
+ base::PLATFORM_FILE_OPEN_TRUNCATED |
+ base::PLATFORM_FILE_READ |
+ base::PLATFORM_FILE_WRITE |
+ base::PLATFORM_FILE_APPEND |
+ base::PLATFORM_FILE_EXCLUSIVE_WRITE |
+ base::PLATFORM_FILE_DELETE_ON_CLOSE |
+ base::PLATFORM_FILE_WRITE_ATTRIBUTES;
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/file_permission_policy.h b/chromium/webkit/browser/fileapi/file_permission_policy.h
index 3975c3ccace..5c9ced54e8a 100644
--- a/chromium/webkit/browser/fileapi/file_permission_policy.h
+++ b/chromium/webkit/browser/fileapi/file_permission_policy.h
@@ -12,7 +12,7 @@ namespace fileapi {
WEBKIT_STORAGE_BROWSER_EXPORT extern const int kReadFilePermissions;
WEBKIT_STORAGE_BROWSER_EXPORT extern const int kWriteFilePermissions;
WEBKIT_STORAGE_BROWSER_EXPORT extern const int kCreateFilePermissions;
-WEBKIT_STORAGE_BROWSER_EXPORT extern const int kOpenFilePermissions;
+WEBKIT_STORAGE_BROWSER_EXPORT extern const int kOpenPepperFilePermissions;
enum FilePermissionPolicy {
// Any access should be always denied.
diff --git a/chromium/webkit/browser/fileapi/file_system_context.cc b/chromium/webkit/browser/fileapi/file_system_context.cc
index f2973d35fa2..d43ba8a846e 100644
--- a/chromium/webkit/browser/fileapi/file_system_context.cc
+++ b/chromium/webkit/browser/fileapi/file_system_context.cc
@@ -108,14 +108,14 @@ FileSystemContext::FileSystemContext(
: io_task_runner_(io_task_runner),
default_file_task_runner_(file_task_runner),
quota_manager_proxy_(quota_manager_proxy),
- sandbox_delegate_(new SandboxFileSystemBackendDelegate(
+ sandbox_context_(new SandboxContext(
quota_manager_proxy,
file_task_runner,
partition_path,
special_storage_policy,
options)),
sandbox_backend_(new SandboxFileSystemBackend(
- sandbox_delegate_.get())),
+ sandbox_context_.get())),
isolated_backend_(new IsolatedFileSystemBackend()),
additional_backends_(additional_backends.Pass()),
external_mount_points_(external_mount_points),
diff --git a/chromium/webkit/browser/fileapi/file_system_context.h b/chromium/webkit/browser/fileapi/file_system_context.h
index 528f7a26021..d6934ec7c68 100644
--- a/chromium/webkit/browser/fileapi/file_system_context.h
+++ b/chromium/webkit/browser/fileapi/file_system_context.h
@@ -17,7 +17,7 @@
#include "base/sequenced_task_runner_helpers.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/open_file_system_mode.h"
-#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
+#include "webkit/browser/fileapi/sandbox_context.h"
#include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/fileapi/file_system_types.h"
@@ -228,9 +228,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
void EnableTemporaryFileSystemInIncognito();
#endif
- SandboxFileSystemBackendDelegate* sandbox_delegate() {
- return sandbox_delegate_.get();
- }
+ SandboxContext* sandbox_context() { return sandbox_context_.get(); }
private:
typedef std::map<FileSystemType, FileSystemBackend*>
@@ -285,7 +283,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
- scoped_ptr<SandboxFileSystemBackendDelegate> sandbox_delegate_;
+ scoped_ptr<SandboxContext> sandbox_context_;
// Regular file system backends.
scoped_ptr<SandboxFileSystemBackend> sandbox_backend_;
diff --git a/chromium/webkit/browser/fileapi/file_system_quota_util.h b/chromium/webkit/browser/fileapi/file_system_quota_util.h
index 5655c990d4d..be98936c2f5 100644
--- a/chromium/webkit/browser/fileapi/file_system_quota_util.h
+++ b/chromium/webkit/browser/fileapi/file_system_quota_util.h
@@ -56,6 +56,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemQuotaUtil {
const GURL& origin_url,
fileapi::FileSystemType type) = 0;
+ virtual void InvalidateUsageCache(const GURL& origin_url,
+ fileapi::FileSystemType type) = 0;
+ virtual void StickyInvalidateUsageCache(const GURL& origin,
+ fileapi::FileSystemType type) = 0;
+
virtual void AddFileUpdateObserver(
FileSystemType type,
FileUpdateObserver* observer,
diff --git a/chromium/webkit/browser/fileapi/obfuscated_file_util.cc b/chromium/webkit/browser/fileapi/obfuscated_file_util.cc
index 7e2f7df12a8..77e2d86a7e7 100644
--- a/chromium/webkit/browser/fileapi/obfuscated_file_util.cc
+++ b/chromium/webkit/browser/fileapi/obfuscated_file_util.cc
@@ -276,7 +276,7 @@ PlatformFileError ObfuscatedFileUtil::CreateOrOpen(
file_flags & base::PLATFORM_FILE_WRITE &&
context->quota_limit_type() == quota::kQuotaLimitTypeUnlimited) {
DCHECK_EQ(base::PLATFORM_FILE_OK, error);
- context->file_system_context()->sandbox_delegate()->
+ context->file_system_context()->GetQuotaUtil(url.type())->
StickyInvalidateUsageCache(url.origin(), url.type());
}
return error;
@@ -1261,7 +1261,7 @@ void ObfuscatedFileUtil::InvalidateUsageCache(
FileSystemOperationContext* context,
const GURL& origin,
FileSystemType type) {
- context->file_system_context()->sandbox_delegate()->
+ context->file_system_context()->GetQuotaUtil(type)->
InvalidateUsageCache(origin, type);
}
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc b/chromium/webkit/browser/fileapi/sandbox_context.cc
index 0a6034e7d9a..d8b7293b6a4 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_context.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/browser/fileapi/sandbox_file_system_backend_delegate.h"
+#include "webkit/browser/fileapi/sandbox_context.h"
#include "base/command_line.h"
#include "base/file_util.h"
@@ -53,7 +53,7 @@ const base::FilePath::CharType kRestrictedChars[] = {
};
class ObfuscatedOriginEnumerator
- : public SandboxFileSystemBackendDelegate::OriginEnumerator {
+ : public SandboxContext::OriginEnumerator {
public:
explicit ObfuscatedOriginEnumerator(ObfuscatedFileUtil* file_util) {
enum_.reset(file_util->CreateOriginEnumerator());
@@ -94,21 +94,20 @@ void OpenFileSystemOnFileThread(
}
void DidOpenFileSystem(
- base::WeakPtr<SandboxFileSystemBackendDelegate> delegate,
+ base::WeakPtr<SandboxContext> sandbox_context,
const base::Callback<void(base::PlatformFileError error)>& callback,
base::PlatformFileError* error) {
- if (delegate.get())
- delegate.get()->CollectOpenFileSystemMetrics(*error);
+ if (sandbox_context.get())
+ sandbox_context.get()->CollectOpenFileSystemMetrics(*error);
callback.Run(*error);
}
} // namespace
const base::FilePath::CharType
-SandboxFileSystemBackendDelegate::kFileSystemDirectory[] =
- FILE_PATH_LITERAL("File System");
+SandboxContext::kFileSystemDirectory[] = FILE_PATH_LITERAL("File System");
-SandboxFileSystemBackendDelegate::SandboxFileSystemBackendDelegate(
+SandboxContext::SandboxContext(
quota::QuotaManagerProxy* quota_manager_proxy,
base::SequencedTaskRunner* file_task_runner,
const base::FilePath& profile_path,
@@ -124,16 +123,16 @@ SandboxFileSystemBackendDelegate::SandboxFileSystemBackendDelegate(
quota_observer_(new SandboxQuotaObserver(
quota_manager_proxy,
file_task_runner,
- obfuscated_file_util(),
+ sync_file_util(),
usage_cache())),
special_storage_policy_(special_storage_policy),
file_system_options_(file_system_options),
weak_factory_(this) {
}
-SandboxFileSystemBackendDelegate::~SandboxFileSystemBackendDelegate() {
+SandboxContext::~SandboxContext() {
if (!file_task_runner_->RunsTasksOnCurrentThread()) {
- AsyncFileUtil* sandbox_file_util = sandbox_file_util_.release();
+ AsyncFileUtilAdapter* sandbox_file_util = sandbox_file_util_.release();
SandboxQuotaObserver* quota_observer = quota_observer_.release();
FileSystemUsageCache* file_system_usage_cache =
file_system_usage_cache_.release();
@@ -146,8 +145,7 @@ SandboxFileSystemBackendDelegate::~SandboxFileSystemBackendDelegate() {
}
}
-bool SandboxFileSystemBackendDelegate::IsAccessValid(
- const FileSystemURL& url) const {
+bool SandboxContext::IsAccessValid(const FileSystemURL& url) const {
if (!IsAllowedScheme(url.origin()))
return false;
@@ -178,7 +176,7 @@ bool SandboxFileSystemBackendDelegate::IsAccessValid(
return true;
}
-bool SandboxFileSystemBackendDelegate::IsAllowedScheme(const GURL& url) const {
+bool SandboxContext::IsAllowedScheme(const GURL& url) const {
// Basically we only accept http or https. We allow file:// URLs
// only if --allow-file-access-from-files flag is given.
if (url.SchemeIs("http") || url.SchemeIs("https"))
@@ -196,25 +194,21 @@ bool SandboxFileSystemBackendDelegate::IsAllowedScheme(const GURL& url) const {
return false;
}
-SandboxFileSystemBackendDelegate::OriginEnumerator*
-SandboxFileSystemBackendDelegate::CreateOriginEnumerator() {
- return new ObfuscatedOriginEnumerator(obfuscated_file_util());
+SandboxContext::OriginEnumerator* SandboxContext::CreateOriginEnumerator() {
+ return new ObfuscatedOriginEnumerator(sync_file_util());
}
-base::FilePath
-SandboxFileSystemBackendDelegate::GetBaseDirectoryForOriginAndType(
- const GURL& origin_url,
- fileapi::FileSystemType type,
- bool create) {
+base::FilePath SandboxContext::GetBaseDirectoryForOriginAndType(
+ const GURL& origin_url, fileapi::FileSystemType type, bool create) {
base::PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath path = obfuscated_file_util()->GetDirectoryForOriginAndType(
+ base::FilePath path = sync_file_util()->GetDirectoryForOriginAndType(
origin_url, type, create, &error);
if (error != base::PLATFORM_FILE_OK)
return base::FilePath();
return path;
}
-void SandboxFileSystemBackendDelegate::OpenFileSystem(
+void SandboxContext::OpenFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
OpenFileSystemMode mode,
@@ -231,7 +225,7 @@ void SandboxFileSystemBackendDelegate::OpenFileSystem(
file_task_runner_->PostTaskAndReply(
FROM_HERE,
base::Bind(&OpenFileSystemOnFileThread,
- obfuscated_file_util(), origin_url, type, mode,
+ sync_file_util(), origin_url, type, mode,
base::Unretained(error_ptr)),
base::Bind(&DidOpenFileSystem,
weak_factory_.GetWeakPtr(),
@@ -239,8 +233,7 @@ void SandboxFileSystemBackendDelegate::OpenFileSystem(
base::Owned(error_ptr)));
}
-base::PlatformFileError
-SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread(
+base::PlatformFileError SandboxContext::DeleteOriginDataOnFileThread(
FileSystemContext* file_system_context,
quota::QuotaManagerProxy* proxy,
const GURL& origin_url,
@@ -248,7 +241,7 @@ SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread(
int64 usage = GetOriginUsageOnFileThread(
file_system_context, origin_url, type);
usage_cache()->CloseCacheFiles();
- bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType(
+ bool result = sync_file_util()->DeleteDirectoryForOriginAndType(
origin_url, type);
if (result && proxy) {
proxy->NotifyStorageModified(
@@ -263,7 +256,7 @@ SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread(
return base::PLATFORM_FILE_ERROR_FAILED;
}
-void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread(
+void SandboxContext::GetOriginsForTypeOnFileThread(
fileapi::FileSystemType type, std::set<GURL>* origins) {
DCHECK(origins);
scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator());
@@ -274,7 +267,7 @@ void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread(
}
}
-void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread(
+void SandboxContext::GetOriginsForHostOnFileThread(
fileapi::FileSystemType type, const std::string& host,
std::set<GURL>* origins) {
DCHECK(origins);
@@ -287,7 +280,7 @@ void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread(
}
}
-int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileThread(
+int64 SandboxContext::GetOriginUsageOnFileThread(
FileSystemContext* file_system_context,
const GURL& origin_url,
fileapi::FileSystemType type) {
@@ -325,18 +318,18 @@ int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileThread(
return usage;
}
-void SandboxFileSystemBackendDelegate::InvalidateUsageCache(
+void SandboxContext::InvalidateUsageCache(
const GURL& origin,
fileapi::FileSystemType type) {
base::PlatformFileError error = base::PLATFORM_FILE_OK;
base::FilePath usage_file_path = GetUsageCachePathForOriginAndType(
- obfuscated_file_util(), origin, type, &error);
+ sync_file_util(), origin, type, &error);
if (error != base::PLATFORM_FILE_OK)
return;
usage_cache()->IncrementDirty(usage_file_path);
}
-void SandboxFileSystemBackendDelegate::StickyInvalidateUsageCache(
+void SandboxContext::StickyInvalidateUsageCache(
const GURL& origin,
fileapi::FileSystemType type) {
sticky_dirty_origins_.insert(std::make_pair(origin, type));
@@ -344,25 +337,19 @@ void SandboxFileSystemBackendDelegate::StickyInvalidateUsageCache(
InvalidateUsageCache(origin, type);
}
-FileSystemFileUtil* SandboxFileSystemBackendDelegate::sync_file_util() {
- return static_cast<AsyncFileUtilAdapter*>(file_util())->sync_file_util();
-}
-
-base::FilePath
-SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
+base::FilePath SandboxContext::GetUsageCachePathForOriginAndType(
const GURL& origin_url,
FileSystemType type) {
base::PlatformFileError error;
base::FilePath path = GetUsageCachePathForOriginAndType(
- obfuscated_file_util(), origin_url, type, &error);
+ sync_file_util(), origin_url, type, &error);
if (error != base::PLATFORM_FILE_OK)
return base::FilePath();
return path;
}
// static
-base::FilePath
-SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
+base::FilePath SandboxContext::GetUsageCachePathForOriginAndType(
ObfuscatedFileUtil* sandbox_file_util,
const GURL& origin_url,
fileapi::FileSystemType type,
@@ -376,16 +363,14 @@ SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
return base_path.Append(FileSystemUsageCache::kUsageFileName);
}
-int64 SandboxFileSystemBackendDelegate::RecalculateUsage(
- FileSystemContext* context,
- const GURL& origin,
- FileSystemType type) {
+int64 SandboxContext::RecalculateUsage(FileSystemContext* context,
+ const GURL& origin,
+ FileSystemType type) {
FileSystemOperationContext operation_context(context);
FileSystemURL url = context->CreateCrackedFileSystemURL(
origin, type, base::FilePath());
scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator(
- obfuscated_file_util()->CreateFileEnumerator(
- &operation_context, url, true));
+ sync_file_util()->CreateFileEnumerator(&operation_context, url, true));
base::FilePath file_path_each;
int64 usage = 0;
@@ -398,7 +383,7 @@ int64 SandboxFileSystemBackendDelegate::RecalculateUsage(
return usage;
}
-void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics(
+void SandboxContext::CollectOpenFileSystemMetrics(
base::PlatformFileError error_code) {
base::Time now = base::Time::Now();
bool throttled = now < next_release_time_for_open_filesystem_stat_;
@@ -435,8 +420,8 @@ void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics(
#undef REPORT
}
-ObfuscatedFileUtil* SandboxFileSystemBackendDelegate::obfuscated_file_util() {
- return static_cast<ObfuscatedFileUtil*>(sync_file_util());
+ObfuscatedFileUtil* SandboxContext::sync_file_util() {
+ return static_cast<ObfuscatedFileUtil*>(file_util()->sync_file_util());
}
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h b/chromium/webkit/browser/fileapi/sandbox_context.h
index 5fb83f082b9..c765077b8d3 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h
+++ b/chromium/webkit/browser/fileapi/sandbox_context.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_
-#define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_
+#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_
+#define WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_
#include <set>
#include <string>
@@ -30,8 +30,7 @@ class SpecialStoragePolicy;
namespace fileapi {
-class AsyncFileUtil;
-class FileSystemFileUtil;
+class AsyncFileUtilAdapter;
class FileSystemURL;
class FileSystemUsageCache;
class ObfuscatedFileUtil;
@@ -39,9 +38,9 @@ class SandboxFileSystemBackend;
class SandboxFileSystemTestHelper;
class SandboxQuotaObserver;
-// Delegate implementation of the some methods in Sandbox/SyncFileSystemBackend.
+// This class keeps and provides a sandbox file system context.
// An instance of this class is created and owned by FileSystemContext.
-class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate {
+class WEBKIT_STORAGE_BROWSER_EXPORT SandboxContext {
public:
typedef FileSystemBackend::OpenFileSystemCallback OpenFileSystemCallback;
@@ -61,14 +60,14 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate {
virtual bool HasFileSystemType(FileSystemType type) const = 0;
};
- SandboxFileSystemBackendDelegate(
+ SandboxContext(
quota::QuotaManagerProxy* quota_manager_proxy,
base::SequencedTaskRunner* file_task_runner,
const base::FilePath& profile_path,
quota::SpecialStoragePolicy* special_storage_policy,
const FileSystemOptions& file_system_options);
- ~SandboxFileSystemBackendDelegate();
+ ~SandboxContext();
// Performs API-specific validity checks on the given path |url|.
// Returns true if access to |url| is valid in this filesystem.
@@ -131,7 +130,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate {
return file_task_runner_.get();
}
- AsyncFileUtil* file_util() { return sandbox_file_util_.get(); }
+ AsyncFileUtilAdapter* file_util() { return sandbox_file_util_.get(); }
FileSystemUsageCache* usage_cache() { return file_system_usage_cache_.get(); }
SandboxQuotaObserver* quota_observer() { return quota_observer_.get(); };
@@ -139,11 +138,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate {
return special_storage_policy_.get();
}
- const FileSystemOptions& file_system_options() const {
- return file_system_options_;
- }
+ FileSystemOptions file_system_options() { return file_system_options_; }
- FileSystemFileUtil* sync_file_util();
+ ObfuscatedFileUtil* sync_file_util();
private:
friend class SandboxQuotaObserver;
@@ -165,11 +162,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate {
const GURL& origin,
FileSystemType type);
- ObfuscatedFileUtil* obfuscated_file_util();
-
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
- scoped_ptr<AsyncFileUtil> sandbox_file_util_;
+ scoped_ptr<AsyncFileUtilAdapter> sandbox_file_util_;
scoped_ptr<FileSystemUsageCache> file_system_usage_cache_;
scoped_ptr<SandboxQuotaObserver> quota_observer_;
@@ -184,11 +179,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate {
base::Time next_release_time_for_open_filesystem_stat_;
- base::WeakPtrFactory<SandboxFileSystemBackendDelegate> weak_factory_;
+ base::WeakPtrFactory<SandboxContext> weak_factory_;
- DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackendDelegate);
+ DISALLOW_COPY_AND_ASSIGN(SandboxContext);
};
} // namespace fileapi
-#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_
+#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_context_unittest.cc
index 48c3b8c4e70..841e10b5b83 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_context_unittest.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/browser/fileapi/sandbox_file_system_backend_delegate.h"
+#include "webkit/browser/fileapi/sandbox_context.h"
#include "base/basictypes.h"
#include "base/file_util.h"
@@ -27,11 +27,11 @@ FileSystemURL CreateFileSystemURL(const char* path) {
} // namespace
-class SandboxFileSystemBackendDelegateTest : public testing::Test {
+class SandboxContextTest : public testing::Test {
protected:
virtual void SetUp() {
ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- delegate_.reset(new SandboxFileSystemBackendDelegate(
+ context_.reset(new SandboxContext(
NULL /* quota_manager_proxy */,
base::MessageLoopProxy::current().get(),
data_dir_.path(),
@@ -41,42 +41,42 @@ class SandboxFileSystemBackendDelegateTest : public testing::Test {
base::ScopedTempDir data_dir_;
base::MessageLoop message_loop_;
- scoped_ptr<SandboxFileSystemBackendDelegate> delegate_;
+ scoped_ptr<SandboxContext> context_;
};
-TEST_F(SandboxFileSystemBackendDelegateTest, IsAccessValid) {
+TEST_F(SandboxContextTest, IsAccessValid) {
// Normal case.
- EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("a")));
+ EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("a")));
// Access to a path with parent references ('..') should be disallowed.
- EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("a/../b")));
+ EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("a/../b")));
// Access from non-allowed scheme should be disallowed.
- EXPECT_FALSE(delegate_->IsAccessValid(
+ EXPECT_FALSE(context_->IsAccessValid(
FileSystemURL::CreateForTest(
GURL("unknown://bar"), kFileSystemTypeTemporary,
base::FilePath::FromUTF8Unsafe("foo"))));
// Access with restricted name should be disallowed.
- EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(".")));
- EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("..")));
+ EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(".")));
+ EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("..")));
// This is also disallowed due to Windows XP parent path handling.
- EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("...")));
+ EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("...")));
// These are identified as unsafe cases due to weird path handling
// on Windows.
- EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(" ..")));
- EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(".. ")));
+ EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(" ..")));
+ EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(".. ")));
// Similar but safe cases.
- EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(" .")));
- EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(". ")));
- EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("b.")));
- EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(".b")));
+ EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(" .")));
+ EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(". ")));
+ EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("b.")));
+ EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(".b")));
// A path that looks like a drive letter.
- EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("c:")));
+ EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("c:")));
}
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/sandbox_directory_database.cc b/chromium/webkit/browser/fileapi/sandbox_directory_database.cc
index 24790b15e31..8a90bd33479 100644
--- a/chromium/webkit/browser/fileapi/sandbox_directory_database.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_directory_database.cc
@@ -715,7 +715,7 @@ bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) {
FilePathToString(filesystem_data_directory_.Append(
kDirectoryDatabaseName));
leveldb::Options options;
- options.max_open_files = 0; // Use minimum.
+ options.max_open_files = 64; // Use minimum.
options.create_if_missing = true;
leveldb::DB* db;
leveldb::Status status = leveldb::DB::Open(options, path, &db);
@@ -763,7 +763,7 @@ bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) {
bool SandboxDirectoryDatabase::RepairDatabase(const std::string& db_path) {
DCHECK(!db_.get());
leveldb::Options options;
- options.max_open_files = 0; // Use minimum.
+ options.max_open_files = 64; // Use minimum.
if (!leveldb::RepairDB(db_path, options).ok())
return false;
if (!Init(FAIL_ON_CORRUPTION))
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc
index 665c0f1f798..20f732989d4 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc
@@ -19,8 +19,8 @@
#include "webkit/browser/fileapi/file_system_options.h"
#include "webkit/browser/fileapi/file_system_usage_cache.h"
#include "webkit/browser/fileapi/obfuscated_file_util.h"
+#include "webkit/browser/fileapi/sandbox_context.h"
#include "webkit/browser/fileapi/sandbox_file_stream_writer.h"
-#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
#include "webkit/browser/fileapi/sandbox_quota_observer.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/common/fileapi/file_system_types.h"
@@ -39,8 +39,8 @@ const char kPersistentOriginsCountLabel[] = "FileSystem.PersistentOriginsCount";
} // anonymous namespace
SandboxFileSystemBackend::SandboxFileSystemBackend(
- SandboxFileSystemBackendDelegate* delegate)
- : delegate_(delegate),
+ SandboxContext* sandbox_context)
+ : sandbox_context_(sandbox_context),
enable_temporary_file_system_in_incognito_(false) {
}
@@ -55,10 +55,10 @@ bool SandboxFileSystemBackend::CanHandleType(FileSystemType type) const {
void SandboxFileSystemBackend::Initialize(FileSystemContext* context) {
// Set quota observers.
update_observers_ = update_observers_.AddObserver(
- delegate_->quota_observer(),
- delegate_->file_task_runner());
+ sandbox_context_->quota_observer(),
+ sandbox_context_->file_task_runner());
access_observers_ = access_observers_.AddObserver(
- delegate_->quota_observer(), NULL);
+ sandbox_context_->quota_observer(), NULL);
}
void SandboxFileSystemBackend::OpenFileSystem(
@@ -67,8 +67,8 @@ void SandboxFileSystemBackend::OpenFileSystem(
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) {
DCHECK(CanHandleType(type));
- DCHECK(delegate_);
- if (delegate_->file_system_options().is_incognito() &&
+ DCHECK(sandbox_context_);
+ if (sandbox_context_->file_system_options().is_incognito() &&
!(type == kFileSystemTypeTemporary &&
enable_temporary_file_system_in_incognito_)) {
// TODO(kinuko): return an isolated temporary directory.
@@ -76,20 +76,20 @@ void SandboxFileSystemBackend::OpenFileSystem(
return;
}
- delegate_->OpenFileSystem(
+ sandbox_context_->OpenFileSystem(
origin_url, type, mode, callback,
GetFileSystemRootURI(origin_url, type));
}
FileSystemFileUtil* SandboxFileSystemBackend::GetFileUtil(
FileSystemType type) {
- return delegate_->sync_file_util();
+ return sandbox_context_->sync_file_util();
}
AsyncFileUtil* SandboxFileSystemBackend::GetAsyncFileUtil(
FileSystemType type) {
- DCHECK(delegate_);
- return delegate_->file_util();
+ DCHECK(sandbox_context_);
+ return sandbox_context_->file_util();
}
CopyOrMoveFileValidatorFactory*
@@ -106,8 +106,8 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation(
FileSystemContext* context,
base::PlatformFileError* error_code) const {
DCHECK(CanHandleType(url.type()));
- DCHECK(delegate_);
- if (!delegate_->IsAccessValid(url)) {
+ DCHECK(sandbox_context_);
+ if (!sandbox_context_->IsAccessValid(url)) {
*error_code = base::PLATFORM_FILE_ERROR_SECURITY;
return NULL;
}
@@ -117,7 +117,7 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation(
operation_context->set_update_observers(update_observers_);
operation_context->set_change_observers(change_observers_);
- SpecialStoragePolicy* policy = delegate_->special_storage_policy();
+ SpecialStoragePolicy* policy = sandbox_context_->special_storage_policy();
if (policy && policy->IsStorageUnlimited(url.origin()))
operation_context->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited);
else
@@ -133,8 +133,8 @@ SandboxFileSystemBackend::CreateFileStreamReader(
const base::Time& expected_modification_time,
FileSystemContext* context) const {
DCHECK(CanHandleType(url.type()));
- DCHECK(delegate_);
- if (!delegate_->IsAccessValid(url))
+ DCHECK(sandbox_context_);
+ if (!sandbox_context_->IsAccessValid(url))
return scoped_ptr<webkit_blob::FileStreamReader>();
return scoped_ptr<webkit_blob::FileStreamReader>(
new FileSystemFileStreamReader(
@@ -147,8 +147,8 @@ SandboxFileSystemBackend::CreateFileStreamWriter(
int64 offset,
FileSystemContext* context) const {
DCHECK(CanHandleType(url.type()));
- DCHECK(delegate_);
- if (!delegate_->IsAccessValid(url))
+ DCHECK(sandbox_context_);
+ if (!sandbox_context_->IsAccessValid(url))
return scoped_ptr<fileapi::FileStreamWriter>();
return scoped_ptr<fileapi::FileStreamWriter>(
new SandboxFileStreamWriter(context, url, offset, update_observers_));
@@ -158,10 +158,10 @@ FileSystemQuotaUtil* SandboxFileSystemBackend::GetQuotaUtil() {
return this;
}
-SandboxFileSystemBackendDelegate::OriginEnumerator*
+SandboxContext::OriginEnumerator*
SandboxFileSystemBackend::CreateOriginEnumerator() {
- DCHECK(delegate_);
- return delegate_->CreateOriginEnumerator();
+ DCHECK(sandbox_context_);
+ return sandbox_context_->CreateOriginEnumerator();
}
base::PlatformFileError
@@ -171,16 +171,16 @@ SandboxFileSystemBackend::DeleteOriginDataOnFileThread(
const GURL& origin_url,
fileapi::FileSystemType type) {
DCHECK(CanHandleType(type));
- DCHECK(delegate_);
- return delegate_->DeleteOriginDataOnFileThread(
+ DCHECK(sandbox_context_);
+ return sandbox_context_->DeleteOriginDataOnFileThread(
file_system_context, proxy, origin_url, type);
}
void SandboxFileSystemBackend::GetOriginsForTypeOnFileThread(
fileapi::FileSystemType type, std::set<GURL>* origins) {
DCHECK(CanHandleType(type));
- DCHECK(delegate_);
- delegate_->GetOriginsForTypeOnFileThread(type, origins);
+ DCHECK(sandbox_context_);
+ sandbox_context_->GetOriginsForTypeOnFileThread(type, origins);
switch (type) {
case kFileSystemTypeTemporary:
UMA_HISTOGRAM_COUNTS(kTemporaryOriginsCountLabel, origins->size());
@@ -197,8 +197,8 @@ void SandboxFileSystemBackend::GetOriginsForHostOnFileThread(
fileapi::FileSystemType type, const std::string& host,
std::set<GURL>* origins) {
DCHECK(CanHandleType(type));
- DCHECK(delegate_);
- delegate_->GetOriginsForHostOnFileThread(type, host, origins);
+ DCHECK(sandbox_context_);
+ sandbox_context_->GetOriginsForHostOnFileThread(type, host, origins);
}
int64 SandboxFileSystemBackend::GetOriginUsageOnFileThread(
@@ -206,11 +206,27 @@ int64 SandboxFileSystemBackend::GetOriginUsageOnFileThread(
const GURL& origin_url,
fileapi::FileSystemType type) {
DCHECK(CanHandleType(type));
- DCHECK(delegate_);
- return delegate_->GetOriginUsageOnFileThread(
+ DCHECK(sandbox_context_);
+ return sandbox_context_->GetOriginUsageOnFileThread(
file_system_context, origin_url, type);
}
+void SandboxFileSystemBackend::InvalidateUsageCache(
+ const GURL& origin,
+ fileapi::FileSystemType type) {
+ DCHECK(CanHandleType(type));
+ DCHECK(sandbox_context_);
+ sandbox_context_->InvalidateUsageCache(origin, type);
+}
+
+void SandboxFileSystemBackend::StickyInvalidateUsageCache(
+ const GURL& origin,
+ fileapi::FileSystemType type) {
+ DCHECK(CanHandleType(type));
+ DCHECK(sandbox_context_);
+ sandbox_context_->StickyInvalidateUsageCache(origin, type);
+}
+
void SandboxFileSystemBackend::AddFileUpdateObserver(
FileSystemType type,
FileUpdateObserver* observer,
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h
index a1a568637a0..3e7ff60b529 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h
@@ -14,7 +14,7 @@
#include "base/memory/scoped_ptr.h"
#include "webkit/browser/fileapi/file_system_backend.h"
#include "webkit/browser/fileapi/file_system_quota_util.h"
-#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
+#include "webkit/browser/fileapi/sandbox_context.h"
#include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
#include "webkit/browser/quota/special_storage_policy.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -30,7 +30,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend
: public FileSystemBackend,
public FileSystemQuotaUtil {
public:
- explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate);
+ explicit SandboxFileSystemBackend(SandboxContext* sandbox_context);
virtual ~SandboxFileSystemBackend();
// FileSystemBackend overrides.
@@ -63,7 +63,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend
// Returns an origin enumerator of this backend.
// This method can only be called on the file thread.
- SandboxFileSystemBackendDelegate::OriginEnumerator* CreateOriginEnumerator();
+ SandboxContext::OriginEnumerator* CreateOriginEnumerator();
// FileSystemQuotaUtil overrides.
virtual base::PlatformFileError DeleteOriginDataOnFileThread(
@@ -82,6 +82,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend
FileSystemContext* context,
const GURL& origin_url,
FileSystemType type) OVERRIDE;
+ virtual void InvalidateUsageCache(
+ const GURL& origin_url,
+ FileSystemType type) OVERRIDE;
+ virtual void StickyInvalidateUsageCache(
+ const GURL& origin_url,
+ FileSystemType type) OVERRIDE;
virtual void AddFileUpdateObserver(
FileSystemType type,
FileUpdateObserver* observer,
@@ -106,7 +112,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend
}
private:
- SandboxFileSystemBackendDelegate* delegate_; // Not owned.
+ SandboxContext* sandbox_context_; // Not owned.
bool enable_temporary_file_system_in_incognito_;
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc
index c7f03170e42..ec213a36386 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc
@@ -17,7 +17,7 @@
#include "webkit/browser/fileapi/file_system_backend.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/mock_file_system_options.h"
-#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
+#include "webkit/browser/fileapi/sandbox_context.h"
#include "webkit/common/fileapi/file_system_util.h"
// PS stands for path separator.
@@ -85,11 +85,11 @@ class SandboxFileSystemBackendTest : public testing::Test {
protected:
virtual void SetUp() {
ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- SetUpNewDelegate(CreateAllowFileAccessOptions());
+ SetUpNewSandboxContext(CreateAllowFileAccessOptions());
}
- void SetUpNewDelegate(const FileSystemOptions& options) {
- delegate_.reset(new SandboxFileSystemBackendDelegate(
+ void SetUpNewSandboxContext(const FileSystemOptions& options) {
+ context_.reset(new SandboxContext(
NULL /* quota_manager_proxy */,
base::MessageLoopProxy::current().get(),
data_dir_.path(),
@@ -98,18 +98,17 @@ class SandboxFileSystemBackendTest : public testing::Test {
}
void SetUpNewBackend(const FileSystemOptions& options) {
- SetUpNewDelegate(options);
- backend_.reset(new SandboxFileSystemBackend(delegate_.get()));
+ SetUpNewSandboxContext(options);
+ backend_.reset(new SandboxFileSystemBackend(context_.get()));
}
- SandboxFileSystemBackendDelegate::OriginEnumerator*
- CreateOriginEnumerator() const {
+ SandboxContext::OriginEnumerator* CreateOriginEnumerator() const {
return backend_->CreateOriginEnumerator();
}
void CreateOriginTypeDirectory(const GURL& origin,
fileapi::FileSystemType type) {
- base::FilePath target = delegate_->
+ base::FilePath target = context_->
GetBaseDirectoryForOriginAndType(origin, type, true);
ASSERT_TRUE(!target.empty());
ASSERT_TRUE(base::DirectoryExists(target));
@@ -127,7 +126,7 @@ class SandboxFileSystemBackendTest : public testing::Test {
if (error != base::PLATFORM_FILE_OK)
return false;
base::FilePath returned_root_path =
- delegate_->GetBaseDirectoryForOriginAndType(
+ context_->GetBaseDirectoryForOriginAndType(
origin_url, type, false /* create */);
if (root_path)
*root_path = returned_root_path;
@@ -135,19 +134,18 @@ class SandboxFileSystemBackendTest : public testing::Test {
}
base::FilePath file_system_path() const {
- return data_dir_.path().Append(
- SandboxFileSystemBackendDelegate::kFileSystemDirectory);
+ return data_dir_.path().Append(SandboxContext::kFileSystemDirectory);
}
base::ScopedTempDir data_dir_;
base::MessageLoop message_loop_;
- scoped_ptr<SandboxFileSystemBackendDelegate> delegate_;
+ scoped_ptr<SandboxContext> context_;
scoped_ptr<SandboxFileSystemBackend> backend_;
};
TEST_F(SandboxFileSystemBackendTest, Empty) {
SetUpNewBackend(CreateAllowFileAccessOptions());
- scoped_ptr<SandboxFileSystemBackendDelegate::OriginEnumerator> enumerator(
+ scoped_ptr<SandboxContext::OriginEnumerator> enumerator(
CreateOriginEnumerator());
ASSERT_TRUE(enumerator->Next().is_empty());
}
@@ -180,7 +178,7 @@ TEST_F(SandboxFileSystemBackendTest, EnumerateOrigins) {
persistent_set.insert(GURL(persistent_origins[i]));
}
- scoped_ptr<SandboxFileSystemBackendDelegate::OriginEnumerator> enumerator(
+ scoped_ptr<SandboxContext::OriginEnumerator> enumerator(
CreateOriginEnumerator());
size_t temporary_actual_size = 0;
size_t persistent_actual_size = 0;
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc
index 97d7a5f2e4a..179bf9b2c1a 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc
@@ -61,7 +61,7 @@ void SandboxFileSystemTestHelper::TearDown() {
}
base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() {
- return file_system_context_->sandbox_delegate()->
+ return file_system_context_->sandbox_context()->
GetBaseDirectoryForOriginAndType(origin_, type_, false);
}
@@ -80,8 +80,8 @@ base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII(
}
base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const {
- return file_system_context_->sandbox_delegate()->
- GetUsageCachePathForOriginAndType(origin_, type_);
+ return file_system_context_->
+ sandbox_context()->GetUsageCachePathForOriginAndType(origin_, type_);
}
FileSystemURL SandboxFileSystemTestHelper::CreateURL(
@@ -129,7 +129,7 @@ void SandboxFileSystemTestHelper::AddFileChangeObserver(
}
FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() {
- return file_system_context()->sandbox_delegate()->usage_cache();
+ return file_system_context()->sandbox_context()->usage_cache();
}
void SandboxFileSystemTestHelper::SetUpFileSystem() {
@@ -140,7 +140,7 @@ void SandboxFileSystemTestHelper::SetUpFileSystem() {
DCHECK(file_util_);
// Prepare the origin's root directory.
- file_system_context_->sandbox_delegate()->
+ file_system_context_->sandbox_context()->
GetBaseDirectoryForOriginAndType(origin_, type_, true /* create */);
// Initialize the usage cache file.
diff --git a/chromium/webkit/browser/fileapi/sandbox_origin_database.cc b/chromium/webkit/browser/fileapi/sandbox_origin_database.cc
index 4ce83017cc0..9ca399673fd 100644
--- a/chromium/webkit/browser/fileapi/sandbox_origin_database.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_origin_database.cc
@@ -76,7 +76,7 @@ bool SandboxOriginDatabase::Init(InitOption init_option,
std::string path = FilePathToString(db_path);
leveldb::Options options;
- options.max_open_files = 0; // Use minimum.
+ options.max_open_files = 64; // Use minimum.
options.create_if_missing = true;
leveldb::DB* db;
leveldb::Status status = leveldb::DB::Open(options, path, &db);
@@ -122,7 +122,7 @@ bool SandboxOriginDatabase::Init(InitOption init_option,
bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) {
DCHECK(!db_.get());
leveldb::Options options;
- options.max_open_files = 0; // Use minimum.
+ options.max_open_files = 64; // Use minimum.
if (!leveldb::RepairDB(db_path, options).ok() ||
!Init(FAIL_IF_NONEXISTENT, FAIL_ON_CORRUPTION)) {
LOG(WARNING) << "Failed to repair SandboxOriginDatabase.";
diff --git a/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc b/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc
index fe5ee3796fb..02a47ee255c 100644
--- a/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc
@@ -7,7 +7,7 @@
#include "base/sequenced_task_runner.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/file_system_usage_cache.h"
-#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
+#include "webkit/browser/fileapi/sandbox_context.h"
#include "webkit/browser/fileapi/timed_task_helper.h"
#include "webkit/browser/quota/quota_client.h"
#include "webkit/browser/quota/quota_manager.h"
@@ -107,7 +107,7 @@ base::FilePath SandboxQuotaObserver::GetUsageCachePath(
DCHECK(sandbox_file_util_);
base::PlatformFileError error = base::PLATFORM_FILE_OK;
base::FilePath path =
- SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
+ SandboxContext::GetUsageCachePathForOriginAndType(
sandbox_file_util_, url.origin(), url.type(), &error);
if (error != base::PLATFORM_FILE_OK) {
LOG(WARNING) << "Could not get usage cache path for: "
diff --git a/chromium/webkit/browser/fileapi/test_file_system_backend.cc b/chromium/webkit/browser/fileapi/test_file_system_backend.cc
index 1cff5c2fb14..584e2e3a10d 100644
--- a/chromium/webkit/browser/fileapi/test_file_system_backend.cc
+++ b/chromium/webkit/browser/fileapi/test_file_system_backend.cc
@@ -66,6 +66,17 @@ class TestFileSystemBackend::QuotaUtil
return usage_;
}
+ virtual void InvalidateUsageCache(const GURL& origin_url,
+ FileSystemType type) OVERRIDE {
+ // Do nothing.
+ }
+
+ virtual void StickyInvalidateUsageCache(
+ const GURL& origin,
+ FileSystemType type) OVERRIDE {
+ // Do nothing.
+ }
+
virtual void AddFileUpdateObserver(
FileSystemType type,
FileUpdateObserver* observer,