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

Unified Diff: components/browser_context_keyed_service/browser_context_keyed_service_factory.cc

Issue 159763004: Eliminate potential for flaky crash in BCKSFactory::SetTestingFactory(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 6 years, 10 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 | « components/browser_context_keyed_service/browser_context_keyed_base_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
diff --git a/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc b/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
index 8f2bc729f06b474421eb06b26e3e7322e8ff4e3d..c9d6646e03c279f6caa15fe0082324c6a4ca4cfb 100644
--- a/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
+++ b/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
@@ -20,6 +20,14 @@ void BrowserContextKeyedServiceFactory::SetTestingFactory(
// destruction.
bool add_context = ArePreferencesSetOn(context);
+#ifndef NDEBUG
+ // Ensure that |context| is not marked as stale (e.g., due to it aliasing an
+ // instance that was destroyed in an earlier test) in order to avoid accesses
+ // to |context| in |BrowserContextShutdown| from causing
+ // |AssertBrowserContextWasntDestroyed| to raise an error.
+ dependency_manager_->MarkBrowserContextLiveForTesting(context);
+#endif
+
// We have to go through the shutdown and destroy mechanisms because there
// are unit tests that create a service on a context and then change the
// testing service mid-test.
« no previous file with comments | « components/browser_context_keyed_service/browser_context_keyed_base_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698