Commit babfdaf7 authored by Adrienne Walker's avatar Adrienne Walker Committed by Commit Bot

storage: clean up cache storage initialization

Instead of going ui -> io thread -> cache storage task runner,
instead have the ui just post two tasks.
This should cut down on any potential races on startup.

This is a followup to comments left on:
https://chromium-review.googlesource.com/c/chromium/src/+/1907095/4#message-d81d6b0b2d2ab774ba9aeff7674e1c4b842fe342

Bug: 1022104
Change-Id: Icdfd30c36969795ba3625179137360258171b170
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931580
Commit-Queue: enne <enne@chromium.org>
Reviewed-by: default avatarBen Kelly <wanderview@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718823}
parent b32bf850
......@@ -128,15 +128,25 @@ void CacheStorageContextImpl::SetBlobParametersForCache(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!blob_storage_context)
return;
// We can only get a mojo interface for BlobStorageContext on the IO thread.
// Bounce there first before setting the context on the manager.
// TODO(enne): this remote will need to be sent to the storage service when
// cache storage is moved.
mojo::PendingRemote<storage::mojom::BlobStorageContext> remote;
auto receiver = remote.InitWithNewPipeAndPassReceiver();
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&CacheStorageContextImpl::SetBlobParametersForCacheOnTaskRunner, this,
std::move(remote)));
// We can only bind a mojo interface for BlobStorageContext on the IO thread.
// TODO(enne): clean this up in the future to not require this bounce and
// to have this mojo context live on the cache storage sequence.
base::PostTask(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&CacheStorageContextImpl::GetBlobStorageMojoContextOnIOThread, this,
base::RetainedRef(blob_storage_context)));
&CacheStorageContextImpl::BindBlobStorageMojoContextOnIOThread, this,
base::RetainedRef(blob_storage_context), std::move(receiver)));
}
void CacheStorageContextImpl::GetAllOriginsInfo(
......@@ -250,22 +260,14 @@ void CacheStorageContextImpl::ShutdownOnTaskRunner() {
cache_manager_ = nullptr;
}
void CacheStorageContextImpl::GetBlobStorageMojoContextOnIOThread(
ChromeBlobStorageContext* blob_storage_context) {
void CacheStorageContextImpl::BindBlobStorageMojoContextOnIOThread(
ChromeBlobStorageContext* blob_storage_context,
mojo::PendingReceiver<storage::mojom::BlobStorageContext> receiver) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(blob_storage_context);
DCHECK(receiver.is_valid());
mojo::PendingRemote<storage::mojom::BlobStorageContext> remote;
blob_storage_context->BindMojoContext(
remote.InitWithNewPipeAndPassReceiver());
// TODO(enne): this remote will need to be sent to the storage service when
// cache storage is moved.
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&CacheStorageContextImpl::SetBlobParametersForCacheOnTaskRunner, this,
std::move(remote)));
blob_storage_context->BindMojoContext(std::move(receiver));
}
void CacheStorageContextImpl::SetBlobParametersForCacheOnTaskRunner(
......
......@@ -121,8 +121,9 @@ class CONTENT_EXPORT CacheStorageContextImpl
void ShutdownOnTaskRunner();
void GetBlobStorageMojoContextOnIOThread(
ChromeBlobStorageContext* blob_storage_context);
void BindBlobStorageMojoContextOnIOThread(
ChromeBlobStorageContext* blob_storage_context,
mojo::PendingReceiver<storage::mojom::BlobStorageContext> receiver);
void SetBlobParametersForCacheOnTaskRunner(
mojo::PendingRemote<storage::mojom::BlobStorageContext> remote);
......
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