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

Unified Diff: content/browser/service_worker/service_worker_service_impl.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_service_impl.cc
diff --git a/content/browser/service_worker/service_worker_service_impl.cc b/content/browser/service_worker/service_worker_service_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5b7a58f7e9d0215c6e94c3d5e0ee5ed63748a84b
--- /dev/null
+++ b/content/browser/service_worker/service_worker_service_impl.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/service_worker/service_worker_service_impl.h"
+
+#include "content/browser/service_worker/service_worker_context_core.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+ServiceWorkerServiceImpl::ServiceWorkerServiceImpl(
+ base::WeakPtr<ServiceWorkerContextCore> context,
+ blink::mojom::ServiceWorkerServiceRequest request)
+ : context_(context), binding_(this, std::move(request)) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ binding_.set_connection_error_handler(
+ base::Bind(&ServiceWorkerServiceImpl::OnConnectionError,
+ base::Unretained(this) /* the channel is owned by this */));
+}
+
+ServiceWorkerServiceImpl::~ServiceWorkerServiceImpl() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
+void ServiceWorkerServiceImpl::ReplaceContext(
+ base::WeakPtr<ServiceWorkerContextCore> context) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ context_ = context;
+}
+
+void ServiceWorkerServiceImpl::WorkerStarted(int32_t embedded_worker_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LOG(ERROR) << "ServiceWorkerServiceImpl::WorkerStarted "
+ << embedded_worker_id;
+}
+
+void ServiceWorkerServiceImpl::OnConnectionError() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_)
+ return;
+ context_->ServiceHadConnectionError(this);
+ // |this| is now deleted.
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698