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..7876b4e9d9cc59b1319e9289be261a05835ad0be |
--- /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( |
+ "BackgroundFetchClient", |
+ 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); |
+} |