Index: chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h |
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c7cb15eaae6b355c945c4f5a3b3eab8e449bef20 |
--- /dev/null |
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h |
@@ -0,0 +1,61 @@ |
+// 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_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |
+#define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |
+ |
+#include <set> |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "base/threading/thread_checker.h" |
+#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_mapper.h" |
+#include "sync/notifier/sync_notifier_observer.h" |
+ |
+class InvalidationService; |
+ |
+namespace extensions { |
+ |
+class PushMessagingInvalidationHandlerObserver; |
Munjal (Google)
2012/08/14 18:56:37
I am wondering if we should have a browser/push_me
dcheng
2012/08/14 21:39:59
That seems like a good idea. The class names are r
|
+ |
+// This class maps extension IDs to the corresponding object IDs, manages |
+// invalidation registrations, and dispatches callbacks for any invalidations |
+// received. |
+class PushMessagingInvalidationHandler : public PushMessagingInvalidationMapper, |
+ public syncer::SyncNotifierObserver { |
+ public: |
+ // |service| and |observer| must remain valid for the lifetime of this object. |
+ // |extension_ids| is the set of extension IDs for which push messaging is |
+ // enabled. |
+ PushMessagingInvalidationHandler( |
+ InvalidationService* service, |
+ PushMessagingInvalidationHandlerObserver* observer, |
+ const std::set<std::string>& extension_ids); |
+ virtual ~PushMessagingInvalidationHandler(); |
+ |
+ // PushMessagingInvalidationMapper implementation. |
+ virtual void RegisterExtension(const std::string& extension_id) OVERRIDE; |
+ virtual void UnregisterExtension(const std::string& extension_id) OVERRIDE; |
+ |
+ // SyncNotifierObserver implementation. |
+ virtual void OnNotificationsEnabled() OVERRIDE; |
+ virtual void OnNotificationsDisabled( |
+ syncer::NotificationsDisabledReason reason) OVERRIDE; |
+ virtual void OnIncomingNotification( |
+ const syncer::ObjectIdPayloadMap& id_payloads, |
+ syncer::IncomingNotificationSource source) OVERRIDE; |
+ |
+ private: |
+ base::ThreadChecker thread_checker_; |
+ InvalidationService* service_; |
+ syncer::ObjectIdSet registered_ids_; |
+ PushMessagingInvalidationHandlerObserver* observer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PushMessagingInvalidationHandler); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |