Commit fdc40e3e authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Change SandboxFileSystemBackendDelegate functions to use url::Origin.

This CL update the functions InvalidateUsageCache and
StickyInvalidateUsageCache of SandboxFileSystemBackendDelegate to use
dedicated Origin type instead of GURL.
Change SandboxQuotaObserver::SetUsageCacheEnabled also, because
it only called in StickyInvalidateUsageCache.

Bug: 598424
Change-Id: Ibd7edbef3b40dd48a14f63bb18d9cb1c357a86a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006902
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732983}
parent 61ccab75
......@@ -300,8 +300,7 @@ base::File ObfuscatedFileUtil::CreateOrOpen(FileSystemOperationContext* context,
if (file.IsValid() && file_flags & base::File::FLAG_WRITE &&
context->quota_limit_type() == storage::kQuotaLimitTypeUnlimited &&
sandbox_delegate_) {
sandbox_delegate_->StickyInvalidateUsageCache(url.origin().GetURL(),
url.type());
sandbox_delegate_->StickyInvalidateUsageCache(url.origin(), url.type());
}
return file;
}
......@@ -1301,7 +1300,7 @@ void ObfuscatedFileUtil::InvalidateUsageCache(
const url::Origin& origin,
FileSystemType type) {
if (sandbox_delegate_)
sandbox_delegate_->InvalidateUsageCache(origin.GetURL(), type);
sandbox_delegate_->InvalidateUsageCache(origin, type);
}
void ObfuscatedFileUtil::MarkUsed() {
......
......@@ -522,20 +522,20 @@ void SandboxFileSystemBackendDelegate::RegisterQuotaUpdateObserver(
}
void SandboxFileSystemBackendDelegate::InvalidateUsageCache(
const GURL& origin,
const url::Origin& origin,
FileSystemType type) {
base::File::Error error = base::File::FILE_OK;
base::FilePath usage_file_path = GetUsageCachePathForOriginAndType(
obfuscated_file_util(), url::Origin::Create(origin), type, &error);
obfuscated_file_util(), origin, type, &error);
if (error != base::File::FILE_OK)
return;
usage_cache()->IncrementDirty(usage_file_path);
}
void SandboxFileSystemBackendDelegate::StickyInvalidateUsageCache(
const GURL& origin,
const url::Origin& origin,
FileSystemType type) {
sticky_dirty_origins_.insert(std::make_pair(origin, type));
sticky_dirty_origins_.insert(std::make_pair(origin.GetURL(), type));
quota_observer()->SetUsageCacheEnabled(origin, type, false);
InvalidateUsageCache(origin, type);
}
......
......@@ -173,8 +173,9 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate
// Registers quota observer for file updates on filesystem of |type|.
void RegisterQuotaUpdateObserver(FileSystemType type);
void InvalidateUsageCache(const GURL& origin_url, FileSystemType type);
void StickyInvalidateUsageCache(const GURL& origin_url, FileSystemType type);
void InvalidateUsageCache(const url::Origin& origin, FileSystemType type);
void StickyInvalidateUsageCache(const url::Origin& origin,
FileSystemType type);
void CollectOpenFileSystemMetrics(base::File::Error error_code);
......
......@@ -82,12 +82,12 @@ void SandboxQuotaObserver::OnAccess(const FileSystemURL& url) {
}
}
void SandboxQuotaObserver::SetUsageCacheEnabled(const GURL& origin,
void SandboxQuotaObserver::SetUsageCacheEnabled(const url::Origin& origin,
FileSystemType type,
bool enabled) {
if (quota_manager_proxy_.get()) {
quota_manager_proxy_->SetUsageCacheEnabled(
storage::QuotaClient::kFileSystem, url::Origin::Create(origin),
storage::QuotaClient::kFileSystem, origin,
FileSystemTypeToQuotaStorageType(type), enabled);
}
}
......
......@@ -22,8 +22,8 @@ namespace base {
class SequencedTaskRunner;
}
namespace storage {
class QuotaManagerProxy;
namespace url {
class Origin;
}
namespace storage {
......@@ -31,6 +31,7 @@ namespace storage {
class FileSystemUsageCache;
class FileSystemURL;
class ObfuscatedFileUtil;
class QuotaManagerProxy;
class SandboxQuotaObserver : public FileUpdateObserver,
public FileAccessObserver {
......@@ -49,7 +50,7 @@ class SandboxQuotaObserver : public FileUpdateObserver,
// FileAccessObserver overrides.
void OnAccess(const FileSystemURL& url) override;
void SetUsageCacheEnabled(const GURL& origin,
void SetUsageCacheEnabled(const url::Origin& origin,
FileSystemType type,
bool enabled);
......
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