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

Unified Diff: chrome/browser/prerender/prerender_manager_factory.h

Issue 2304953002: NoState Prefetch: nostate prefetch browser tests. (Closed)
Patch Set: histogram name fixes Created 4 years, 3 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: 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

Powered by Google App Engine
This is Rietveld 408576698