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