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

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

Issue 2467223002: ServiceWorker: Add a check if error handler runs on the right thread (Closed)
Patch Set: Call EWInstance::Detach as an error handler from outside of EWInstance Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/embedded_worker_instance.cc
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc
index dcf7580597bc687029169a2ba30cc41139c05a63..6fb30fdeff79f0695c595379d08da704e500893d 100644
--- a/content/browser/service_worker/embedded_worker_instance.cc
+++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -121,6 +121,17 @@ void SetupMojoOnUIThread(
mojo::MakeProxy(std::move(exposed_interfaces)));
}
+void CallDetach(EmbeddedWorkerInstance* instance) {
nhiroki 2016/11/02 08:42:39 Just to confirm: A raw pointer is safe here becaus
shimazu 2016/11/04 01:09:21 Done.
+ // This could be called on the UI thread if |client_| still be valid when the
+ // message loop on the UI thread gets destructed.
+ // TODO(shimazu): Remove this after https://crbug.com/604762 is fixed
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ DCHECK(ServiceWorkerUtils::IsMojoForServiceWorkerEnabled());
+ return;
+ }
+ instance->Detach();
+}
+
} // namespace
// Lives on IO thread, proxies notifications to DevToolsManager that lives on
@@ -477,7 +488,7 @@ void EmbeddedWorkerInstance::Start(
if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) {
request = mojo::GetProxy(&client_);
client_.set_connection_error_handler(
- base::Bind(&EmbeddedWorkerInstance::Detach, base::Unretained(this)));
+ base::Bind(&CallDetach, base::Unretained(this)));
}
inflight_start_task_.reset(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698