OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_FACTORY_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_FACTORY_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_FACTORY_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" | 10 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 // Listens for the Profile's destruction notification and cleans up the | 23 // Listens for the Profile's destruction notification and cleans up the |
24 // associated PrerenderManager. | 24 // associated PrerenderManager. |
25 class PrerenderManagerFactory : public BrowserContextKeyedServiceFactory { | 25 class PrerenderManagerFactory : public BrowserContextKeyedServiceFactory { |
26 public: | 26 public: |
27 // Returns the PrerenderManager for |profile|. | 27 // Returns the PrerenderManager for |profile|. |
28 static PrerenderManager* GetForBrowserContext( | 28 static PrerenderManager* GetForBrowserContext( |
29 content::BrowserContext* context); | 29 content::BrowserContext* context); |
30 | 30 |
31 static PrerenderManagerFactory* GetInstance(); | 31 static PrerenderManagerFactory* GetInstance(); |
32 | 32 |
33 // Sets a global TestingFactoryFunction that will be used to create | |
34 // PrerenderManagers for all BrowserContexts. | |
35 // | |
36 // In-process browser tests cannot use KeyedServiceFactory::SetTestingFactory | |
37 // to override the PrerenderManagerFactory. The test instance is started | |
38 // before there is a browser or profile and so it is not possible to | |
39 // SetTestingFactory. By the time the first testing hook after browser | |
40 // creation is called (content::BrowserTestBase::SetUpOnMainThread), the | |
41 // 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
| |
42 // helper), and it is too late. This testing_create_function overrides | |
43 // PrerenderManager creation for all profiles. | |
44 static void set_testing_create_function( | |
45 TestingFactoryFunction create_function) { | |
46 testing_create_function_ = create_function; | |
47 } | |
48 | |
33 private: | 49 private: |
34 friend struct base::DefaultSingletonTraits<PrerenderManagerFactory>; | 50 friend struct base::DefaultSingletonTraits<PrerenderManagerFactory>; |
35 | 51 |
36 PrerenderManagerFactory(); | 52 PrerenderManagerFactory(); |
37 ~PrerenderManagerFactory() override; | 53 ~PrerenderManagerFactory() override; |
38 | 54 |
39 // BrowserContextKeyedServiceFactory: | 55 // BrowserContextKeyedServiceFactory: |
40 KeyedService* BuildServiceInstanceFor( | 56 KeyedService* BuildServiceInstanceFor( |
41 content::BrowserContext* profile) const override; | 57 content::BrowserContext* profile) const override; |
42 content::BrowserContext* GetBrowserContextToUse( | 58 content::BrowserContext* GetBrowserContextToUse( |
43 content::BrowserContext* context) const override; | 59 content::BrowserContext* context) const override; |
60 | |
61 static TestingFactoryFunction testing_create_function_; | |
44 }; | 62 }; |
45 | 63 |
46 } // namespace prerender | 64 } // namespace prerender |
47 | 65 |
48 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_FACTORY_H_ | 66 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_FACTORY_H_ |
OLD | NEW |