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