| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "extensions/browser/api/cast_channel/cast_socket_service_factory.h" | |
| 6 | |
| 7 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 8 #include "extensions/browser/api/cast_channel/cast_socket_service.h" | |
| 9 | |
| 10 namespace extensions { | |
| 11 namespace api { | |
| 12 namespace cast_channel { | |
| 13 | |
| 14 using content::BrowserContext; | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 base::LazyInstance<CastSocketServiceFactory>::DestructorAtExit service_factory = | |
| 19 LAZY_INSTANCE_INITIALIZER; | |
| 20 } // namespace | |
| 21 | |
| 22 // static | |
| 23 CastSocketService* CastSocketServiceFactory::GetForBrowserContext( | |
| 24 BrowserContext* context) { | |
| 25 DCHECK(context); | |
| 26 // GetServiceForBrowserContext returns a KeyedService hence the static_cast<> | |
| 27 // to return a pointer to CastSocketService. | |
| 28 return static_cast<CastSocketService*>( | |
| 29 service_factory.Get().GetServiceForBrowserContext(context, true)); | |
| 30 } | |
| 31 | |
| 32 // static | |
| 33 CastSocketServiceFactory* CastSocketServiceFactory::GetInstance() { | |
| 34 return &service_factory.Get(); | |
| 35 } | |
| 36 | |
| 37 CastSocketServiceFactory::CastSocketServiceFactory() | |
| 38 : BrowserContextKeyedServiceFactory( | |
| 39 "CastSocketService", | |
| 40 BrowserContextDependencyManager::GetInstance()) {} | |
| 41 | |
| 42 CastSocketServiceFactory::~CastSocketServiceFactory() {} | |
| 43 | |
| 44 content::BrowserContext* CastSocketServiceFactory::GetBrowserContextToUse( | |
| 45 content::BrowserContext* context) const { | |
| 46 return context; | |
| 47 } | |
| 48 | |
| 49 KeyedService* CastSocketServiceFactory::BuildServiceInstanceFor( | |
| 50 BrowserContext* context) const { | |
| 51 return new CastSocketService(); | |
| 52 } | |
| 53 | |
| 54 } // namespace cast_channel | |
| 55 } // namespace api | |
| 56 } // namespace extensions | |
| OLD | NEW |