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 scoped_refptr<CastSocketService> CastSocketServiceFactory::GetForBrowserContext( | |
24 BrowserContext* context) { | |
25 DCHECK(context); | |
26 // GetServiceForBrowserContext returns a KeyedService hence the static_cast<> | |
27 // to construct a temporary scoped_refptr on the stack for the return value. | |
28 return static_cast<CastSocketService*>( | |
29 service_factory.Get().GetServiceForBrowserContext(context, true).get()); | |
30 } | |
31 | |
32 // static | |
33 CastSocketServiceFactory* CastSocketServiceFactory::GetInstance() { | |
34 return &service_factory.Get(); | |
35 } | |
36 | |
37 CastSocketServiceFactory::CastSocketServiceFactory() | |
38 : RefcountedBrowserContextKeyedServiceFactory( | |
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 scoped_refptr<RefcountedKeyedService> | |
50 CastSocketServiceFactory::BuildServiceInstanceFor( | |
51 BrowserContext* context) const { | |
52 return make_scoped_refptr(new CastSocketService()); | |
53 } | |
54 | |
55 } // namespace cast_channel | |
56 } // namespace api | |
57 } // namespace extensions | |
OLD | NEW |