Convert browser_tests to Swarming.
[chromium-blink-merge.git] / chrome / browser / media / router / media_router_mojo_impl_factory.cc
blob1e2c73552bf77fa973bf8bbf8bb590331233e5ef
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
3 // found in the LICENSE file.
5 #include "chrome/browser/media/router/media_router_mojo_impl_factory.h"
7 #include "chrome/browser/media/router/media_router_mojo_impl.h"
8 #include "components/keyed_service/content/browser_context_dependency_manager.h"
9 #include "extensions/browser/process_manager.h"
10 #include "extensions/browser/process_manager_factory.h"
12 using content::BrowserContext;
14 namespace media_router {
16 namespace {
18 base::LazyInstance<MediaRouterMojoImplFactory> service_factory =
19 LAZY_INSTANCE_INITIALIZER;
21 } // namespace
23 // static
24 MediaRouterMojoImpl* MediaRouterMojoImplFactory::GetApiForBrowserContext(
25 BrowserContext* context) {
26 DCHECK(context);
28 return static_cast<MediaRouterMojoImpl*>(
29 service_factory.Get().GetServiceForBrowserContext(context, true));
32 MediaRouterMojoImplFactory::MediaRouterMojoImplFactory()
33 : BrowserContextKeyedServiceFactory(
34 "MediaRouterMojoImpl",
35 BrowserContextDependencyManager::GetInstance()) {
36 // MediaRouterMojoImpl depends on ProcessManager.
37 DependsOn(extensions::ProcessManagerFactory::GetInstance());
40 MediaRouterMojoImplFactory::~MediaRouterMojoImplFactory() {
43 KeyedService* MediaRouterMojoImplFactory::BuildServiceInstanceFor(
44 BrowserContext* context) const {
45 return new MediaRouterMojoImpl(extensions::ProcessManager::Get(context));
48 BrowserContext* MediaRouterMojoImplFactory::GetBrowserContextToUse(
49 BrowserContext* context) const {
50 // Always use the input context. This means that an incognito context will
51 // have its own MediaRouterMojoImpl service, rather than sharing it with its
52 // original non-incognito context.
53 return context;
56 } // namespace media_router