Chromium Code Reviews| Index: chrome/browser/previews/previews_service_factory.cc |
| diff --git a/chrome/browser/previews/previews_service_factory.cc b/chrome/browser/previews/previews_service_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a8e1ad3e35f6765ebfd3ed2d23922b873c3967f0 |
| --- /dev/null |
| +++ b/chrome/browser/previews/previews_service_factory.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2016 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 "chrome/browser/previews/previews_service_factory.h" |
| + |
| +#include "chrome/browser/previews/previews_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| +#include "content/public/browser/browser_context.h" |
| + |
| +namespace { |
| + |
| +static base::LazyInstance<PreviewsServiceFactory> g_previews_factory = |
|
Lei Zhang
2016/09/08 21:31:57
no need for static inside anonymous namespace.
RyanSturm
2016/09/08 22:18:26
Done.
|
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| +} // namespace |
| + |
| +// static |
| +PreviewsService* PreviewsServiceFactory::GetForProfile(Profile* profile) { |
| + DCHECK_NE(profile->GetProfileType(), Profile::INCOGNITO_PROFILE); |
| + return static_cast<PreviewsService*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| +} |
| + |
| +// static |
| +PreviewsServiceFactory* PreviewsServiceFactory::GetInstance() { |
| + return g_previews_factory.Pointer(); |
| +} |
| + |
| +PreviewsServiceFactory::PreviewsServiceFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "PreviewsService", |
| + BrowserContextDependencyManager::GetInstance()) {} |
| + |
| +PreviewsServiceFactory::~PreviewsServiceFactory() {} |
| + |
| +KeyedService* PreviewsServiceFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* context) const { |
| + return new PreviewsService(); |
| +} |