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

Unified Diff: content/child/background_sync/background_sync_provider_thread_proxy.cc

Issue 1302543002: Support calling BackgroundSyncProviderThreadProxy::GetThreadInstance after the worker has stopped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« 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/child/background_sync/background_sync_provider_thread_proxy.cc
diff --git a/content/child/background_sync/background_sync_provider_thread_proxy.cc b/content/child/background_sync/background_sync_provider_thread_proxy.cc
index 90584bfc8380a6d31a2280ddd33303e83e52439a..97466b23bf18dc84ee0787d8d4c817ea9fda156a 100644
--- a/content/child/background_sync/background_sync_provider_thread_proxy.cc
+++ b/content/child/background_sync/background_sync_provider_thread_proxy.cc
@@ -62,6 +62,7 @@ LazyInstance<ThreadLocalPointer<BackgroundSyncProviderThreadProxy>>::Leaky
} // anonymous namespace
+// static
BackgroundSyncProviderThreadProxy*
BackgroundSyncProviderThreadProxy::GetThreadInstance(
base::SingleThreadTaskRunner* main_thread_task_runner,
@@ -69,10 +70,15 @@ BackgroundSyncProviderThreadProxy::GetThreadInstance(
if (g_sync_provider_tls.Pointer()->Get())
return g_sync_provider_tls.Pointer()->Get();
+ if (!WorkerTaskRunner::Instance()->CurrentWorkerId()) {
+ // This could happen if GetThreadInstance is called very late (say by a
+ // garbage collected SyncRegistration).
+ return nullptr;
+ }
+
BackgroundSyncProviderThreadProxy* instance =
new BackgroundSyncProviderThreadProxy(main_thread_task_runner,
sync_provider);
- DCHECK(WorkerTaskRunner::Instance()->CurrentWorkerId());
WorkerTaskRunner::Instance()->AddStopObserver(instance);
return instance;
}
« 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