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..a3102c5af4db4abe85354bec52af14ab662a3a37 |
| --- /dev/null |
| +++ b/chrome/browser/background_fetch/background_fetch_client_factory.cc |
| @@ -0,0 +1,45 @@ |
| +// 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" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +// static |
| +BackgroundFetchClientImpl* BackgroundFetchClientFactory::GetForProfile( |
| + Profile* profile) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + return static_cast<BackgroundFetchClientImpl*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true /* create */)); |
| +} |
| + |
| +// static |
| +BackgroundFetchClientFactory* BackgroundFetchClientFactory::GetInstance() { |
| + return base::Singleton<BackgroundFetchClientFactory>::get(); |
| +} |
| + |
| +BackgroundFetchClientFactory::BackgroundFetchClientFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "BackgroundFetchService", |
|
Peter Beverloo
2017/04/18 23:12:08
nit: BackgroundFetchClient
harkness
2017/04/19 09:03:40
Done.
|
| + 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); |
| +} |