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

Unified Diff: chrome/browser/invalidation/invalidation_service_factory.cc

Issue 13991017: Commit InvalidationService implementations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor updates Created 7 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/invalidation/invalidation_service_factory.cc
diff --git a/chrome/browser/invalidation/invalidation_service_factory.cc b/chrome/browser/invalidation/invalidation_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7922deb39127b054f6b92bf6ff8ee408c944b0cb
--- /dev/null
+++ b/chrome/browser/invalidation/invalidation_service_factory.cc
@@ -0,0 +1,77 @@
+// Copyright (c) 2013 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/invalidation/invalidation_service_factory.h"
+
+#include "chrome/browser/invalidation/android_invalidation_service.h"
+#include "chrome/browser/invalidation/invalidation_frontend.h"
+#include "chrome/browser/invalidation/p2p_invalidation_service.h"
+#include "chrome/browser/invalidation/ticl_invalidation_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/signin/token_service_factory.h"
+
+namespace invalidation {
+
+// TODO(rlarocque): Re-enable this once InvalidationFrontend can
+// extend ProfileKeyedService.
+// // static
+// InvalidationFrontend* InvalidationServiceFactory::GetForProfile(
+// Profile* profile) {
+// return static_cast<InvalidationFrontend*>(
+// GetInstance()->GetServiceForProfile(profile, true));
+// }
+
+// static
+InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() {
+ return Singleton<InvalidationServiceFactory>::get();
+}
+
+InvalidationServiceFactory::InvalidationServiceFactory()
+ : ProfileKeyedServiceFactory("InvalidationService",
+ ProfileDependencyManager::GetInstance()) {
+#ifndef OS_ANDROID
tim (not reviewing) 2013/05/03 17:48:23 nit- prefer #if !defined(OS_ANDROID)
rlarocque 2013/05/03 22:16:14 Done.
+ DependsOn(SigninManagerFactory::GetInstance());
+ DependsOn(TokenServiceFactory::GetInstance());
+#endif
+}
+
+InvalidationServiceFactory::~InvalidationServiceFactory() {}
+
+// static
+ProfileKeyedService* InvalidationServiceFactory::BuildTestServiceInstanceFor(
+ Profile* profile) {
+ // This is unsafe. We can get awway with it because we know that the the
+ // InvalidationService will never access those NULL pointers because Init()
+ // was never called.
+ return new TiclInvalidationService(NULL, NULL);
+}
+
+// static
+ProfileKeyedService*
+InvalidationServiceFactory::BuildP2PInvalidationServiceFor(Profile* profile) {
+ P2PInvalidationService* service = new P2PInvalidationService();
+ service->Init(profile);
+ return service;
+}
+
+ProfileKeyedService* InvalidationServiceFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+#ifndef OS_ANDROID
tim (not reviewing) 2013/05/03 17:48:23 nit - #if !defined(OS_ANDROID)
rlarocque 2013/05/03 22:16:14 Done.
+ SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
+ TokenService* token_service = TokenServiceFactory::GetForProfile(profile);
+
+ TiclInvalidationService* service = new TiclInvalidationService(
+ signin_manager, token_service);
+ service->Init(profile);
+ return service;
+#else
+ AndroidInvalidationService* service = new AndroidInvalidationService();
+ service->Init(profile);
+ return service;
+#endif
+}
+
+} // namespace invalidation

Powered by Google App Engine
This is Rietveld 408576698