Chromium Code Reviews| Index: chrome/browser/invalidation_service.h |
| diff --git a/chrome/browser/invalidation_service.h b/chrome/browser/invalidation_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c72979742e2e2968dba6c84cd2b8f064c5095fca |
| --- /dev/null |
| +++ b/chrome/browser/invalidation_service.h |
| @@ -0,0 +1,89 @@ |
| +// 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_SERVICE_H_ |
|
tim (not reviewing)
2013/04/15 16:48:24
This may have been your plan given the 'Draft' tit
|
| +#define CHROME_BROWSER_INVALIDATION_SERVICE_H_ |
| + |
| +#include "base/threading/non_thread_safe.h" |
| +#include "chrome/browser/profiles/profile_keyed_service.h" |
| +#include "chrome/browser/signin/signin_global_error.h" |
| +#include "chrome/browser/sync/invalidation_frontend.h" |
| +#include "chrome/browser/sync/invalidations/invalidator_storage.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; |
| +} |
| + |
| +class InvalidationService |
| + : public base::NonThreadSafe, |
| + public ProfileKeyedService, |
| + public InvalidationFrontend, |
| + public content::NotificationObserver, |
| + public syncer::InvalidationHandler { |
| + public: |
| + InvalidationService(SigninManager* signin, |
| + TokenService* token_service); |
| + virtual ~InvalidationService(); |
| + |
| + void Init(Profile* profile); |
| + |
| + // 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 OVERRIDE; |
| + |
| + // 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 method. |
| + virtual void Shutdown() OVERRIDE; |
| + |
| + 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<browser_sync::InvalidatorStorage> invalidator_storage_; |
| + scoped_ptr<syncer::Invalidator> invalidator_; |
| + |
| + content::NotificationRegistrar notification_registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InvalidationService); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_INVALIDATION_SERVICE_H_ |