Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1149)

Unified Diff: content/browser/service_worker/service_worker_provider_host.cc

Issue 2804843005: Implement the infrastructure of creating WorkerFetchContext in worker global scope. (Closed)
Patch Set: s/WebScheduler.h/web_scheduler.h/ Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_provider_host.h ('k') | content/child/resource_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 92fc4cf7a5331ccb60b2dcb0fb80d1951be1ab1a..3e6025d0c57ec6d57d22475b1dc8862158e81640 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 {
@@ -112,6 +115,31 @@ std::unique_ptr<ServiceWorkerProviderHost> ServiceWorkerProviderHost::Create(
info.is_parent_frame_secure, context, dispatcher_host));
}
+void ServiceWorkerProviderHost::BindWorkerFetchContext(
+ mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info) {
+ DCHECK(base::FeatureList::IsEnabled(features::kOffMainThreadFetch));
+ mojom::ServiceWorkerWorkerClientAssociatedPtr 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::ServiceWorkerWorkerClient*,
+ mojom::ServiceWorkerWorkerClientAssociatedPtr>(
+ client.get(), std::move(client)));
+ DCHECK(result.second);
+}
+
+void ServiceWorkerProviderHost::UnregisterWorkerFetchContext(
+ mojom::ServiceWorkerWorkerClient* client) {
+ DCHECK(worker_clients_.count(client));
+ worker_clients_.erase(client);
+}
+
ServiceWorkerProviderHost::ServiceWorkerProviderHost(
int render_process_id,
int route_id,
@@ -247,8 +275,12 @@ void ServiceWorkerProviderHost::SetControllerVersionAttribute(
scoped_refptr<ServiceWorkerVersion> previous_version = controlling_version_;
controlling_version_ = version;
- if (version)
+ if (version) {
version->AddControllee(this);
+ for (const auto& pair : worker_clients_) {
+ pair.second->SetControllerServiceWorker(version->version_id());
+ }
+ }
if (previous_version.get())
previous_version->RemoveControllee(this);
« no previous file with comments | « content/browser/service_worker/service_worker_provider_host.h ('k') | content/child/resource_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698