OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MEDIA_ROUTER_MEDIA_ROUTER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_FACTORY_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_FACTORY_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_FACTORY_H_ |
7 | 7 |
| 8 #include "base/gtest_prod_util.h" |
8 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 11 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 class BrowserContext; | 14 class BrowserContext; |
14 } | 15 } |
15 | 16 |
16 namespace media_router { | 17 namespace media_router { |
17 | 18 |
18 class MediaRouter; | 19 class MediaRouter; |
19 | 20 |
20 // A factory that lazily returns a MediaRouter implementation for a given | 21 // A factory that lazily returns a MediaRouter implementation for a given |
21 // BrowserContext. | 22 // BrowserContext. |
22 class MediaRouterFactory : public BrowserContextKeyedServiceFactory { | 23 class MediaRouterFactory : public BrowserContextKeyedServiceFactory { |
23 public: | 24 public: |
24 static MediaRouter* GetApiForBrowserContext(content::BrowserContext* context); | 25 static MediaRouter* GetApiForBrowserContext(content::BrowserContext* context); |
25 | 26 |
26 protected: | 27 protected: |
27 // We override the shutdown method for the factory to give the Media Router a | 28 // We override the shutdown method for the factory to give the Media Router a |
28 // chance to remove off the record media routes. | 29 // chance to remove off the record media routes. |
29 void BrowserContextShutdown(content::BrowserContext* context) override; | 30 void BrowserContextShutdown(content::BrowserContext* context) override; |
30 | 31 |
31 private: | 32 private: |
32 friend struct base::DefaultLazyInstanceTraits<MediaRouterFactory>; | 33 friend struct base::DefaultLazyInstanceTraits<MediaRouterFactory>; |
| 34 FRIEND_TEST_ALL_PREFIXES(MediaRouterFactoryTest, |
| 35 OffTheRecordBrowserContextShutdown); |
33 | 36 |
34 MediaRouterFactory(); | 37 MediaRouterFactory(); |
35 ~MediaRouterFactory() override; | 38 ~MediaRouterFactory() override; |
36 | 39 |
| 40 // Exposed for testing. |
| 41 static MediaRouterFactory* GetMediaRouterFactoryForTest(); |
| 42 |
37 // BrowserContextKeyedServiceFactory interface. | 43 // BrowserContextKeyedServiceFactory interface. |
38 content::BrowserContext* GetBrowserContextToUse( | 44 content::BrowserContext* GetBrowserContextToUse( |
39 content::BrowserContext* context) const override; | 45 content::BrowserContext* context) const override; |
40 | 46 |
41 KeyedService* BuildServiceInstanceFor( | 47 KeyedService* BuildServiceInstanceFor( |
42 content::BrowserContext* context) const override; | 48 content::BrowserContext* context) const override; |
43 | 49 |
44 DISALLOW_COPY_AND_ASSIGN(MediaRouterFactory); | 50 DISALLOW_COPY_AND_ASSIGN(MediaRouterFactory); |
45 }; | 51 }; |
46 | 52 |
47 } // namespace media_router | 53 } // namespace media_router |
48 | 54 |
49 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_FACTORY_H_ | 55 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_FACTORY_H_ |
OLD | NEW |