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

Unified Diff: chrome/browser/gcm/gcm_profile_service_factory.cc

Issue 2864293003: [Offline Pages] Add a GCMAppHandler for offline page prefetch. (Closed)
Patch Set: Touch ups. 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/gcm/gcm_profile_service_factory.cc
diff --git a/chrome/browser/gcm/gcm_profile_service_factory.cc b/chrome/browser/gcm/gcm_profile_service_factory.cc
index f46cd612f8231fe2083b041e28d05da76a770eb6..45e4913e3cb522fe0684c763b4daf88ccde7bcde 100644
--- a/chrome/browser/gcm/gcm_profile_service_factory.cc
+++ b/chrome/browser/gcm/gcm_profile_service_factory.cc
@@ -18,7 +18,10 @@
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_thread.h"
-#if !defined(OS_ANDROID)
+#if defined(OS_ANDROID)
+#include "components/offline_pages/content/prefetch_service_factory.h"
+#include "components/offline_pages/core/prefetch/prefetch_service.h"
+#else
#include "chrome/browser/gcm/gcm_product_util.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/common/channel_info.h"
@@ -51,6 +54,8 @@ GCMProfileServiceFactory::GCMProfileServiceFactory()
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
#if !defined(OS_ANDROID)
DependsOn(LoginUIServiceFactory::GetInstance());
+#else
+ DependsOn(offline_pages::PrefetchServiceFactory::GetInstance());
#endif
}
@@ -68,10 +73,16 @@ KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor(
worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
worker_pool->GetSequenceToken(),
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
+ std::unique_ptr<GCMProfileService> service;
#if defined(OS_ANDROID)
- return new GCMProfileService(profile->GetPath(), blocking_task_runner);
+ service = base::WrapUnique(
Dmitry Titov 2017/05/11 03:35:20 Could be just base::MakeUnique<type>(params);
+ new GCMProfileService(profile->GetPath(), blocking_task_runner));
+ offline_pages::PrefetchService* prefetch_service =
+ offline_pages::PrefetchServiceFactory::GetForBrowserContext(context);
+ if (prefetch_service)
+ prefetch_service->RegisterWithGCMDriver(service->driver());
#else
- return new GCMProfileService(
+ service = base::WrapUnique(new GCMProfileService(
profile->GetPrefs(), profile->GetPath(), profile->GetRequestContext(),
chrome::GetChannel(),
gcm::GetProductCategoryForSubtypes(profile->GetPrefs()),
@@ -84,8 +95,9 @@ KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor(
content::BrowserThread::UI),
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO),
- blocking_task_runner);
+ blocking_task_runner));
#endif
+ return service.release();
}
content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse(

Powered by Google App Engine
This is Rietveld 408576698