Chromium Code Reviews| Index: chrome/browser/background_fetch/background_fetch_client_factory.cc |
| diff --git a/chrome/browser/background_fetch/background_fetch_client_factory.cc b/chrome/browser/background_fetch/background_fetch_client_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1a255a8759b930abab5807bc858d778f13c715fd |
| --- /dev/null |
| +++ b/chrome/browser/background_fetch/background_fetch_client_factory.cc |
| @@ -0,0 +1,43 @@ |
| +// 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 "chrome/browser/background_fetch/background_fetch_client_factory.h" |
| + |
| +#include "chrome/browser/background_fetch/background_fetch_client_impl.h" |
| +#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h" |
| +#include "chrome/browser/profiles/incognito_helpers.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| + |
| +// static |
| +BackgroundFetchClientImpl* BackgroundFetchClientFactory::GetForProfile( |
| + Profile* profile) { |
| + return static_cast<BackgroundFetchClientImpl*>( |
|
Peter Beverloo
2017/03/31 01:32:22
Should we maybe have a DCHECK_CURRENTLY_ON() in he
harkness
2017/03/31 10:11:43
Done.
|
| + GetInstance()->GetServiceForBrowserContext(profile, true /* create */)); |
| +} |
| + |
| +// static |
| +BackgroundFetchClientFactory* BackgroundFetchClientFactory::GetInstance() { |
| + return base::Singleton<BackgroundFetchClientFactory>::get(); |
| +} |
| + |
| +BackgroundFetchClientFactory::BackgroundFetchClientFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "BackgroundFetchService", |
| + BrowserContextDependencyManager::GetInstance()) { |
| + DependsOn( |
| + offline_items_collection::OfflineContentAggregatorFactory::GetInstance()); |
| +} |
| + |
| +BackgroundFetchClientFactory::~BackgroundFetchClientFactory() {} |
| + |
| +KeyedService* BackgroundFetchClientFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* context) const { |
| + return new BackgroundFetchClientImpl(Profile::FromBrowserContext(context)); |
| +} |
| + |
| +content::BrowserContext* BackgroundFetchClientFactory::GetBrowserContextToUse( |
| + content::BrowserContext* context) const { |
| + return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| +} |