summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_context.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-09 06:29:59 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-09 06:29:59 +0000
commitc62983a7fcbd13cb5aade8da6d4f27c44dd5c069 (patch)
tree7532ffa1f81bbf1eed6dbf5c9009c4c4ecd89f4e /webkit/fileapi/file_system_context.cc
parentd36f941bbea3e9fa6d13829626a1911008b37f17 (diff)
downloadchromium_src-c62983a7fcbd13cb5aade8da6d4f27c44dd5c069.zip
chromium_src-c62983a7fcbd13cb5aade8da6d4f27c44dd5c069.tar.gz
chromium_src-c62983a7fcbd13cb5aade8da6d4f27c44dd5c069.tar.bz2
Implement SandboxQuotaClient for Quota support in sandboxed filesystem
- Refactored FileSystemUsageTracker as a SandboxQuotaClient - Added a few more tests BUG=61676 TEST=SandboxQuotaClientTest.* Review URL: http://codereview.chromium.org/6883002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_context.cc')
-rw-r--r--webkit/fileapi/file_system_context.cc37
1 files changed, 27 insertions, 10 deletions
diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc
index 7e0d62e..d27b87d 100644
--- a/webkit/fileapi/file_system_context.cc
+++ b/webkit/fileapi/file_system_context.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -8,15 +8,32 @@
#include "base/message_loop_proxy.h"
#include "googleurl/src/gurl.h"
#include "webkit/fileapi/file_system_path_manager.h"
-#include "webkit/fileapi/file_system_usage_tracker.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
+#include "webkit/fileapi/sandbox_quota_client.h"
+#include "webkit/quota/quota_manager.h"
+
+using quota::QuotaClient;
namespace fileapi {
+namespace {
+QuotaClient* CreateQuotaClient(
+ scoped_refptr<base::MessageLoopProxy> file_message_loop,
+ FileSystemContext* context,
+ bool is_incognito) {
+ // TODO(kinuko): For now we assume only sandbox filesystem uses
+ // the quota feature. If we want to support multiple filesystem types
+ // that require different quota we'll need to add more QuotaClientID
+ // and more factory-like code around QuotaClient.
+ return new SandboxQuotaClient(file_message_loop, context, is_incognito);
+}
+} // anonymous namespace
+
FileSystemContext::FileSystemContext(
scoped_refptr<base::MessageLoopProxy> file_message_loop,
scoped_refptr<base::MessageLoopProxy> io_message_loop,
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
+ quota::QuotaManagerProxy* quota_manager_proxy,
const FilePath& profile_path,
bool is_incognito,
bool allow_file_access,
@@ -25,16 +42,19 @@ FileSystemContext::FileSystemContext(
: file_message_loop_(file_message_loop),
io_message_loop_(io_message_loop),
special_storage_policy_(special_storage_policy),
+ quota_manager_proxy_(quota_manager_proxy),
allow_file_access_from_files_(allow_file_access),
unlimited_quota_(unlimited_quota),
- path_manager_(path_manager),
- usage_tracker_(new FileSystemUsageTracker(
- file_message_loop, profile_path, is_incognito)) {
+ path_manager_(path_manager) {
if (!path_manager) {
path_manager_.reset(new FileSystemPathManager(
file_message_loop, profile_path, special_storage_policy,
is_incognito, allow_file_access));
}
+ if (quota_manager_proxy) {
+ quota_manager_proxy->RegisterClient(CreateQuotaClient(
+ file_message_loop, this, is_incognito));
+ }
}
FileSystemContext::~FileSystemContext() {
@@ -55,11 +75,8 @@ void FileSystemContext::DeleteDataForOriginOnFileThread(
DCHECK(path_manager_.get());
DCHECK(file_message_loop_->BelongsToCurrentThread());
- std::string origin_identifier =
- SandboxMountPointProvider::GetOriginIdentifierFromURL(origin_url);
- FilePath path_for_origin = sandbox_provider()->base_path().AppendASCII(
- origin_identifier);
-
+ FilePath path_for_origin =
+ sandbox_provider()->GetBaseDirectoryForOrigin(origin_url);
file_util::Delete(path_for_origin, true /* recursive */);
}