Commit d7122722 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

PlzWorker: Pass scoped_refptr<ChromeAppCacheService> to SharedWorkerServiceImpl

This is a preparation CL for PlzWorker for shared workers.

SharedWorkerServiceImpl needs to access ChromeAppCacheService to create a
NavigationLoaderInterceptor for AppCache. Subsequent CLs will actually use it.

DesignDoc:
https://docs.google.com/document/d/1Jtn33bvqkqWxq6K7HIA4uU6HLWPTmOD7vFviacfTmhM/edit?usp=sharing

Bug: 715632
Change-Id: Ib2e8e8d2ae9adb2bc4851fb985eb121dc4ad2917
Reviewed-on: https://chromium-review.googlesource.com/1146405Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577117}
parent e43057b3
......@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/shared_worker/mock_shared_worker.h"
#include "content/browser/shared_worker/shared_worker_connector_impl.h"
#include "content/browser/shared_worker/shared_worker_instance.h"
......@@ -34,7 +35,9 @@ class SharedWorkerHostTest : public testing::Test {
public:
SharedWorkerHostTest()
: mock_render_process_host_(&browser_context_),
service_(&storage_partition_, nullptr /* service_worker_context */) {
service_(&storage_partition_,
nullptr /* service_worker_context */,
nullptr /* appcache_service */) {
storage_partition_.set_network_context(&network_context_);
}
......
......@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/task_scheduler/post_task.h"
#include "content/browser/appcache/appcache_navigation_handle.h"
#include "content/browser/file_url_loader_factory.h"
#include "content/browser/shared_worker/shared_worker_host.h"
#include "content/browser/shared_worker/shared_worker_instance.h"
......@@ -147,12 +148,18 @@ void CreateScriptLoaderOnIO(
SharedWorkerServiceImpl::SharedWorkerServiceImpl(
StoragePartition* storage_partition,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
scoped_refptr<ChromeAppCacheService> appcache_service)
: storage_partition_(storage_partition),
service_worker_context_(std::move(service_worker_context)),
weak_factory_(this) {}
appcache_service_(std::move(appcache_service)),
weak_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
SharedWorkerServiceImpl::~SharedWorkerServiceImpl() {}
SharedWorkerServiceImpl::~SharedWorkerServiceImpl() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
bool SharedWorkerServiceImpl::TerminateWorker(
const GURL& url,
......@@ -305,6 +312,10 @@ void SharedWorkerServiceImpl::CreateWorker(
CreateFactoryBundle(process_id, storage_partition,
constructor_uses_file_url);
// TODO(nhiroki): Create an instance of AppCacheNavigationHandle from
// |appcache_service_| and pass its core() to the IO thread in order to set
// up an interceptor for AppCache.
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(
......
......@@ -27,6 +27,8 @@ class MessagePortChannel;
}
namespace content {
class ChromeAppCacheService;
class SharedWorkerInstance;
class SharedWorkerHost;
class StoragePartition;
......@@ -36,7 +38,8 @@ class CONTENT_EXPORT SharedWorkerServiceImpl : public SharedWorkerService {
public:
SharedWorkerServiceImpl(
StoragePartition* storage_partition,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
scoped_refptr<ChromeAppCacheService> appcache_service);
~SharedWorkerServiceImpl() override;
// SharedWorkerService implementation.
......@@ -95,6 +98,7 @@ class CONTENT_EXPORT SharedWorkerServiceImpl : public SharedWorkerService {
// |storage_partition_| owns |this|.
StoragePartition* const storage_partition_;
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
scoped_refptr<ChromeAppCacheService> appcache_service_;
base::WeakPtrFactory<SharedWorkerServiceImpl> weak_factory_;
......
......@@ -606,11 +606,12 @@ std::unique_ptr<StoragePartitionImpl> StoragePartitionImpl::Create(
partition->service_worker_context_ = new ServiceWorkerContextWrapper(context);
partition->service_worker_context_->set_storage_partition(partition.get());
partition->shared_worker_service_ = std::make_unique<SharedWorkerServiceImpl>(
partition.get(), partition->service_worker_context_);
partition->appcache_service_ =
new ChromeAppCacheService(quota_manager_proxy.get());
base::MakeRefCounted<ChromeAppCacheService>(quota_manager_proxy.get());
partition->shared_worker_service_ = std::make_unique<SharedWorkerServiceImpl>(
partition.get(), partition->service_worker_context_,
partition->appcache_service_);
partition->push_messaging_context_ =
new PushMessagingContext(context, partition->service_worker_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