Commit cbae8d9e authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

[NativeFS] Change hash calculation code to go through FS backends.

This makes sure this code works for non-native file systems.

Bug: 1103076
Change-Id: I1579fd33cd40b6527504a89987ba8dbc9b3c8931
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304958
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791250}
parent fbbf6668
......@@ -85,14 +85,16 @@ class CONTENT_EXPORT NativeFileSystemFileWriterImpl
// perform cleanup even if the writer was deleted before they were invoked.
static void DoAfterWriteCheck(
base::WeakPtr<NativeFileSystemFileWriterImpl> file_writer,
const base::FilePath& swap_path,
scoped_refptr<NativeFileSystemManagerImpl> manager,
const storage::FileSystemURL& swap_url,
NativeFileSystemFileWriterImpl::CloseCallback callback,
base::File::Error hash_result,
const std::string& hash,
int64_t size);
static void DidAfterWriteCheck(
base::WeakPtr<NativeFileSystemFileWriterImpl> file_writer,
const base::FilePath& swap_path,
scoped_refptr<NativeFileSystemManagerImpl> manager,
const storage::FileSystemURL& swap_url,
NativeFileSystemFileWriterImpl::CloseCallback callback,
NativeFileSystemPermissionContext::AfterWriteCheckResult result);
void DidPassAfterWriteCheck(CloseCallback callback);
......@@ -106,8 +108,7 @@ class CONTENT_EXPORT NativeFileSystemFileWriterImpl
// except temporary file systems.
// TOOD(crbug.com/1103076): Extend this check to non-native paths.
bool RequireSecurityChecks() const {
return url().type() == storage::kFileSystemTypeNativeLocal ||
url().type() == storage::kFileSystemTypeNativeForPlatformApp;
return url().type() != storage::kFileSystemTypeTemporary;
}
void ComputeHashForSwapFile(HashCallback callback);
......
......@@ -290,8 +290,7 @@ TEST_F(NativeFileSystemManagerImplTest,
storage::AsyncFileTestHelper::kDontCheckSize));
}
TEST_F(NativeFileSystemManagerImplTest,
FileWriterCloseAllowedToCompleteOnDestruct) {
TEST_F(NativeFileSystemManagerImplTest, FileWriterCloseAbortsOnDestruct) {
auto test_file_url = file_system_context_->CreateCrackedFileSystemURL(
kTestOrigin, storage::kFileSystemTypeTest,
base::FilePath::FromUTF8Unsafe("test"));
......@@ -319,11 +318,14 @@ TEST_F(NativeFileSystemManagerImplTest,
writer_remote.reset();
base::RunLoop().RunUntilIdle();
// Since the writer was destroyed before close completed, the swap file should
// have been destroyed and the target file should have been left untouched.
ASSERT_FALSE(storage::AsyncFileTestHelper::FileExists(
file_system_context_.get(), test_swap_url,
storage::AsyncFileTestHelper::kDontCheckSize));
ASSERT_TRUE(storage::AsyncFileTestHelper::FileExists(
file_system_context_.get(), test_file_url, 3));
ASSERT_FALSE(storage::AsyncFileTestHelper::FileExists(
file_system_context_.get(), test_file_url,
storage::AsyncFileTestHelper::kDontCheckSize));
}
TEST_F(NativeFileSystemManagerImplTest, SerializeHandle_SandboxedFile) {
......
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