OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
| 6 |
| 7 #include "chrome/browser/invalidation/invalidation_frontend.h" |
| 8 #include "chrome/browser/invalidation/invalidation_service_android.h" |
| 9 #include "chrome/browser/invalidation/p2p_invalidation_service.h" |
| 10 #include "chrome/browser/invalidation/ticl_invalidation_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 13 #include "chrome/browser/signin/signin_manager.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/browser/signin/token_service_factory.h" |
| 16 |
| 17 class TokenService; |
| 18 |
| 19 namespace invalidation { |
| 20 |
| 21 // TODO(rlarocque): Re-enable this once InvalidationFrontend can |
| 22 // extend ProfileKeyedService. |
| 23 // // static |
| 24 // InvalidationFrontend* InvalidationServiceFactory::GetForProfile( |
| 25 // Profile* profile) { |
| 26 // return static_cast<InvalidationFrontend*>( |
| 27 // GetInstance()->GetServiceForProfile(profile, true)); |
| 28 // } |
| 29 |
| 30 // static |
| 31 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() { |
| 32 return Singleton<InvalidationServiceFactory>::get(); |
| 33 } |
| 34 |
| 35 InvalidationServiceFactory::InvalidationServiceFactory() |
| 36 : ProfileKeyedServiceFactory("InvalidationService", |
| 37 ProfileDependencyManager::GetInstance()) { |
| 38 #if !defined(OS_ANDROID) |
| 39 DependsOn(SigninManagerFactory::GetInstance()); |
| 40 DependsOn(TokenServiceFactory::GetInstance()); |
| 41 #endif |
| 42 } |
| 43 |
| 44 InvalidationServiceFactory::~InvalidationServiceFactory() {} |
| 45 |
| 46 // static |
| 47 ProfileKeyedService* |
| 48 InvalidationServiceFactory::BuildP2PInvalidationServiceFor(Profile* profile) { |
| 49 return new P2PInvalidationService(profile); |
| 50 } |
| 51 |
| 52 ProfileKeyedService* InvalidationServiceFactory::BuildServiceInstanceFor( |
| 53 content::BrowserContext* context) const { |
| 54 Profile* profile = static_cast<Profile*>(context); |
| 55 #if defined(OS_ANDROID) |
| 56 InvalidationServiceAndroid* service = new InvalidationServiceAndroid(profile); |
| 57 return service; |
| 58 #else |
| 59 SigninManagerBase* signin_manager = |
| 60 SigninManagerFactory::GetForProfile(profile); |
| 61 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); |
| 62 |
| 63 TiclInvalidationService* service = new TiclInvalidationService( |
| 64 signin_manager, token_service, profile); |
| 65 service->Init(); |
| 66 return service; |
| 67 #endif |
| 68 } |
| 69 |
| 70 } // namespace invalidation |
OLD | NEW |