Skip to content

Commit

Permalink
Remove BlobURLRequestJob
Browse files Browse the repository at this point in the history
Bug: 934009, 985682
Change-Id: Id1767bd1df5833ab3bff966edca8f0c2158c3348
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1732701
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685094}
  • Loading branch information
kinu authored and Commit Bot committed Aug 8, 2019
1 parent fc64668 commit abbb92a
Show file tree
Hide file tree
Showing 26 changed files with 231 additions and 917 deletions.
14 changes: 7 additions & 7 deletions chrome/browser/extensions/app_data_migrator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/manifest.h"
#include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_operation_runner.h"
#include "storage/browser/fileapi/file_system_url.h"
#include "storage/browser/test/mock_blob_url_request_context.h"
#include "storage/browser/test/mock_blob_util.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {
Expand Down Expand Up @@ -56,8 +57,7 @@ class AppDataMigratorTest : public testing::Test {

default_fs_context_ = default_partition_->GetFileSystemContext();

url_request_context_ = std::unique_ptr<content::MockBlobURLRequestContext>(
new content::MockBlobURLRequestContext());
blob_storage_context_ = std::make_unique<storage::BlobStorageContext>();
}

void TearDown() override {}
Expand All @@ -70,7 +70,7 @@ class AppDataMigratorTest : public testing::Test {
ExtensionRegistry* registry_;
storage::FileSystemContext* default_fs_context_;
content::IndexedDBContext* idb_context_;
std::unique_ptr<content::MockBlobURLRequestContext> url_request_context_;
std::unique_ptr<storage::BlobStorageContext> blob_storage_context_;
};

scoped_refptr<const Extension> GetTestExtension(bool platform_app) {
Expand Down Expand Up @@ -141,7 +141,7 @@ void OpenFileSystems(storage::FileSystemContext* fs_context,
content::RunAllTasksUntilIdle();
}

void GenerateTestFiles(content::MockBlobURLRequestContext* url_request_context,
void GenerateTestFiles(storage::BlobStorageContext* blob_storage_context,
const Extension* ext,
storage::FileSystemContext* fs_context,
Profile* profile) {
Expand All @@ -160,7 +160,7 @@ void GenerateTestFiles(content::MockBlobURLRequestContext* url_request_context,
fs_context->CreateCrackedFileSystemURL(
extension_url, storage::kFileSystemTypePersistent, path);

content::ScopedTextBlob blob1(*url_request_context, "blob-id:success1",
storage::ScopedTextBlob blob1(blob_storage_context, "blob-id:success1",
"Hello, world!\n");

fs_context->operation_runner()->CreateFile(fs_temp_url, false,
Expand Down Expand Up @@ -259,7 +259,7 @@ TEST_F(AppDataMigratorTest, DISABLED_FileSystemMigration) {
scoped_refptr<const Extension> old_ext = GetTestExtension(false);
scoped_refptr<const Extension> new_ext = GetTestExtension(true);

GenerateTestFiles(url_request_context_.get(), old_ext.get(),
GenerateTestFiles(blob_storage_context_.get(), old_ext.get(),
default_fs_context_, profile_.get());

migrator_->DoMigrationAndReply(old_ext.get(), new_ext.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
#include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
#include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/blob/shareable_file_reference.h"
#include "storage/browser/fileapi/external_mount_points.h"
#include "storage/browser/fileapi/file_system_backend.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_operation_context.h"
#include "storage/browser/fileapi/file_system_operation_runner.h"
#include "storage/browser/quota/quota_manager.h"
#include "storage/browser/test/mock_blob_url_request_context.h"
#include "storage/browser/test/mock_blob_util.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "storage/browser/test/test_file_system_options.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -43,8 +44,7 @@ using storage::FileSystemOperationRunner;
using storage::FileSystemURL;
using storage::FileSystemURLSet;
using storage::QuotaManager;
using content::MockBlobURLRequestContext;
using content::ScopedTextBlob;
using storage::ScopedTextBlob;

namespace sync_file_system {

Expand Down Expand Up @@ -153,21 +153,15 @@ void OnReadDirectory(CannedSyncableFileSystem::FileEntryList* entries_out,
class WriteHelper {
public:
WriteHelper() : bytes_written_(0) {}
WriteHelper(MockBlobURLRequestContext* request_context,
WriteHelper(std::unique_ptr<storage::BlobStorageContext> blob_storage_context,
const std::string& blob_data)
: bytes_written_(0),
request_context_(request_context),
blob_data_(new ScopedTextBlob(*request_context,
blob_storage_context_(std::move(blob_storage_context)),
blob_data_(new ScopedTextBlob(blob_storage_context_.get(),
base::GenerateGUID(),
blob_data)) {
}
blob_data)) {}

~WriteHelper() {
if (request_context_) {
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
FROM_HERE, request_context_.release());
}
}
~WriteHelper() {}

ScopedTextBlob* scoped_text_blob() const { return blob_data_.get(); }

Expand All @@ -187,7 +181,7 @@ class WriteHelper {

private:
int64_t bytes_written_;
std::unique_ptr<MockBlobURLRequestContext> request_context_;
std::unique_ptr<storage::BlobStorageContext> blob_storage_context_;
std::unique_ptr<ScopedTextBlob> blob_data_;

DISALLOW_COPY_AND_ASSIGN(WriteHelper);
Expand Down Expand Up @@ -652,9 +646,8 @@ void CannedSyncableFileSystem::DoWriteString(
const WriteCallback& callback) {
EXPECT_TRUE(io_task_runner_->RunsTasksInCurrentSequence());
EXPECT_TRUE(is_filesystem_opened_);
MockBlobURLRequestContext* url_request_context(
new MockBlobURLRequestContext());
WriteHelper* helper = new WriteHelper(url_request_context, data);
auto blob_storage_context = std::make_unique<storage::BlobStorageContext>();
WriteHelper* helper = new WriteHelper(std::move(blob_storage_context), data);
operation_runner()->Write(url,
helper->scoped_text_blob()->GetBlobDataHandle(), 0,
base::BindRepeating(&WriteHelper::DidWrite,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
#include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/quota/quota_manager.h"
#include "storage/browser/test/mock_blob_url_request_context.h"
#include "storage/browser/test/mock_blob_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/leveldb_chrome.h"

using content::MockBlobURLRequestContext;
using content::ScopedTextBlob;
using storage::BlobStorageContext;
using storage::FileSystemContext;
using storage::FileSystemURL;
using storage::FileSystemURLSet;
using storage::ScopedTextBlob;

namespace sync_file_system {

Expand Down Expand Up @@ -280,8 +281,8 @@ TEST_F(LocalFileChangeTrackerTest, RestoreCreateAndModifyChanges) {
ASSERT_EQ(0U, urls.size());

const std::string kData("Lorem ipsum.");
MockBlobURLRequestContext url_request_context;
ScopedTextBlob blob(url_request_context, "blob_id:test", kData);
BlobStorageContext blob_storage_context;
ScopedTextBlob blob(&blob_storage_context, "blob_id:test", kData);

// Create files and nested directories.
EXPECT_EQ(base::File::FILE_OK,
Expand Down Expand Up @@ -430,8 +431,8 @@ TEST_F(LocalFileChangeTrackerTest, RestoreCopyChanges) {
ASSERT_EQ(0U, urls.size());

const std::string kData("Lorem ipsum.");
MockBlobURLRequestContext url_request_context;
ScopedTextBlob blob(url_request_context, "blob_id:test", kData);
BlobStorageContext blob_storage_context;
ScopedTextBlob blob(&blob_storage_context, "blob_id:test", kData);

// Create files and nested directories.
EXPECT_EQ(base::File::FILE_OK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_operation_runner.h"
#include "storage/browser/fileapi/isolated_context.h"
#include "storage/browser/test/mock_blob_url_request_context.h"
#include "storage/browser/test/mock_blob_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/leveldb_chrome.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
#include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_operation_runner.h"
#include "storage/browser/test/mock_blob_url_request_context.h"
#include "storage/browser/test/mock_blob_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/leveldb_chrome.h"

using base::File;
using storage::FileSystemOperation;
using storage::FileSystemURL;
using content::MockBlobURLRequestContext;
using content::ScopedTextBlob;
using base::File;
using storage::ScopedTextBlob;

namespace sync_file_system {

Expand Down Expand Up @@ -156,7 +156,7 @@ class SyncableFileOperationRunnerTest : public testing::Test {
size_t write_bytes_;
bool write_complete_;

MockBlobURLRequestContext url_request_context_;
storage::BlobStorageContext blob_storage_context_;

private:
base::WeakPtrFactory<SyncableFileOperationRunnerTest> weak_factory_{this};
Expand Down Expand Up @@ -310,7 +310,7 @@ TEST_F(SyncableFileOperationRunnerTest, CopyAndMove) {
TEST_F(SyncableFileOperationRunnerTest, Write) {
EXPECT_EQ(File::FILE_OK, file_system_.CreateFile(URL(kFile)));
const std::string kData("Lorem ipsum.");
ScopedTextBlob blob(url_request_context_, "blob:foo", kData);
ScopedTextBlob blob(&blob_storage_context_, "blob:foo", kData);

sync_status()->StartSyncing(URL(kFile));

Expand Down

0 comments on commit abbb92a

Please sign in to comment.