| 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;
|
| +}
|
| +
|
|
|