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

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

Issue 2118243002: [proof-of-concept] SW thread independent of the main thread Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
Index: content/browser/service_worker/service_worker_context_core.cc
diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc
index d787d5c1d9e71227ef5df1d4b66fd1540badb902..1d90c465d99b5f3b828274f1cc1ef5c1a6229491 100644
--- a/content/browser/service_worker/service_worker_context_core.cc
+++ b/content/browser/service_worker/service_worker_context_core.cc
@@ -30,6 +30,7 @@
#include "content/browser/service_worker/service_worker_provider_host.h"
#include "content/browser/service_worker/service_worker_register_job.h"
#include "content/browser/service_worker/service_worker_registration.h"
+#include "content/browser/service_worker/service_worker_service_impl.h"
#include "content/browser/service_worker/service_worker_storage.h"
#include "content/common/service_worker/service_worker_utils.h"
#include "content/public/browser/browser_thread.h"
@@ -227,6 +228,7 @@ ServiceWorkerContextCore::ServiceWorkerContextCore(
next_registration_handle_id_(0),
was_service_worker_registered_(false),
observer_list_(observer_list),
+ services_(new ScopedVector<ServiceWorkerServiceImpl>),
weak_factory_(this) {
// These get a WeakPtr from weak_factory_, so must be set after weak_factory_
// is initialized.
@@ -248,6 +250,7 @@ ServiceWorkerContextCore::ServiceWorkerContextCore(
was_service_worker_registered_(
old_context->was_service_worker_registered_),
observer_list_(old_context->observer_list_),
+ services_(old_context->services_.release()),
weak_factory_(this) {
// These get a WeakPtr from weak_factory_, so must be set after weak_factory_
// is initialized.
@@ -256,6 +259,11 @@ ServiceWorkerContextCore::ServiceWorkerContextCore(
AsWeakPtr(),
old_context->embedded_worker_registry());
job_coordinator_.reset(new ServiceWorkerJobCoordinator(AsWeakPtr()));
+ for (ScopedVector<ServiceWorkerServiceImpl>::iterator iter(
+ services_->begin());
+ iter != services_->end(); ++iter) {
+ (*iter)->ReplaceContext(AsWeakPtr());
+ }
}
ServiceWorkerContextCore::~ServiceWorkerContextCore() {
@@ -730,6 +738,23 @@ int ServiceWorkerContextCore::GetVersionFailureCount(int64_t version_id) {
return it->second.count;
}
+void ServiceWorkerContextCore::CreateService(
+ mojo::InterfaceRequest<blink::mojom::ServiceWorkerService> request) {
+ LOG(ERROR) << "ServiceWorkerContextCore::CreateService ";
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ services_->push_back(
+ new ServiceWorkerServiceImpl(AsWeakPtr(), std::move(request)));
+}
+
+void ServiceWorkerContextCore::ServiceHadConnectionError(
+ ServiceWorkerServiceImpl* service) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LOG(ERROR) << "ServiceWorkerContextCore::ServiceHadConnectionError";
+ auto it = std::find(services_->begin(), services_->end(), service);
+ DCHECK(it != services_->end());
+ services_->erase(it);
+}
+
void ServiceWorkerContextCore::OnRunningStateChanged(
ServiceWorkerVersion* version) {
if (!observer_list_)

Powered by Google App Engine
This is Rietveld 408576698