Index: chrome/browser/extensions/api/push_messaging/invalidation_handler.h |
diff --git a/chrome/browser/extensions/api/push_messaging/invalidation_handler.h b/chrome/browser/extensions/api/push_messaging/invalidation_handler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..268f3a9d35f4a7691432629b13dd167b03bba6e8 |
--- /dev/null |
+++ b/chrome/browser/extensions/api/push_messaging/invalidation_handler.h |
@@ -0,0 +1,62 @@ |
+// Copyright (c) 2012 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_EXTENSIONS_API_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |
+#define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |
+ |
+#include <map> |
+#include <string> |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "google/cacheinvalidation/include/types.h" |
+#include "sync/notifier/invalidation_util.h" |
+#include "sync/notifier/sync_notifier_observer.h" |
+ |
+namespace extensions { |
+ |
+class InvalidationHandlerObserver; |
+ |
+// Implements a listener for invalidations from Tango for app messaging. |
+// TODO(dcheng): Are there threading requirements here? We probably need to run |
+// on a certain thread. |
+// TODO(dcheng): This name is probably too generic. |
+class InvalidationHandler : public syncer::SyncNotifierObserver { |
+ public: |
+ explicit InvalidationHandler(InvalidationHandlerObserver* observer); |
+ virtual ~InvalidationHandler(); |
+ |
+ void RegisterExtension(const std::string& id); |
+ void UnregisterExtension(const std::string& id); |
+ |
+ // SyncNotifierObserver implementation. |
+ virtual void OnIncomingNotification( |
+ const syncer::ObjectIdPayloadMap& id_payloads, |
+ syncer::IncomingNotificationSource source) OVERRIDE; |
+ virtual void OnNotificationsEnabled() OVERRIDE; |
+ virtual void OnNotificationsDisabled( |
+ syncer::NotificationsDisabledReason reason) OVERRIDE; |
+ |
+ private: |
+ struct InvalidationRecord { |
+ // TODO(dcheng): Eventually we might store ack handles or something in here. |
+ enum Status { |
+ // TODO(dcheng): Better naming? |
+ kUpToDate, |
+ kNeedsAck, |
+ }; |
+ Status status; |
+ }; |
+ typedef std::map<invalidation::ObjectId, |
+ InvalidationRecord, |
+ syncer::ObjectIdLessThan> InvalidationRecordMap; |
+ |
+ InvalidationHandlerObserver* observer_; |
+ InvalidationRecordMap registered_entries_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InvalidationHandler); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |