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

Unified Diff: chrome/browser/invalidation_service_factory.cc

Issue 13197004: Draft: InvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Passes tests 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_service_factory.cc
diff --git a/chrome/browser/invalidation_service_factory.cc b/chrome/browser/invalidation_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..707720336f5d9f15d98c7b9cd4182899f6e74179
--- /dev/null
+++ b/chrome/browser/invalidation_service_factory.cc
@@ -0,0 +1,71 @@
+// 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_service_factory.h"
+
+#include "chrome/browser/android_invalidation_service.h"
+#include "chrome/browser/invalidation_service.h"
+#include "chrome/browser/p2p_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"
+
+// static
+InvalidationService* InvalidationServiceFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<InvalidationService*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+// static
+InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() {
+ return Singleton<InvalidationServiceFactory>::get();
+}
+
+InvalidationServiceFactory::InvalidationServiceFactory()
+ : ProfileKeyedServiceFactory("InvalidationService",
+ ProfileDependencyManager::GetInstance()) {
+#ifndef OS_ANDROID
+ DependsOn(SigninManagerFactory::GetInstance());
+ DependsOn(TokenServiceFactory::GetInstance());
+#endif
+}
+
+InvalidationServiceFactory::~InvalidationServiceFactory() {}
+
+ProfileKeyedService* InvalidationServiceFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+#ifndef OS_ANDROID
+ SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
+ TokenService* token_service = TokenServiceFactory::GetForProfile(profile);
+
+ InvalidationService* service = new InvalidationService(
+ signin_manager, token_service);
+ service->Init(profile);
+ return service;
+#else
+ AndroidInvalidationService* service = new AndroidInvalidationService();
+ service->Init(profile);
+ return service;
+#endif
+}
+
+// static
+ProfileKeyedService* InvalidationServiceFactory::BuildTestServiceInstanceFor(
+ Profile* profile) {
+ // This looks unsafe because it is unsafe. Fortunately, this class has
+ // sufficiently close relations to the InvalidationService to know that it
+ // will never access those NULL pointers because Init() was never called.
+ return new InvalidationService(NULL, NULL);
+}
+
+// static
+ProfileKeyedService*
+InvalidationServiceFactory::BuildP2PInvalidationServiceFor(Profile* profile) {
+ P2PInvalidationService* service = new P2PInvalidationService();
+ service->Init(profile);
+ return service;
+}
+

Powered by Google App Engine
This is Rietveld 408576698