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

Change GetBaseDirectoryForOriginAndType to use url::Origin

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

Bug: 598424
Change-Id: I0385e929b7cc8b6a12aae23a4d667240e7957f1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038913
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738810}
parent 298ea59d
...@@ -241,12 +241,12 @@ SandboxFileSystemBackendDelegate::CreateOriginEnumerator() { ...@@ -241,12 +241,12 @@ SandboxFileSystemBackendDelegate::CreateOriginEnumerator() {
base::FilePath base::FilePath
SandboxFileSystemBackendDelegate::GetBaseDirectoryForOriginAndType( SandboxFileSystemBackendDelegate::GetBaseDirectoryForOriginAndType(
const GURL& origin_url, const url::Origin& origin,
FileSystemType type, FileSystemType type,
bool create) { bool create) {
base::File::Error error = base::File::FILE_OK; base::File::Error error = base::File::FILE_OK;
base::FilePath path = obfuscated_file_util()->GetDirectoryForOriginAndType( base::FilePath path = obfuscated_file_util()->GetDirectoryForOriginAndType(
url::Origin::Create(origin_url), GetTypeString(type), create, &error); origin, GetTypeString(type), create, &error);
if (error != base::File::FILE_OK) if (error != base::File::FILE_OK)
return base::FilePath(); return base::FilePath();
return path; return path;
...@@ -420,7 +420,7 @@ int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner( ...@@ -420,7 +420,7 @@ int64_t SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner(
return RecalculateUsage(file_system_context, origin.GetURL(), type); return RecalculateUsage(file_system_context, origin.GetURL(), type);
base::FilePath base_path = base::FilePath base_path =
GetBaseDirectoryForOriginAndType(origin.GetURL(), type, false); GetBaseDirectoryForOriginAndType(origin, 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;
...@@ -684,21 +684,21 @@ void SandboxFileSystemBackendDelegate::CopyFileSystem( ...@@ -684,21 +684,21 @@ void SandboxFileSystemBackendDelegate::CopyFileSystem(
SandboxFileSystemBackendDelegate* destination) { SandboxFileSystemBackendDelegate* destination) {
DCHECK(file_task_runner()->RunsTasksInCurrentSequence()); DCHECK(file_task_runner()->RunsTasksInCurrentSequence());
base::FilePath base_path = base::FilePath base_path = GetBaseDirectoryForOriginAndType(
GetBaseDirectoryForOriginAndType(origin_url, type, false /* create */); url::Origin::Create(origin_url), type, false /* create */);
if (base::PathExists(base_path)) { if (base::PathExists(base_path)) {
// Delete any existing file system directories in the destination. A // Delete any existing file system directories in the destination. A
// previously failed migration // previously failed migration
// may have left behind partially copied directories. // may have left behind partially copied directories.
base::FilePath dest_path = destination->GetBaseDirectoryForOriginAndType( base::FilePath dest_path = destination->GetBaseDirectoryForOriginAndType(
origin_url, type, false /* create */); url::Origin::Create(origin_url), type, false /* create */);
// Make sure we're not about to delete our own file system. // Make sure we're not about to delete our own file system.
CHECK_NE(base_path.value(), dest_path.value()); CHECK_NE(base_path.value(), dest_path.value());
base::DeleteFileRecursively(dest_path); base::DeleteFileRecursively(dest_path);
dest_path = destination->GetBaseDirectoryForOriginAndType( dest_path = destination->GetBaseDirectoryForOriginAndType(
origin_url, type, true /* create */); url::Origin::Create(origin_url), type, true /* create */);
obfuscated_file_util()->CloseFileSystemForOriginAndType( obfuscated_file_util()->CloseFileSystemForOriginAndType(
url::Origin::Create(origin_url), GetTypeString(type)); url::Origin::Create(origin_url), GetTypeString(type));
......
...@@ -104,7 +104,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate ...@@ -104,7 +104,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate
// the 'unique' part.) // the 'unique' part.)
// Returns an empty path if the given type is invalid. // Returns an empty path if the given type is invalid.
// This method can only be called on the file thread. // This method can only be called on the file thread.
base::FilePath GetBaseDirectoryForOriginAndType(const GURL& origin_url, base::FilePath GetBaseDirectoryForOriginAndType(const url::Origin& origin,
FileSystemType type, FileSystemType type,
bool create); bool create);
......
...@@ -112,8 +112,8 @@ class SandboxFileSystemBackendTest ...@@ -112,8 +112,8 @@ class SandboxFileSystemBackendTest
void CreateOriginTypeDirectory(const GURL& origin, void CreateOriginTypeDirectory(const GURL& origin,
storage::FileSystemType type) { storage::FileSystemType type) {
base::FilePath target = base::FilePath target = delegate_->GetBaseDirectoryForOriginAndType(
delegate_->GetBaseDirectoryForOriginAndType(origin, type, true); url::Origin::Create(origin), type, true);
ASSERT_TRUE(!target.empty()); ASSERT_TRUE(!target.empty());
ASSERT_TRUE(base::DirectoryExists(target)); ASSERT_TRUE(base::DirectoryExists(target));
} }
...@@ -131,8 +131,8 @@ class SandboxFileSystemBackendTest ...@@ -131,8 +131,8 @@ class SandboxFileSystemBackendTest
if (error != base::File::FILE_OK) if (error != base::File::FILE_OK)
return false; return false;
base::FilePath returned_root_path = base::FilePath returned_root_path =
delegate_->GetBaseDirectoryForOriginAndType(origin_url, type, delegate_->GetBaseDirectoryForOriginAndType(
false /* create */); url::Origin::Create(origin_url), type, false /* create */);
if (root_path) if (root_path)
*root_path = returned_root_path; *root_path = returned_root_path;
return !returned_root_path.empty(); return !returned_root_path.empty();
......
...@@ -68,7 +68,7 @@ void SandboxFileSystemTestHelper::TearDown() { ...@@ -68,7 +68,7 @@ void SandboxFileSystemTestHelper::TearDown() {
base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() { base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() {
return file_system_context_->sandbox_delegate() return file_system_context_->sandbox_delegate()
->GetBaseDirectoryForOriginAndType(origin_.GetURL(), type_, false); ->GetBaseDirectoryForOriginAndType(origin_, type_, false);
} }
base::FilePath SandboxFileSystemTestHelper::GetLocalPath( base::FilePath SandboxFileSystemTestHelper::GetLocalPath(
...@@ -163,7 +163,7 @@ void SandboxFileSystemTestHelper::SetUpFileSystem() { ...@@ -163,7 +163,7 @@ void SandboxFileSystemTestHelper::SetUpFileSystem() {
// Prepare the origin's root directory. // Prepare the origin's root directory.
file_system_context_->sandbox_delegate()->GetBaseDirectoryForOriginAndType( file_system_context_->sandbox_delegate()->GetBaseDirectoryForOriginAndType(
origin_.GetURL(), type_, true /* create */); origin_, type_, true /* create */);
base::FilePath usage_cache_path = GetUsageCachePath(); base::FilePath usage_cache_path = GetUsageCachePath();
if (!usage_cache_path.empty()) if (!usage_cache_path.empty())
......
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