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