Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1510)

Unified Diff: chrome/browser/invalidation/ticl_invalidation_service.h

Issue 13991017: Commit InvalidationService implementations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another attempt to fix Android Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ec6a14ce91a185716e22f44f827cd5bb945b6029
--- /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/memory/scoped_ptr.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 SigninManagerBase;
+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(SigninManagerBase* signin,
+ TokenService* token_service,
+ Profile* profile);
+ virtual ~TiclInvalidationService();
+
+ void Init();
+
+ // 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:
+ // Initializes with an injected invalidator.
+ void InitForTest(syncer::Invalidator* invalidator);
+
+ friend class TiclInvalidationServiceTestDelegate;
+
+ private:
+ bool IsReadyToStart();
+ bool IsStarted();
+
+ void Start();
+ void UpdateToken();
+ void Stop();
+
+ Profile *const profile_;
+ SigninManagerBase *const signin_manager_;
+ TokenService *const 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);
+};
+
+}
+
+#endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698