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 #include "content/public/browser/browser_thread.h" | |
13 | |
14 // static | |
15 BackgroundFetchClientImpl* BackgroundFetchClientFactory::GetForProfile( | |
16 Profile* profile) { | |
17 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
18 return static_cast<BackgroundFetchClientImpl*>( | |
19 GetInstance()->GetServiceForBrowserContext(profile, true /* create */)); | |
20 } | |
21 | |
22 // static | |
23 BackgroundFetchClientFactory* BackgroundFetchClientFactory::GetInstance() { | |
24 return base::Singleton<BackgroundFetchClientFactory>::get(); | |
25 } | |
26 | |
27 BackgroundFetchClientFactory::BackgroundFetchClientFactory() | |
28 : BrowserContextKeyedServiceFactory( | |
29 "BackgroundFetchService", | |
Peter Beverloo
2017/04/18 23:12:08
nit: BackgroundFetchClient
harkness
2017/04/19 09:03:40
Done.
| |
30 BrowserContextDependencyManager::GetInstance()) { | |
31 DependsOn( | |
32 offline_items_collection::OfflineContentAggregatorFactory::GetInstance()); | |
33 } | |
34 | |
35 BackgroundFetchClientFactory::~BackgroundFetchClientFactory() {} | |
36 | |
37 KeyedService* BackgroundFetchClientFactory::BuildServiceInstanceFor( | |
38 content::BrowserContext* context) const { | |
39 return new BackgroundFetchClientImpl(Profile::FromBrowserContext(context)); | |
40 } | |
41 | |
42 content::BrowserContext* BackgroundFetchClientFactory::GetBrowserContextToUse( | |
43 content::BrowserContext* context) const { | |
44 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | |
45 } | |
OLD | NEW |