Chromium Code Reviews| 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/android_invalidation_service.h" | |
| 8 #include "chrome/browser/invalidation/invalidation_frontend.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_factory.h" | |
| 14 #include "chrome/browser/signin/token_service_factory.h" | |
| 15 | |
| 16 namespace invalidation { | |
| 17 | |
| 18 // TODO(rlarocque): Re-enable this once InvalidationFrontend can | |
| 19 // extend ProfileKeyedService. | |
| 20 // // static | |
| 21 // InvalidationFrontend* InvalidationServiceFactory::GetForProfile( | |
| 22 // Profile* profile) { | |
| 23 // return static_cast<InvalidationFrontend*>( | |
| 24 // GetInstance()->GetServiceForProfile(profile, true)); | |
| 25 // } | |
| 26 | |
| 27 // static | |
| 28 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() { | |
| 29 return Singleton<InvalidationServiceFactory>::get(); | |
| 30 } | |
| 31 | |
| 32 InvalidationServiceFactory::InvalidationServiceFactory() | |
| 33 : ProfileKeyedServiceFactory("InvalidationService", | |
| 34 ProfileDependencyManager::GetInstance()) { | |
| 35 #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.
| |
| 36 DependsOn(SigninManagerFactory::GetInstance()); | |
| 37 DependsOn(TokenServiceFactory::GetInstance()); | |
| 38 #endif | |
| 39 } | |
| 40 | |
| 41 InvalidationServiceFactory::~InvalidationServiceFactory() {} | |
| 42 | |
| 43 // static | |
| 44 ProfileKeyedService* InvalidationServiceFactory::BuildTestServiceInstanceFor( | |
| 45 Profile* profile) { | |
| 46 // This is unsafe. We can get awway with it because we know that the the | |
| 47 // InvalidationService will never access those NULL pointers because Init() | |
| 48 // was never called. | |
| 49 return new TiclInvalidationService(NULL, NULL); | |
| 50 } | |
| 51 | |
| 52 // static | |
| 53 ProfileKeyedService* | |
| 54 InvalidationServiceFactory::BuildP2PInvalidationServiceFor(Profile* profile) { | |
| 55 P2PInvalidationService* service = new P2PInvalidationService(); | |
| 56 service->Init(profile); | |
| 57 return service; | |
| 58 } | |
| 59 | |
| 60 ProfileKeyedService* InvalidationServiceFactory::BuildServiceInstanceFor( | |
| 61 Profile* profile) const { | |
| 62 #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.
| |
| 63 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); | |
| 64 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); | |
| 65 | |
| 66 TiclInvalidationService* service = new TiclInvalidationService( | |
| 67 signin_manager, token_service); | |
| 68 service->Init(profile); | |
| 69 return service; | |
| 70 #else | |
| 71 AndroidInvalidationService* service = new AndroidInvalidationService(); | |
| 72 service->Init(profile); | |
| 73 return service; | |
| 74 #endif | |
| 75 } | |
| 76 | |
| 77 } // namespace invalidation | |
| OLD | NEW |