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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/content/prefetch_service_factory.h" 5 #include "chrome/browser/android/offline_pages/prefetch/prefetch_service_factory .h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "chrome/browser/gcm/gcm_profile_service_factory.h"
9 #include "components/gcm_driver/gcm_driver.h"
10 #include "components/gcm_driver/gcm_profile_service.h"
8 #include "components/keyed_service/content/browser_context_dependency_manager.h" 11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
9 #include "components/offline_pages/core/prefetch/prefetch_service_impl.h" 12 #include "components/offline_pages/core/prefetch/prefetch_service_impl.h"
10 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
11 14
12 namespace offline_pages { 15 namespace offline_pages {
13 16
17 namespace {
18 const char kPrefetchingOfflinePagesAppId[] =
19 "com.google.chrome.OfflinePagePrefetch";
20 }
21
14 PrefetchServiceFactory::PrefetchServiceFactory() 22 PrefetchServiceFactory::PrefetchServiceFactory()
15 : BrowserContextKeyedServiceFactory( 23 : BrowserContextKeyedServiceFactory(
16 "OfflinePagePrefetchService", 24 "OfflinePagePrefetchService",
17 BrowserContextDependencyManager::GetInstance()) {} 25 BrowserContextDependencyManager::GetInstance()) {
26 DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
Dmitry Titov 2017/05/09 00:22:25 I wonder if this is the other way around - technic
27 }
18 28
19 // static 29 // static
20 PrefetchServiceFactory* PrefetchServiceFactory::GetInstance() { 30 PrefetchServiceFactory* PrefetchServiceFactory::GetInstance() {
21 return base::Singleton<PrefetchServiceFactory>::get(); 31 return base::Singleton<PrefetchServiceFactory>::get();
22 } 32 }
23 33
24 // static 34 // static
25 PrefetchService* PrefetchServiceFactory::GetForBrowserContext( 35 PrefetchService* PrefetchServiceFactory::GetForBrowserContext(
26 content::BrowserContext* context) { 36 content::BrowserContext* context) {
27 return static_cast<PrefetchService*>( 37 return static_cast<PrefetchService*>(
28 GetInstance()->GetServiceForBrowserContext(context, true)); 38 GetInstance()->GetServiceForBrowserContext(context, true));
29 } 39 }
30 40
31 KeyedService* PrefetchServiceFactory::BuildServiceInstanceFor( 41 KeyedService* PrefetchServiceFactory::BuildServiceInstanceFor(
32 content::BrowserContext* context) const { 42 content::BrowserContext* context) const {
33 return new PrefetchServiceImpl(); 43 PrefetchServiceImpl* service = new PrefetchServiceImpl();
44 gcm::GCMProfileServiceFactory::GetForProfile(context)
45 ->driver()
46 ->AddAppHandler(kPrefetchingOfflinePagesAppId, service);
47 return service;
48 }
49
50 bool PrefetchServiceFactory::ServiceIsCreatedWithBrowserContext() const {
51 return true;
34 } 52 }
35 53
36 } // namespace offline_pages 54 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698