| Index: content/browser/service_worker/service_worker_provider_host.cc
|
| diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc
|
| index 40a00374088869c3373f2ca7191e02ab95b7275f..b463b9508368f81a354e2a5b094f9fdf7d07392c 100644
|
| --- a/content/browser/service_worker/service_worker_provider_host.cc
|
| +++ b/content/browser/service_worker/service_worker_provider_host.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <utility>
|
|
|
| +#include "base/feature_list.h"
|
| #include "base/guid.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/stl_util.h"
|
| @@ -26,7 +27,9 @@
|
| #include "content/public/common/browser_side_navigation_policy.h"
|
| #include "content/public/common/child_process_host.h"
|
| #include "content/public/common/content_client.h"
|
| +#include "content/public/common/content_features.h"
|
| #include "content/public/common/origin_util.h"
|
| +#include "mojo/public/cpp/bindings/strong_associated_binding.h"
|
| #include "net/base/url_util.h"
|
|
|
| namespace content {
|
| @@ -109,6 +112,31 @@ std::unique_ptr<ServiceWorkerProviderHost> ServiceWorkerProviderHost::Create(
|
| info.is_parent_frame_secure, context, dispatcher_host));
|
| }
|
|
|
| +void ServiceWorkerProviderHost::BindWorkerFetchContext(
|
| + mojom::ServiceWorkerClientAssociatedPtrInfo client_ptr_info) {
|
| + DCHECK(base::FeatureList::IsEnabled(features::kOffMainThreadFetch));
|
| + mojom::ServiceWorkerClientAssociatedPtr client;
|
| + client.Bind(std::move(client_ptr_info));
|
| + client.set_connection_error_handler(
|
| + base::Bind(&ServiceWorkerProviderHost::UnregisterWorkerFetchContext,
|
| + base::Unretained(this), client.get()));
|
| +
|
| + if (controlling_version_)
|
| + client->SetControllerServiceWorker(controlling_version_->version_id());
|
| +
|
| + auto result = worker_clients_.insert(
|
| + std::make_pair<mojom::ServiceWorkerClient*,
|
| + mojom::ServiceWorkerClientAssociatedPtr>(
|
| + client.get(), std::move(client)));
|
| + DCHECK(result.second);
|
| +}
|
| +
|
| +void ServiceWorkerProviderHost::UnregisterWorkerFetchContext(
|
| + mojom::ServiceWorkerClient* client) {
|
| + DCHECK(worker_clients_.count(client));
|
| + worker_clients_.erase(client);
|
| +}
|
| +
|
| ServiceWorkerProviderHost::ServiceWorkerProviderHost(
|
| int render_process_id,
|
| int route_id,
|
| @@ -248,6 +276,11 @@ void ServiceWorkerProviderHost::SetControllerVersionAttribute(
|
| version->AddControllee(this);
|
| if (previous_version.get())
|
| previous_version->RemoveControllee(this);
|
| + if (version) {
|
| + for (auto it = worker_clients_.begin(); it != worker_clients_.end(); it++) {
|
| + it->second->SetControllerServiceWorker(version->version_id());
|
| + }
|
| + }
|
|
|
| if (!dispatcher_host_)
|
| return; // Could be NULL in some tests.
|
|
|