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

Unified Diff: chrome/browser/extensions/api/push_messaging/invalidation_handler.h

Issue 10837013: Chrome Cloud Messaging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: InvalidationHandler + event Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/push_messaging/invalidation_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | chrome/browser/extensions/api/push_messaging/invalidation_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698