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

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: 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
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..04785bb436b045a5ae37204c737981e5b1ceb509 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,12 @@ void BrowserContextKeyedServiceFactory::SetTestingFactory(
// destruction.
bool add_context = ArePreferencesSetOn(context);
+ // 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);
+
// 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.

Powered by Google App Engine
This is Rietveld 408576698