Commit 9280a290 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Remove RemovePluginPrivateDataWhileWriting unittest.

In the past, base::File object was passed to the CDM process and it
read/write using the handle. Now that all the reading/writing is done
in the browser process, it's no longer a concern that the handle can
exist after the underlying file was deleted.
The test is removed while removing usages of CreateOrOpen() function
that is on deprecation path.

Bug: 936722
Change-Id: Ic2ab6ffece24118e3f7384b440b77cecd12ddc5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768590
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692383}
parent 5b4905b0
......@@ -409,26 +409,6 @@ class RemovePluginPrivateDataTester {
return data_exists_for_origin;
}
// Opens the file created for ClearKey (in kOrigin1) for writing. Caller
// needs to verify if the file was opened or not.
base::File OpenClearKeyFileForWrite() {
AwaitCompletionHelper await_completion;
base::File file;
storage::AsyncFileUtil* async_file_util =
filesystem_context_->GetAsyncFileUtil(
storage::kFileSystemTypePluginPrivate);
std::unique_ptr<storage::FileSystemOperationContext> operation_context =
std::make_unique<storage::FileSystemOperationContext>(
filesystem_context_);
async_file_util->CreateOrOpen(
std::move(operation_context), clearkey_file_,
base::File::FLAG_OPEN | base::File::FLAG_WRITE,
base::BindOnce(&RemovePluginPrivateDataTester::OnFileOpened,
base::Unretained(this), &file, &await_completion));
await_completion.BlockUntilNotified();
return file;
}
private:
// Creates a PluginPrivateFileSystem for the |plugin_name| and |origin|
// provided. Returns the file system ID for the created
......@@ -533,14 +513,6 @@ class RemovePluginPrivateDataTester {
await_completion->Notify();
}
void OnFileOpened(base::File* file_result,
AwaitCompletionHelper* await_completion,
base::File file,
base::OnceClosure on_close_callback) {
*file_result = std::move(file);
await_completion->Notify();
}
// If |origin| exists in the PluginPrivateFileSystem, set
// |data_exists_for_origin| to true, false otherwise.
void CheckIfDataExistsForOriginOnFileTaskRunner(
......@@ -1544,38 +1516,6 @@ TEST_F(StoragePartitionImplTest, RemovePluginPrivateDataForOrigin) {
EXPECT_TRUE(tester.DataExistsForOrigin(kOrigin2));
}
TEST_F(StoragePartitionImplTest, RemovePluginPrivateDataWhileWriting) {
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition(browser_context()));
RemovePluginPrivateDataTester tester(partition->GetFileSystemContext());
tester.AddPluginPrivateTestData();
EXPECT_TRUE(tester.DataExistsForOrigin(kOrigin1));
EXPECT_TRUE(tester.DataExistsForOrigin(kOrigin2));
const char test_data[] = {0, 1, 2, 3, 4, 5};
base::File file = tester.OpenClearKeyFileForWrite();
EXPECT_TRUE(file.IsValid());
EXPECT_EQ(static_cast<int>(base::size(test_data)),
file.Write(0, test_data, base::size(test_data)));
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&ClearPluginPrivateData, partition, GURL(),
base::Time(), base::Time::Max(), &run_loop));
run_loop.Run();
EXPECT_FALSE(tester.DataExistsForOrigin(kOrigin1));
EXPECT_FALSE(tester.DataExistsForOrigin(kOrigin2));
const char more_data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
EXPECT_EQ(static_cast<int>(base::size(more_data)),
file.WriteAtCurrentPos(more_data, base::size(more_data)));
base::File file2 = tester.OpenClearKeyFileForWrite();
EXPECT_FALSE(file2.IsValid());
}
TEST_F(StoragePartitionImplTest, RemovePluginPrivateDataAfterDeletion) {
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition(browser_context()));
......
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