Commit 22894525 authored by kinuko@chromium.org's avatar kinuko@chromium.org

Always pass FileSystemContext to ObfuscatedFileUtil operations

Now it may always refer operation_context->file_system_context() as it tries to invalidate the usage cache whenever it finds inconsistency.

BUG=129303
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10407115

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138444 0039d316-1c4b-4281-b951-d872f2087c98
parent d3ec669b
......@@ -116,11 +116,13 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
origin_enumerator(BrowserContext::GetFileSystemContext(profile_)->
sandbox_provider()->CreateOriginEnumerator());
scoped_refptr<fileapi::FileSystemContext> context =
BrowserContext::GetFileSystemContext(profile_);
// We don't own this pointer; it's a magic singleton generated by the
// profile's FileSystemContext. Deleting it would be a bad idea.
fileapi::FileSystemQuotaUtil* quota_util =
BrowserContext::GetFileSystemContext(profile_)->GetQuotaUtil(
fileapi::kFileSystemTypeTemporary);
context->GetQuotaUtil(fileapi::kFileSystemTypeTemporary);
GURL current;
......@@ -130,9 +132,11 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
// We can call these synchronous methods as we've already verified that
// we're running on the FILE thread.
int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current,
int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(
context, current,
fileapi::kFileSystemTypePersistent);
int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(current,
int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(
context, current,
fileapi::kFileSystemTypeTemporary);
file_system_info_.push_back(
FileSystemInfo(
......
......@@ -78,9 +78,9 @@ bool FileSystemContext::DeleteDataForOriginOnFileThread(
// Delete temporary and persistent data.
return
sandbox_provider()->DeleteOriginDataOnFileThread(
quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) &&
this, quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) &&
sandbox_provider()->DeleteOriginDataOnFileThread(
quota_manager_proxy(), origin_url, kFileSystemTypePersistent);
this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent);
}
bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread(
......@@ -90,7 +90,7 @@ bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread(
type == fileapi::kFileSystemTypePersistent) {
DCHECK(sandbox_provider());
return sandbox_provider()->DeleteOriginDataOnFileThread(
quota_manager_proxy(), origin_url, type);
this, quota_manager_proxy(), origin_url, type);
}
return false;
}
......
......@@ -47,7 +47,8 @@ class FileSystemQuotaClient::GetOriginUsageTask : public QuotaThreadTask {
virtual void RunOnTargetThread() OVERRIDE {
FileSystemQuotaUtil* quota_util = file_system_context_->GetQuotaUtil(type_);
if (quota_util)
fs_usage_ = quota_util->GetOriginUsageOnFileThread(origin_url_, type_);
fs_usage_ = quota_util->GetOriginUsageOnFileThread(
file_system_context_, origin_url_, type_);
}
virtual void Completed() OVERRIDE {
......
......@@ -23,6 +23,8 @@ class QuotaManagerProxy;
namespace fileapi {
class FileSystemContext;
// An abstract interface that provides common quota-related utility functions
// for internal filesystem modules. The main consumer of this class is
// file_system_quota_client and quota_file_util.
......@@ -67,8 +69,10 @@ class FileSystemQuotaUtil {
// Called by quota client.
// Returns the amount of data used for the origin for usage tracking.
virtual int64 GetOriginUsageOnFileThread(const GURL& origin_url,
fileapi::FileSystemType type) = 0;
virtual int64 GetOriginUsageOnFileThread(
fileapi::FileSystemContext* file_system_context,
const GURL& origin_url,
fileapi::FileSystemType type) = 0;
// Called by quota file util.
virtual void UpdateOriginUsageOnFileThread(quota::QuotaManagerProxy* proxy,
......
......@@ -159,7 +159,7 @@ base::PlatformFileError FileSystemTestOriginHelper::SameFileUtilMove(
int64 FileSystemTestOriginHelper::GetCachedOriginUsage() const {
return file_system_context_->GetQuotaUtil(type_)->GetOriginUsageOnFileThread(
origin_, type_);
file_system_context_, origin_, type_);
}
int64 FileSystemTestOriginHelper::ComputeCurrentOriginUsage() const {
......
......@@ -498,11 +498,14 @@ FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType(
}
bool SandboxMountPointProvider::DeleteOriginDataOnFileThread(
QuotaManagerProxy* proxy, const GURL& origin_url,
FileSystemContext* file_system_context,
QuotaManagerProxy* proxy,
const GURL& origin_url,
fileapi::FileSystemType type) {
MigrateIfNeeded(sandbox_file_util_, old_base_path());
int64 usage = GetOriginUsageOnFileThread(origin_url, type);
int64 usage = GetOriginUsageOnFileThread(file_system_context,
origin_url, type);
bool result =
sandbox_file_util_->DeleteDirectoryForOriginAndType(origin_url, type);
......@@ -552,7 +555,9 @@ void SandboxMountPointProvider::GetOriginsForHostOnFileThread(
}
int64 SandboxMountPointProvider::GetOriginUsageOnFileThread(
const GURL& origin_url, fileapi::FileSystemType type) {
FileSystemContext* file_system_context,
const GURL& origin_url,
fileapi::FileSystemType type) {
DCHECK(type == kFileSystemTypeTemporary ||
type == kFileSystemTypePersistent);
FilePath base_path =
......@@ -574,7 +579,7 @@ int64 SandboxMountPointProvider::GetOriginUsageOnFileThread(
// Get the directory size now and update the cache.
FileSystemUsageCache::Delete(usage_file_path);
FileSystemOperationContext context(NULL);
FileSystemOperationContext context(file_system_context);
FileSystemPath path(origin_url, type, FilePath());
scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator(
sandbox_file_util_->CreateFileEnumerator(&context, path, true));
......
......@@ -128,6 +128,7 @@ class SandboxMountPointProvider
// Deletes the data on the origin and reports the amount of deleted data
// to the quota manager via |proxy|.
bool DeleteOriginDataOnFileThread(
FileSystemContext* context,
quota::QuotaManagerProxy* proxy,
const GURL& origin_url,
FileSystemType type);
......@@ -141,6 +142,7 @@ class SandboxMountPointProvider
const std::string& host,
std::set<GURL>* origins) OVERRIDE;
virtual int64 GetOriginUsageOnFileThread(
FileSystemContext* context,
const GURL& origin_url,
FileSystemType type) OVERRIDE;
virtual void NotifyOriginWasAccessedOnIOThread(
......
......@@ -294,7 +294,7 @@ class SandboxMountPointProviderMigrationTest : public testing::Test {
break;
case 3:
sandbox_provider()->DeleteOriginDataOnFileThread(
NULL, origin_url, type);
file_system_context_, NULL, origin_url, type);
break;
case 4:
sandbox_provider()->GetOriginsForTypeOnFileThread(
......@@ -305,7 +305,8 @@ class SandboxMountPointProviderMigrationTest : public testing::Test {
type, host, &origins);
break;
case 6:
sandbox_provider()->GetOriginUsageOnFileThread(origin_url, type);
sandbox_provider()->GetOriginUsageOnFileThread(
file_system_context_, origin_url, type);
break;
case 7:
// This case has to use an origin that already exists in the
......
......@@ -41,6 +41,7 @@ class TestFileSystemQuotaUtil : public FileSystemQuotaUtil {
NOTREACHED();
}
virtual int64 GetOriginUsageOnFileThread(
FileSystemContext* context,
const GURL& origin_url,
FileSystemType type) OVERRIDE {
return usage_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment