Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Unified Diff: chrome/browser/background_fetch/background_fetch_client_factory.cc

Issue 2777063008: Connect BackgroundFetch to the OfflineItemCollection
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fdd094d1fe2839ac4bc69a0426ea697b1e13956f
--- /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*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
Peter Beverloo 2017/03/29 14:32:12 nit: true /* create */
harkness 2017/03/30 12:42:34 Done.
+}
+
+// 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);
Peter Beverloo 2017/03/29 14:32:12 Why do we want a separate instance of the service
harkness 2017/03/30 12:42:34 Let's discuss this in person.
+}

Powered by Google App Engine
This is Rietveld 408576698