Chromium Code Reviews| Index: extensions/browser/api/cast_channel/cast_channel_service_factory.cc |
| diff --git a/extensions/browser/api/cast_channel/cast_channel_service_factory.cc b/extensions/browser/api/cast_channel/cast_channel_service_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b914bbc0dff0c0cbdf308bb15bc23464340b5187 |
| --- /dev/null |
| +++ b/extensions/browser/api/cast_channel/cast_channel_service_factory.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "extensions/browser/api/cast_channel/cast_channel_service_factory.h" |
| + |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| +#include "extensions/browser/api/cast_channel/cast_channel_service.h" |
| + |
| +namespace extensions { |
| +namespace api { |
| +namespace cast_channel { |
| + |
| +using content::BrowserContext; |
| + |
| +namespace { |
| + |
| +base::LazyInstance<CastChannelServiceFactory>::DestructorAtExit |
| + service_factory = LAZY_INSTANCE_INITIALIZER; |
| +} // namespace |
| + |
| +// static |
| +CastChannelService* CastChannelServiceFactory::GetForBrowserContext( |
| + BrowserContext* context) { |
| + DCHECK(context); |
| + // GetServiceForBrowserContext returns a KeyedService hence the static_cast<> |
| + // to return a pointer to CastChannelService. |
| + return static_cast<CastChannelService*>( |
| + service_factory.Get().GetServiceForBrowserContext(context, true)); |
| +} |
| + |
| +// static |
| +CastChannelServiceFactory* CastChannelServiceFactory::GetInstance() { |
| + return &service_factory.Get(); |
| +} |
| + |
| +CastChannelServiceFactory::CastChannelServiceFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "CastChannelService", |
| + BrowserContextDependencyManager::GetInstance()) {} |
| + |
| +CastChannelServiceFactory::~CastChannelServiceFactory() {} |
| + |
| +content::BrowserContext* CastChannelServiceFactory::GetBrowserContextToUse( |
| + content::BrowserContext* context) const { |
| + return context; |
|
mark a. foltz
2017/05/18 19:12:05
This will return separate services for a normal pr
zhaobin
2017/05/24 01:51:40
Verified that CastChannelAPI has the same browser
mark a. foltz
2017/05/24 17:44:10
Cool :)
|
| +} |
| + |
| +KeyedService* CastChannelServiceFactory::BuildServiceInstanceFor( |
| + BrowserContext* context) const { |
| + return new CastChannelService(); |
| +} |
| + |
| +} // namespace cast_channel |
| +} // namespace api |
| +} // namespace extensions |