summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 01:12:12 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 01:12:12 +0000
commitb7b82eb3dce4220e592472d0f9220280d1246243 (patch)
tree2fa55d5d932949d4a313ca3b7d8ed39fc9c81d11 /webkit
parenta097393e6e0f08f521c977677bed01a0ad01120b (diff)
downloadchromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.zip
chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.tar.gz
chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.tar.bz2
Remove BrowserFileSystemContext class and merge it into SandboxedFileSystemContext
BUG=60243 TEST=none Review URL: http://codereview.chromium.org/5633008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/fileapi/sandboxed_file_system_context.cc21
-rw-r--r--webkit/fileapi/sandboxed_file_system_context.h16
-rw-r--r--webkit/fileapi/sandboxed_file_system_operation.cc2
-rw-r--r--webkit/fileapi/sandboxed_file_system_operation.h15
-rw-r--r--webkit/tools/test_shell/simple_file_system.cc6
-rw-r--r--webkit/tools/test_shell/simple_file_system.h2
6 files changed, 47 insertions, 15 deletions
diff --git a/webkit/fileapi/sandboxed_file_system_context.cc b/webkit/fileapi/sandboxed_file_system_context.cc
index b3b009e..16232d5 100644
--- a/webkit/fileapi/sandboxed_file_system_context.cc
+++ b/webkit/fileapi/sandboxed_file_system_context.cc
@@ -13,11 +13,13 @@ namespace fileapi {
SandboxedFileSystemContext::SandboxedFileSystemContext(
scoped_refptr<base::MessageLoopProxy> file_message_loop,
+ scoped_refptr<base::MessageLoopProxy> io_message_loop,
const FilePath& profile_path,
bool is_incognito,
bool allow_file_access,
bool unlimited_quota)
: file_message_loop_(file_message_loop),
+ io_message_loop_(io_message_loop),
path_manager_(new FileSystemPathManager(
file_message_loop, profile_path, is_incognito, allow_file_access)),
quota_manager_(new FileSystemQuotaManager(
@@ -28,6 +30,7 @@ SandboxedFileSystemContext::~SandboxedFileSystemContext() {
}
void SandboxedFileSystemContext::Shutdown() {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
path_manager_.reset();
quota_manager_.reset();
}
@@ -45,4 +48,22 @@ void SandboxedFileSystemContext::DeleteDataForOriginOnFileThread(
file_util::Delete(path_for_origin, true /* recursive */);
}
+void SandboxedFileSystemContext::SetOriginQuotaUnlimited(const GURL& url) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ quota_manager()->SetOriginQuotaUnlimited(url);
+}
+
+void SandboxedFileSystemContext::ResetOriginQuotaUnlimited(const GURL& url) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ quota_manager()->ResetOriginQuotaUnlimited(url);
+}
+
+void SandboxedFileSystemContext::DeleteOnCorrectThread() const {
+ if (!io_message_loop_->BelongsToCurrentThread()) {
+ io_message_loop_->DeleteSoon(FROM_HERE, this);
+ return;
+ }
+ delete this;
+}
+
} // namespace fileapi
diff --git a/webkit/fileapi/sandboxed_file_system_context.h b/webkit/fileapi/sandboxed_file_system_context.h
index 6c72bc0..fcb90bb 100644
--- a/webkit/fileapi/sandboxed_file_system_context.h
+++ b/webkit/fileapi/sandboxed_file_system_context.h
@@ -24,10 +24,13 @@ class SandboxedFileSystemContext;
struct DefaultContextDeleter;
// This class keeps and provides a sandboxed file system context.
-class SandboxedFileSystemContext {
+class SandboxedFileSystemContext
+ : public base::RefCountedThreadSafe<SandboxedFileSystemContext,
+ DefaultContextDeleter> {
public:
SandboxedFileSystemContext(
scoped_refptr<base::MessageLoopProxy> file_message_loop,
+ scoped_refptr<base::MessageLoopProxy> io_message_loop,
const FilePath& profile_path,
bool is_incognito,
bool allow_file_access_from_files,
@@ -38,6 +41,10 @@ class SandboxedFileSystemContext {
void DeleteDataForOriginOnFileThread(const GURL& origin_url);
+ // Quota related methods.
+ void SetOriginQuotaUnlimited(const GURL& url);
+ void ResetOriginQuotaUnlimited(const GURL& url);
+
FileSystemPathManager* path_manager() { return path_manager_.get(); }
FileSystemQuotaManager* quota_manager() { return quota_manager_.get(); }
@@ -47,12 +54,19 @@ class SandboxedFileSystemContext {
bool allow_file_access_from_files_;
scoped_refptr<base::MessageLoopProxy> file_message_loop_;
+ scoped_refptr<base::MessageLoopProxy> io_message_loop_;
scoped_ptr<FileSystemPathManager> path_manager_;
scoped_ptr<FileSystemQuotaManager> quota_manager_;
DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxedFileSystemContext);
};
+struct DefaultContextDeleter {
+ static void Destruct(const SandboxedFileSystemContext* context) {
+ context->DeleteOnCorrectThread();
+ }
+};
+
} // namespace fileapi
#endif // WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_CONTEXT_H_
diff --git a/webkit/fileapi/sandboxed_file_system_operation.cc b/webkit/fileapi/sandboxed_file_system_operation.cc
index ef7c752..d866512 100644
--- a/webkit/fileapi/sandboxed_file_system_operation.cc
+++ b/webkit/fileapi/sandboxed_file_system_operation.cc
@@ -15,7 +15,7 @@ namespace fileapi {
SandboxedFileSystemOperation::SandboxedFileSystemOperation(
FileSystemCallbackDispatcher* dispatcher,
scoped_refptr<base::MessageLoopProxy> proxy,
- SandboxedFileSystemContext* file_system_context)
+ scoped_refptr<SandboxedFileSystemContext> file_system_context)
: FileSystemOperation(dispatcher, proxy),
file_system_context_(file_system_context),
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
diff --git a/webkit/fileapi/sandboxed_file_system_operation.h b/webkit/fileapi/sandboxed_file_system_operation.h
index c6c905d..d3e1ce9 100644
--- a/webkit/fileapi/sandboxed_file_system_operation.h
+++ b/webkit/fileapi/sandboxed_file_system_operation.h
@@ -21,14 +21,10 @@ class SandboxedFileSystemContext;
// via |file_system_context|.
class SandboxedFileSystemOperation : public FileSystemOperation {
public:
- // This class doesn't hold a reference or ownership of |file_system_context|.
- // It is the caller's responsibility to keep the pointer alive *until*
- // it calls any of the operation methods. The |file_system_context| won't be
- // used in the callback path and can be deleted after the operation is
- // made (e.g. after one of CreateFile, CreateDirectory, Copy, etc is called).
- SandboxedFileSystemOperation(FileSystemCallbackDispatcher* dispatcher,
- scoped_refptr<base::MessageLoopProxy> proxy,
- SandboxedFileSystemContext* file_system_context);
+ SandboxedFileSystemOperation(
+ FileSystemCallbackDispatcher* dispatcher,
+ scoped_refptr<base::MessageLoopProxy> proxy,
+ scoped_refptr<SandboxedFileSystemContext> file_system_context);
virtual ~SandboxedFileSystemOperation();
void OpenFileSystem(const GURL& origin_url,
@@ -94,8 +90,7 @@ class SandboxedFileSystemOperation : public FileSystemOperation {
bool create,
int64 growth);
- // Not owned. See the comment at the constructor.
- SandboxedFileSystemContext* file_system_context_;
+ scoped_refptr<SandboxedFileSystemContext> file_system_context_;
base::ScopedCallbackFactory<SandboxedFileSystemOperation> callback_factory_;
diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc
index 94269b9..ee8c72c 100644
--- a/webkit/tools/test_shell/simple_file_system.cc
+++ b/webkit/tools/test_shell/simple_file_system.cc
@@ -5,6 +5,7 @@
#include "webkit/tools/test_shell/simple_file_system.h"
#include "base/file_path.h"
+#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/scoped_callback_factory.h"
#include "base/time.h"
@@ -117,12 +118,13 @@ class SimpleFileSystemCallbackDispatcher
SimpleFileSystem::SimpleFileSystem() {
if (file_system_dir_.CreateUniqueTempDir()) {
- sandboxed_context_.reset(new SandboxedFileSystemContext(
+ sandboxed_context_ = new SandboxedFileSystemContext(
+ base::MessageLoopProxy::CreateForCurrentThread(),
base::MessageLoopProxy::CreateForCurrentThread(),
file_system_dir_.path(),
false /* incognito */,
true /* allow_file_access */,
- false /* unlimited_quota */));
+ false /* unlimited_quota */);
} else {
LOG(WARNING) << "Failed to create a temp dir for the filesystem."
"FileSystem feature will be disabled.";
diff --git a/webkit/tools/test_shell/simple_file_system.h b/webkit/tools/test_shell/simple_file_system.h
index 9a6758c..b875a76 100644
--- a/webkit/tools/test_shell/simple_file_system.h
+++ b/webkit/tools/test_shell/simple_file_system.h
@@ -72,7 +72,7 @@ class SimpleFileSystem
// A temporary directory for FileSystem API.
ScopedTempDir file_system_dir_;
- scoped_ptr<fileapi::SandboxedFileSystemContext> sandboxed_context_;
+ scoped_refptr<fileapi::SandboxedFileSystemContext> sandboxed_context_;
DISALLOW_COPY_AND_ASSIGN(SimpleFileSystem);
};