Index: chrome/browser/prerender/prerender_manager_factory.h |
diff --git a/chrome/browser/prerender/prerender_manager_factory.h b/chrome/browser/prerender/prerender_manager_factory.h |
index 46e7e67f2db756bb316e4ada0a1de322763340b4..e6a35f65bf3d62f4b527df823fe40d03397192f2 100644 |
--- a/chrome/browser/prerender/prerender_manager_factory.h |
+++ b/chrome/browser/prerender/prerender_manager_factory.h |
@@ -30,6 +30,22 @@ class PrerenderManagerFactory : public BrowserContextKeyedServiceFactory { |
static PrerenderManagerFactory* GetInstance(); |
+ // Sets a global TestingFactoryFunction that will be used to create |
+ // PrerenderManagers for all BrowserContexts. |
+ // |
+ // In-process browser tests cannot use KeyedServiceFactory::SetTestingFactory |
+ // to override the PrerenderManagerFactory. The test instance is started |
+ // before there is a browser or profile and so it is not possible to |
+ // SetTestingFactory. By the time the first testing hook after browser |
+ // creation is called (content::BrowserTestBase::SetUpOnMainThread), the |
+ // PrerenderManager instance has already by created (eg, by the prerender tab |
pasko
2016/09/30 18:29:20
nit: s/by/been/
(but actually it is better to rem
|
+ // helper), and it is too late. This testing_create_function overrides |
+ // PrerenderManager creation for all profiles. |
+ static void set_testing_create_function( |
+ TestingFactoryFunction create_function) { |
+ testing_create_function_ = create_function; |
+ } |
+ |
private: |
friend struct base::DefaultSingletonTraits<PrerenderManagerFactory>; |
@@ -41,6 +57,8 @@ class PrerenderManagerFactory : public BrowserContextKeyedServiceFactory { |
content::BrowserContext* profile) const override; |
content::BrowserContext* GetBrowserContextToUse( |
content::BrowserContext* context) const override; |
+ |
+ static TestingFactoryFunction testing_create_function_; |
}; |
} // namespace prerender |