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

Unified Diff: components/keyed_service/core/refcounted_keyed_service_factory.cc

Issue 2749823002: Restore KeyedServiceFactory diagnostics for context use-after-destroy. (Closed)
Patch Set: Refactor SiteEngagementService tests. Created 3 years, 9 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/keyed_service/core/refcounted_keyed_service_factory.cc
diff --git a/components/keyed_service/core/refcounted_keyed_service_factory.cc b/components/keyed_service/core/refcounted_keyed_service_factory.cc
index 7c44c2ce3893fcf79297864fe0041e5914712900..7afecda34f6676c1c5aa3d3dac84ad66effad3b7 100644
--- a/components/keyed_service/core/refcounted_keyed_service_factory.cc
+++ b/components/keyed_service/core/refcounted_keyed_service_factory.cc
@@ -28,6 +28,12 @@ void RefcountedKeyedServiceFactory::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 |ContextShutdown| from causing
+ // |AssertBrowserContextWasntDestroyed| to raise an error.
+ MarkContextLive(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