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 #ifndef CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ |
| 6 #define CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/threading/non_thread_safe.h" |
| 10 #include "chrome/browser/invalidation/invalidation_frontend.h" |
| 11 #include "chrome/browser/invalidation/invalidator_storage.h" |
| 12 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 13 #include "chrome/browser/signin/signin_global_error.h" |
| 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "sync/notifier/invalidation_handler.h" |
| 17 #include "sync/notifier/invalidator_registrar.h" |
| 18 |
| 19 class Profile; |
| 20 class SigninManagerBase; |
| 21 class TokenService; |
| 22 |
| 23 namespace syncer { |
| 24 class Invalidator; |
| 25 } |
| 26 |
| 27 namespace invalidation { |
| 28 |
| 29 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. |
| 30 // It provides invalidations for desktop platforms (Win, Mac, Linux). |
| 31 class TiclInvalidationService |
| 32 : public base::NonThreadSafe, |
| 33 public ProfileKeyedService, |
| 34 public InvalidationFrontend, |
| 35 public content::NotificationObserver, |
| 36 public syncer::InvalidationHandler { |
| 37 public: |
| 38 TiclInvalidationService(SigninManagerBase* signin, |
| 39 TokenService* token_service, |
| 40 Profile* profile); |
| 41 virtual ~TiclInvalidationService(); |
| 42 |
| 43 void Init(); |
| 44 |
| 45 // InvalidationFrontend implementation. |
| 46 // It is an error to have registered handlers when Shutdown() is called. |
| 47 virtual void RegisterInvalidationHandler( |
| 48 syncer::InvalidationHandler* handler) OVERRIDE; |
| 49 virtual void UpdateRegisteredInvalidationIds( |
| 50 syncer::InvalidationHandler* handler, |
| 51 const syncer::ObjectIdSet& ids) OVERRIDE; |
| 52 virtual void UnregisterInvalidationHandler( |
| 53 syncer::InvalidationHandler* handler) OVERRIDE; |
| 54 virtual void AcknowledgeInvalidation( |
| 55 const invalidation::ObjectId& id, |
| 56 const syncer::AckHandle& ack_handle) OVERRIDE; |
| 57 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; |
| 58 virtual std::string GetInvalidatorClientId() const; |
| 59 |
| 60 // content::NotificationObserver implementation. |
| 61 virtual void Observe(int type, |
| 62 const content::NotificationSource& source, |
| 63 const content::NotificationDetails& details) OVERRIDE; |
| 64 |
| 65 // syncer::InvalidationHandler implementation. |
| 66 virtual void OnInvalidatorStateChange( |
| 67 syncer::InvalidatorState state) OVERRIDE; |
| 68 virtual void OnIncomingInvalidation( |
| 69 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 70 |
| 71 // Override of ProfileKeyedService methods. |
| 72 virtual void Shutdown() OVERRIDE; |
| 73 |
| 74 protected: |
| 75 // Initializes with an injected invalidator. |
| 76 void InitForTest(syncer::Invalidator* invalidator); |
| 77 |
| 78 friend class TiclInvalidationServiceTestDelegate; |
| 79 |
| 80 private: |
| 81 bool IsReadyToStart(); |
| 82 bool IsStarted(); |
| 83 |
| 84 void Start(); |
| 85 void UpdateToken(); |
| 86 void Stop(); |
| 87 |
| 88 Profile *const profile_; |
| 89 SigninManagerBase *const signin_manager_; |
| 90 TokenService *const token_service_; |
| 91 |
| 92 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; |
| 93 scoped_ptr<InvalidatorStorage> invalidator_storage_; |
| 94 scoped_ptr<syncer::Invalidator> invalidator_; |
| 95 |
| 96 content::NotificationRegistrar notification_registrar_; |
| 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); |
| 99 }; |
| 100 |
| 101 } |
| 102 |
| 103 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ |
OLD | NEW |