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