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

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

Issue 2777063008: Connect BackgroundFetch to the OfflineItemCollection
Patch Set: Fixed incognito check and added tests Created 3 years, 8 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..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);
+}

Powered by Google App Engine
This is Rietveld 408576698