Commit 60ea1ff5 authored by Md. Hasanur Rashid's avatar Md. Hasanur Rashid Committed by Commit Bot

Change GetOriginUsageOnFileTaskRunner to use url::Origin

This CL update the function GetOriginUsageOnFileTaskRunner to use
url::Origin instead of GURL.

Bug: 598424
Change-Id: Id88ee97f35f68dbc557c86e07f4431fb95271676
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032556Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Commit-Queue: Md. Hasanur Rashid <hasanur.r@samsung.com>
Cr-Commit-Position: refs/heads/master@{#738414}
parent 5fc05e23
...@@ -85,7 +85,7 @@ void BrowsingDataFileSystemHelper::FetchFileSystemInfoInFileThread( ...@@ -85,7 +85,7 @@ void BrowsingDataFileSystemHelper::FetchFileSystemInfoInFileThread(
if (!BrowsingDataHelper::HasWebScheme(current)) if (!BrowsingDataHelper::HasWebScheme(current))
continue; // Non-websafe state is not considered browsing data. continue; // Non-websafe state is not considered browsing data.
int64_t usage = quota_util->GetOriginUsageOnFileTaskRunner( int64_t usage = quota_util->GetOriginUsageOnFileTaskRunner(
filesystem_context_.get(), current, type); filesystem_context_.get(), url::Origin::Create(current), type);
auto inserted = auto inserted =
file_system_info_map file_system_info_map
.insert(std::make_pair( .insert(std::make_pair(
......
...@@ -119,8 +119,7 @@ void FileSystemQuotaClient::GetOriginUsage(const url::Origin& origin, ...@@ -119,8 +119,7 @@ void FileSystemQuotaClient::GetOriginUsage(const url::Origin& origin,
// It is safe to pass Unretained(quota_util) since context owns it. // It is safe to pass Unretained(quota_util) since context owns it.
base::BindOnce(&FileSystemQuotaUtil::GetOriginUsageOnFileTaskRunner, base::BindOnce(&FileSystemQuotaUtil::GetOriginUsageOnFileTaskRunner,
base::Unretained(quota_util), base::Unretained(quota_util),
base::RetainedRef(file_system_context_), origin.GetURL(), base::RetainedRef(file_system_context_), origin, type),
type),
std::move(callback)); std::move(callback));
} }
......
...@@ -56,7 +56,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileSystemQuotaUtil { ...@@ -56,7 +56,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileSystemQuotaUtil {
// 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_t GetOriginUsageOnFileTaskRunner( virtual int64_t GetOriginUsageOnFileTaskRunner(
FileSystemContext* file_system_context, FileSystemContext* file_system_context,
const GURL& origin_url, const url::Origin& origin,
FileSystemType type) = 0; FileSystemType type) = 0;
// Creates new reservation object for the origin and the type. // Creates new reservation object for the origin and the type.
......
...@@ -103,7 +103,8 @@ class FileWriterDelegateTest : public PlatformTest { ...@@ -103,7 +103,8 @@ class FileWriterDelegateTest : public PlatformTest {
int64_t usage() { int64_t usage() {
return file_system_context_->GetQuotaUtil(kFileSystemType) return file_system_context_->GetQuotaUtil(kFileSystemType)
->GetOriginUsageOnFileTaskRunner(file_system_context_.get(), ->GetOriginUsageOnFileTaskRunner(file_system_context_.get(),
GURL(kOrigin), kFileSystemType); url::Origin::Create(GURL(kOrigin)),
kFileSystemType);
} }
int64_t GetFileSizeOnDisk(const char* test_file_path) { int64_t GetFileSizeOnDisk(const char* test_file_path) {
......
...@@ -280,7 +280,7 @@ void PluginPrivateFileSystemBackend::GetOriginsForHostOnFileTaskRunner( ...@@ -280,7 +280,7 @@ void PluginPrivateFileSystemBackend::GetOriginsForHostOnFileTaskRunner(
int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner( int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner(
FileSystemContext* context, FileSystemContext* context,
const GURL& origin_url, const url::Origin& origin,
FileSystemType type) { FileSystemType type) {
DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); DCHECK(file_task_runner_->RunsTasksInCurrentSequence());
...@@ -289,8 +289,8 @@ int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner( ...@@ -289,8 +289,8 @@ int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner(
int64_t total_size; int64_t total_size;
base::Time last_modified_time; base::Time last_modified_time;
GetOriginDetailsOnFileTaskRunner(context, url::Origin::Create(origin_url), GetOriginDetailsOnFileTaskRunner(context, origin, &total_size,
&total_size, &last_modified_time); &last_modified_time);
return total_size; return total_size;
} }
......
...@@ -122,7 +122,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) PluginPrivateFileSystemBackend ...@@ -122,7 +122,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) PluginPrivateFileSystemBackend
const std::string& host, const std::string& host,
std::set<GURL>* origins) override; std::set<GURL>* origins) override;
int64_t GetOriginUsageOnFileTaskRunner(FileSystemContext* context, int64_t GetOriginUsageOnFileTaskRunner(FileSystemContext* context,
const GURL& origin_url, const url::Origin& origin,
FileSystemType type) override; FileSystemType type) override;
scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner( scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner(
const url::Origin& origin, const url::Origin& origin,
......
...@@ -335,8 +335,8 @@ SandboxFileSystemBackendDelegate::CreateFileStreamWriter( ...@@ -335,8 +335,8 @@ SandboxFileSystemBackendDelegate::CreateFileStreamWriter(
return nullptr; return nullptr;
const UpdateObserverList* observers = GetUpdateObservers(type); const UpdateObserverList* observers = GetUpdateObservers(type);
DCHECK(observers); DCHECK(observers);
return std::make_unique<SandboxFileStreamWriter>( return std::make_unique<SandboxFileStreamWriter>(context, url, offset,
context, url, offset, *observers); *observers);
} }
base::File::Error base::File::Error
...@@ -346,8 +346,8 @@ SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileTaskRunner( ...@@ -346,8 +346,8 @@ SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileTaskRunner(
const GURL& origin_url, const GURL& origin_url,
FileSystemType type) { FileSystemType type) {
DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); DCHECK(file_task_runner_->RunsTasksInCurrentSequence());
int64_t usage = int64_t usage = GetOriginUsageOnFileTaskRunner(
GetOriginUsageOnFileTaskRunner(file_system_context, origin_url, type); file_system_context, url::Origin::Create(origin_url), type);
usage_cache()->CloseCacheFiles(); usage_cache()->CloseCacheFiles();
bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType( bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType(
url::Origin::Create(origin_url), GetTypeString(type)); url::Origin::Create(origin_url), GetTypeString(type));
...@@ -410,17 +410,18 @@ void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileTaskRunner( ...@@ -410,17 +410,18 @@ void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileTaskRunner(
int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner( int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner(
FileSystemContext* file_system_context, FileSystemContext* file_system_context,
const GURL& origin_url, const url::Origin& origin,
FileSystemType type) { FileSystemType type) {
DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); DCHECK(file_task_runner_->RunsTasksInCurrentSequence());
// Don't use usage cache and return recalculated usage for sticky invalidated // Don't use usage cache and return recalculated usage for sticky invalidated
// origins. // origins.
if (base::Contains(sticky_dirty_origins_, std::make_pair(origin_url, type))) if (base::Contains(sticky_dirty_origins_,
return RecalculateUsage(file_system_context, origin_url, type); std::make_pair(origin.GetURL(), type)))
return RecalculateUsage(file_system_context, origin.GetURL(), type);
base::FilePath base_path = base::FilePath base_path =
GetBaseDirectoryForOriginAndType(origin_url, type, false); GetBaseDirectoryForOriginAndType(origin.GetURL(), type, false);
if (base_path.empty() || if (base_path.empty() ||
!obfuscated_file_util()->delegate()->DirectoryExists(base_path)) { !obfuscated_file_util()->delegate()->DirectoryExists(base_path)) {
return 0; return 0;
...@@ -432,7 +433,7 @@ int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner( ...@@ -432,7 +433,7 @@ int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner(
uint32_t dirty_status = 0; uint32_t dirty_status = 0;
bool dirty_status_available = bool dirty_status_available =
usage_cache()->GetDirty(usage_file_path, &dirty_status); usage_cache()->GetDirty(usage_file_path, &dirty_status);
bool visited = !visited_origins_.insert(origin_url).second; bool visited = !visited_origins_.insert(origin.GetURL()).second;
if (is_valid && (dirty_status == 0 || (dirty_status_available && visited))) { if (is_valid && (dirty_status == 0 || (dirty_status_available && visited))) {
// The usage cache is clean (dirty == 0) or the origin is already // The usage cache is clean (dirty == 0) or the origin is already
// initialized and running. Read the cache file to get the usage. // initialized and running. Read the cache file to get the usage.
...@@ -443,7 +444,7 @@ int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner( ...@@ -443,7 +444,7 @@ int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner(
// Get the directory size now and update the cache. // Get the directory size now and update the cache.
usage_cache()->Delete(usage_file_path); usage_cache()->Delete(usage_file_path);
int64_t usage = RecalculateUsage(file_system_context, origin_url, type); int64_t usage = RecalculateUsage(file_system_context, origin.GetURL(), type);
// This clears the dirty flag too. // This clears the dirty flag too.
usage_cache()->UpdateUsage(usage_file_path, usage); usage_cache()->UpdateUsage(usage_file_path, usage);
......
...@@ -144,7 +144,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate ...@@ -144,7 +144,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate
const std::string& host, const std::string& host,
std::set<GURL>* origins) override; std::set<GURL>* origins) override;
int64_t GetOriginUsageOnFileTaskRunner(FileSystemContext* context, int64_t GetOriginUsageOnFileTaskRunner(FileSystemContext* context,
const GURL& origin_url, const url::Origin& origin,
FileSystemType type) override; FileSystemType type) override;
scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner( scoped_refptr<QuotaReservation> CreateQuotaReservationOnFileTaskRunner(
const url::Origin& origin, const url::Origin& origin,
......
...@@ -55,8 +55,8 @@ void SandboxFileSystemTestHelper::SetUp( ...@@ -55,8 +55,8 @@ void SandboxFileSystemTestHelper::SetUp(
void SandboxFileSystemTestHelper::SetUp( void SandboxFileSystemTestHelper::SetUp(
const base::FilePath& base_dir, const base::FilePath& base_dir,
storage::QuotaManagerProxy* quota_manager_proxy) { storage::QuotaManagerProxy* quota_manager_proxy) {
file_system_context_ = CreateFileSystemContextForTesting( file_system_context_ =
quota_manager_proxy, base_dir); CreateFileSystemContextForTesting(quota_manager_proxy, base_dir);
SetUpFileSystem(); SetUpFileSystem();
} }
...@@ -98,8 +98,8 @@ FileSystemURL SandboxFileSystemTestHelper::CreateURL( ...@@ -98,8 +98,8 @@ FileSystemURL SandboxFileSystemTestHelper::CreateURL(
int64_t SandboxFileSystemTestHelper::GetCachedOriginUsage() const { int64_t SandboxFileSystemTestHelper::GetCachedOriginUsage() const {
return file_system_context_->GetQuotaUtil(type_) return file_system_context_->GetQuotaUtil(type_)
->GetOriginUsageOnFileTaskRunner(file_system_context_.get(), ->GetOriginUsageOnFileTaskRunner(file_system_context_.get(), origin_,
origin_.GetURL(), type_); type_);
} }
int64_t SandboxFileSystemTestHelper::ComputeCurrentOriginUsage() { int64_t SandboxFileSystemTestHelper::ComputeCurrentOriginUsage() {
...@@ -122,8 +122,7 @@ FileSystemOperationRunner* SandboxFileSystemTestHelper::operation_runner() { ...@@ -122,8 +122,7 @@ FileSystemOperationRunner* SandboxFileSystemTestHelper::operation_runner() {
return file_system_context_->operation_runner(); return file_system_context_->operation_runner();
} }
FileSystemOperationContext* FileSystemOperationContext* SandboxFileSystemTestHelper::NewOperationContext() {
SandboxFileSystemTestHelper::NewOperationContext() {
DCHECK(file_system_context_.get()); DCHECK(file_system_context_.get());
FileSystemOperationContext* context = FileSystemOperationContext* context =
new FileSystemOperationContext(file_system_context_.get()); new FileSystemOperationContext(file_system_context_.get());
......
...@@ -102,7 +102,7 @@ class TestFileSystemBackend::QuotaUtil : public storage::FileSystemQuotaUtil, ...@@ -102,7 +102,7 @@ class TestFileSystemBackend::QuotaUtil : public storage::FileSystemQuotaUtil,
int64_t GetOriginUsageOnFileTaskRunner( int64_t GetOriginUsageOnFileTaskRunner(
FileSystemContext* context, FileSystemContext* context,
const GURL& origin_url, const url::Origin& origin,
storage::FileSystemType type) override { storage::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