OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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. | |
4 | |
5 #include "chrome/browser/background_fetch/background_fetch_client_factory.h" | |
6 | |
7 #include "chrome/browser/background_fetch/background_fetch_client_impl.h" | |
8 #include "chrome/browser/offline_items_collection/offline_content_aggregator_fac tory.h" | |
9 #include "chrome/browser/profiles/incognito_helpers.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
11 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
12 | |
13 // static | |
14 BackgroundFetchClientImpl* BackgroundFetchClientFactory::GetForProfile( | |
15 Profile* profile) { | |
16 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.
| |
17 GetInstance()->GetServiceForBrowserContext(profile, true /* create */)); | |
18 } | |
19 | |
20 // static | |
21 BackgroundFetchClientFactory* BackgroundFetchClientFactory::GetInstance() { | |
22 return base::Singleton<BackgroundFetchClientFactory>::get(); | |
23 } | |
24 | |
25 BackgroundFetchClientFactory::BackgroundFetchClientFactory() | |
26 : BrowserContextKeyedServiceFactory( | |
27 "BackgroundFetchService", | |
28 BrowserContextDependencyManager::GetInstance()) { | |
29 DependsOn( | |
30 offline_items_collection::OfflineContentAggregatorFactory::GetInstance()); | |
31 } | |
32 | |
33 BackgroundFetchClientFactory::~BackgroundFetchClientFactory() {} | |
34 | |
35 KeyedService* BackgroundFetchClientFactory::BuildServiceInstanceFor( | |
36 content::BrowserContext* context) const { | |
37 return new BackgroundFetchClientImpl(Profile::FromBrowserContext(context)); | |
38 } | |
39 | |
40 content::BrowserContext* BackgroundFetchClientFactory::GetBrowserContextToUse( | |
41 content::BrowserContext* context) const { | |
42 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | |
43 } | |
OLD | NEW |