Chromium Code Reviews| Index: chrome/browser/invalidation/ticl_invalidation_service.h |
| diff --git a/chrome/browser/invalidation/ticl_invalidation_service.h b/chrome/browser/invalidation/ticl_invalidation_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..701ac856f04f1345004452b49358876ac8e0ef2e |
| --- /dev/null |
| +++ b/chrome/browser/invalidation/ticl_invalidation_service.h |
| @@ -0,0 +1,103 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ |
| +#define CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ |
| + |
| +#include "base/threading/non_thread_safe.h" |
| +#include "chrome/browser/invalidation/invalidation_frontend.h" |
| +#include "chrome/browser/invalidation/invalidator_storage.h" |
| +#include "chrome/browser/profiles/profile_keyed_service.h" |
| +#include "chrome/browser/signin/signin_global_error.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| +#include "sync/notifier/invalidation_handler.h" |
| +#include "sync/notifier/invalidator_registrar.h" |
| + |
| +class Profile; |
| +class SigninManager; |
| +class TokenService; |
| + |
| +namespace syncer { |
| +class Invalidator; |
| +} |
| + |
| +namespace invalidation { |
| + |
| +// This InvalidationService wraps the C++ Invalidation Client (TICL) library. |
| +// It provides invalidations for desktop platforms (Win, Mac, Linux). |
| +class TiclInvalidationService |
| + : public base::NonThreadSafe, |
| + public ProfileKeyedService, |
| + public InvalidationFrontend, |
| + public content::NotificationObserver, |
| + public syncer::InvalidationHandler { |
| + public: |
| + TiclInvalidationService(SigninManager* signin, |
| + TokenService* token_service); |
| + virtual ~TiclInvalidationService(); |
| + |
| + void Init(Profile* profile); |
|
dcheng
2013/05/03 18:07:34
Out of curiosity, is there a particular reason tha
rlarocque
2013/05/03 22:16:14
I think that's probably historical reasons. Takin
|
| + |
| + // InvalidationFrontend implementation. |
| + // It is an error to have registered handlers when Shutdown() is called. |
| + virtual void RegisterInvalidationHandler( |
| + syncer::InvalidationHandler* handler) OVERRIDE; |
| + virtual void UpdateRegisteredInvalidationIds( |
| + syncer::InvalidationHandler* handler, |
| + const syncer::ObjectIdSet& ids) OVERRIDE; |
| + virtual void UnregisterInvalidationHandler( |
| + syncer::InvalidationHandler* handler) OVERRIDE; |
| + virtual void AcknowledgeInvalidation( |
| + const invalidation::ObjectId& id, |
| + const syncer::AckHandle& ack_handle) OVERRIDE; |
| + virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; |
| + virtual std::string GetInvalidatorClientId() const; |
| + |
| + // content::NotificationObserver implementation. |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + // syncer::InvalidationHandler implementation. |
| + virtual void OnInvalidatorStateChange( |
| + syncer::InvalidatorState state) OVERRIDE; |
| + virtual void OnIncomingInvalidation( |
| + const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| + |
| + // Override of ProfileKeyedService methods. |
| + virtual void Shutdown() OVERRIDE; |
| + |
| + protected: |
| + // Constructor for tests. |
| + TiclInvalidationService(SigninManager* signin, |
|
tim (not reviewing)
2013/05/03 17:48:23
Rather than rely on the comment, why not have an I
rlarocque
2013/05/03 22:16:14
Done.
|
| + TokenService* token_service, |
| + Profile* profile, |
| + syncer::Invalidator* invalidator); |
| + friend class TiclInvalidationServiceTestDelegate; |
| + |
| + private: |
| + bool IsReadyToStart(); |
| + bool IsStarted(); |
| + |
| + void Start(); |
| + void UpdateToken(); |
| + void Stop(); |
| + |
| + Profile* profile_; |
| + SigninManager* signin_manager_; |
| + TokenService* token_service_; |
| + |
| + scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; |
| + scoped_ptr<InvalidatorStorage> invalidator_storage_; |
| + scoped_ptr<syncer::Invalidator> invalidator_; |
| + |
| + content::NotificationRegistrar notification_registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); |
| +}; |
| + |
| +} |
|
tim (not reviewing)
2013/05/03 17:48:23
// namespace invalidation
rlarocque
2013/05/03 22:16:14
Done.
|
| + |
| +#endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ |