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

Change OpenFileSystem to use url::Origin

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

Bug: 598424
Change-Id: Idd3ffb4d059c8289f0090e4e8d318c7fc58c623c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038932
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738805}
parent d47392b8
......@@ -28,6 +28,7 @@
#include "storage/browser/file_system/file_system_operation_context.h"
#include "storage/browser/file_system/file_system_operation_runner.h"
#include "storage/common/file_system/file_system_util.h"
#include "url/origin.h"
using storage::FileSystemContext;
using storage::FileSystemFileUtil;
......@@ -94,7 +95,8 @@ void LocalFileSyncContext::MaybeInitializeFileSystemContext(
FROM_HERE,
base::BindOnce(&storage::SandboxFileSystemBackendDelegate::OpenFileSystem,
base::Unretained(file_system_context->sandbox_delegate()),
source_url, storage::kFileSystemTypeSyncable,
url::Origin::Create(source_url),
storage::kFileSystemTypeSyncable,
storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
std::move(open_filesystem_callback), GURL()));
}
......
......@@ -90,7 +90,7 @@ void RootDeleteHelper::DidResetFileChangeTracker() {
// Reopening the filesystem.
file_system_context_->sandbox_delegate()->OpenFileSystem(
url_.origin().GetURL(), url_.type(),
url_.origin(), url_.type(),
storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
base::Bind(&RootDeleteHelper::DidOpenFileSystem,
weak_factory_.GetWeakPtr()),
......
......@@ -89,7 +89,7 @@ void SyncFileSystemBackend::ResolveURL(const storage::FileSystemURL& url,
if (skip_initialize_syncfs_service_for_testing_) {
GetDelegate()->OpenFileSystem(
url.origin().GetURL(), url.type(), mode, std::move(callback),
url.origin(), url.type(), mode, std::move(callback),
GetSyncableFileSystemRootURI(url.origin().GetURL()));
return;
}
......
......@@ -76,7 +76,7 @@ void SandboxFileSystemBackend::ResolveURL(const FileSystemURL& url,
}
delegate_->OpenFileSystem(
url.origin().GetURL(), url.type(), mode, std::move(callback),
url.origin(), url.type(), mode, std::move(callback),
GetFileSystemRootURI(url.origin().GetURL(), url.type()));
}
......
......@@ -253,25 +253,24 @@ SandboxFileSystemBackendDelegate::GetBaseDirectoryForOriginAndType(
}
void SandboxFileSystemBackendDelegate::OpenFileSystem(
const GURL& origin_url,
const url::Origin& origin,
FileSystemType type,
OpenFileSystemMode mode,
OpenFileSystemCallback callback,
const GURL& root_url) {
if (!IsAllowedScheme(origin_url)) {
if (!IsAllowedScheme(origin.GetURL())) {
std::move(callback).Run(GURL(), std::string(),
base::File::FILE_ERROR_SECURITY);
return;
}
std::string name = GetFileSystemName(origin_url, type);
std::string name = GetFileSystemName(origin.GetURL(), type);
// |quota_manager_proxy_| may be null in unit tests.
base::OnceClosure quota_callback =
(quota_manager_proxy_.get())
? base::BindOnce(&QuotaManagerProxy::NotifyStorageAccessed,
quota_manager_proxy_,
url::Origin::Create(origin_url),
quota_manager_proxy_, origin,
FileSystemTypeToQuotaStorageType(type))
: base::DoNothing();
......@@ -279,7 +278,7 @@ void SandboxFileSystemBackendDelegate::OpenFileSystem(
file_task_runner_->PostTaskAndReply(
FROM_HERE,
base::BindOnce(&OpenSandboxFileSystemOnFileTaskRunner,
obfuscated_file_util(), origin_url, type, mode,
obfuscated_file_util(), origin.GetURL(), type, mode,
base::Unretained(error_ptr)),
base::BindOnce(&DidOpenFileSystem, weak_factory_.GetWeakPtr(),
std::move(quota_callback),
......
......@@ -109,7 +109,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate
bool create);
// FileSystemBackend helpers.
void OpenFileSystem(const GURL& origin_url,
void OpenFileSystem(const url::Origin& origin,
FileSystemType type,
OpenFileSystemMode mode,
OpenFileSystemCallback callback,
......
......@@ -50,7 +50,7 @@ class SandboxFileSystemBackendDelegateTest : public testing::Test {
return delegate_->IsAccessValid(url);
}
void OpenFileSystem(const GURL& origin,
void OpenFileSystem(const url::Origin& origin,
storage::FileSystemType type,
storage::OpenFileSystemMode mode) {
delegate_->OpenFileSystem(
......@@ -128,7 +128,7 @@ TEST_F(SandboxFileSystemBackendDelegateTest, OpenFileSystemAccessesStorage) {
EXPECT_EQ(quota_manager_proxy()->notify_storage_accessed_count(), 0);
EXPECT_EQ(callback_count(), 0);
OpenFileSystem(origin, storage::kFileSystemTypeTemporary,
OpenFileSystem(url::Origin::Create(origin), storage::kFileSystemTypeTemporary,
storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT);
EXPECT_EQ(callback_count(), 1);
......
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