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

Unified Diff: chrome/browser/android/offline_pages/prefetch/prefetch_service_factory.cc

Issue 2864293003: [Offline Pages] Add a GCMAppHandler for offline page prefetch. (Closed)
Patch Set: Created 3 years, 7 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/android/offline_pages/prefetch/prefetch_service_factory.cc
diff --git a/components/offline_pages/content/prefetch_service_factory.cc b/chrome/browser/android/offline_pages/prefetch/prefetch_service_factory.cc
similarity index 57%
rename from components/offline_pages/content/prefetch_service_factory.cc
rename to chrome/browser/android/offline_pages/prefetch/prefetch_service_factory.cc
index ffe46b2630825585089479fcd31dfa4165481b54..f181cb8b1d4ffb876c8fa1b6b529b8711629a79b 100644
--- a/components/offline_pages/content/prefetch_service_factory.cc
+++ b/chrome/browser/android/offline_pages/prefetch/prefetch_service_factory.cc
@@ -2,19 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/offline_pages/content/prefetch_service_factory.h"
+#include "chrome/browser/android/offline_pages/prefetch/prefetch_service_factory.h"
#include "base/memory/singleton.h"
+#include "chrome/browser/gcm/gcm_profile_service_factory.h"
+#include "components/gcm_driver/gcm_driver.h"
+#include "components/gcm_driver/gcm_profile_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/offline_pages/core/prefetch/prefetch_service_impl.h"
#include "content/public/browser/browser_context.h"
namespace offline_pages {
+namespace {
+const char kPrefetchingOfflinePagesAppId[] =
+ "com.google.chrome.OfflinePagePrefetch";
+}
+
PrefetchServiceFactory::PrefetchServiceFactory()
: BrowserContextKeyedServiceFactory(
"OfflinePagePrefetchService",
- BrowserContextDependencyManager::GetInstance()) {}
+ BrowserContextDependencyManager::GetInstance()) {
+ DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
Dmitry Titov 2017/05/09 00:22:25 I wonder if this is the other way around - technic
+}
// static
PrefetchServiceFactory* PrefetchServiceFactory::GetInstance() {
@@ -30,7 +40,15 @@ PrefetchService* PrefetchServiceFactory::GetForBrowserContext(
KeyedService* PrefetchServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
- return new PrefetchServiceImpl();
+ PrefetchServiceImpl* service = new PrefetchServiceImpl();
+ gcm::GCMProfileServiceFactory::GetForProfile(context)
+ ->driver()
+ ->AddAppHandler(kPrefetchingOfflinePagesAppId, service);
+ return service;
+}
+
+bool PrefetchServiceFactory::ServiceIsCreatedWithBrowserContext() const {
+ return true;
}
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698