| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION
_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION
_HANDLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION
_HANDLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION
_HANDLER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_mapper.h" | 14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_mapper.h" |
| 15 #include "sync/notifier/invalidation_handler.h" | 15 #include "sync/notifier/invalidation_handler.h" |
| 16 | 16 |
| 17 namespace invalidation { |
| 17 class InvalidationFrontend; | 18 class InvalidationFrontend; |
| 19 } |
| 18 | 20 |
| 19 namespace extensions { | 21 namespace extensions { |
| 20 | 22 |
| 21 class PushMessagingInvalidationHandlerDelegate; | 23 class PushMessagingInvalidationHandlerDelegate; |
| 22 | 24 |
| 23 // This class maps extension IDs to the corresponding object IDs, manages | 25 // This class maps extension IDs to the corresponding object IDs, manages |
| 24 // invalidation registrations, and dispatches callbacks for any invalidations | 26 // invalidation registrations, and dispatches callbacks for any invalidations |
| 25 // received. | 27 // received. |
| 26 class PushMessagingInvalidationHandler : public PushMessagingInvalidationMapper, | 28 class PushMessagingInvalidationHandler : public PushMessagingInvalidationMapper, |
| 27 public syncer::InvalidationHandler { | 29 public syncer::InvalidationHandler { |
| 28 public: | 30 public: |
| 29 // |service| and |delegate| must remain valid for the lifetime of this object. | 31 // |service| and |delegate| must remain valid for the lifetime of this object. |
| 30 // |extension_ids| is the set of extension IDs for which push messaging is | 32 // |extension_ids| is the set of extension IDs for which push messaging is |
| 31 // enabled. | 33 // enabled. |
| 32 PushMessagingInvalidationHandler( | 34 PushMessagingInvalidationHandler( |
| 33 InvalidationFrontend* service, | 35 invalidation::InvalidationFrontend* service, |
| 34 PushMessagingInvalidationHandlerDelegate* delegate); | 36 PushMessagingInvalidationHandlerDelegate* delegate); |
| 35 virtual ~PushMessagingInvalidationHandler(); | 37 virtual ~PushMessagingInvalidationHandler(); |
| 36 | 38 |
| 37 // PushMessagingInvalidationMapper implementation. | 39 // PushMessagingInvalidationMapper implementation. |
| 38 virtual void SuppressInitialInvalidationsForExtension( | 40 virtual void SuppressInitialInvalidationsForExtension( |
| 39 const std::string& extension_id) OVERRIDE; | 41 const std::string& extension_id) OVERRIDE; |
| 40 virtual void RegisterExtension(const std::string& extension_id) OVERRIDE; | 42 virtual void RegisterExtension(const std::string& extension_id) OVERRIDE; |
| 41 virtual void UnregisterExtension(const std::string& extension_id) OVERRIDE; | 43 virtual void UnregisterExtension(const std::string& extension_id) OVERRIDE; |
| 42 | 44 |
| 43 // InvalidationHandler implementation. | 45 // InvalidationHandler implementation. |
| 44 virtual void OnInvalidatorStateChange( | 46 virtual void OnInvalidatorStateChange( |
| 45 syncer::InvalidatorState state) OVERRIDE; | 47 syncer::InvalidatorState state) OVERRIDE; |
| 46 virtual void OnIncomingInvalidation( | 48 virtual void OnIncomingInvalidation( |
| 47 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 49 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 48 | 50 |
| 49 const std::set<std::string>& GetRegisteredExtensionsForTest() const { | 51 const std::set<std::string>& GetRegisteredExtensionsForTest() const { |
| 50 return registered_extensions_; | 52 return registered_extensions_; |
| 51 } | 53 } |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 void UpdateRegistrations(); | 56 void UpdateRegistrations(); |
| 55 | 57 |
| 56 base::ThreadChecker thread_checker_; | 58 base::ThreadChecker thread_checker_; |
| 57 InvalidationFrontend* const service_; | 59 invalidation::InvalidationFrontend* const service_; |
| 58 std::set<std::string> registered_extensions_; | 60 std::set<std::string> registered_extensions_; |
| 59 syncer::ObjectIdSet suppressed_ids_; | 61 syncer::ObjectIdSet suppressed_ids_; |
| 60 PushMessagingInvalidationHandlerDelegate* const delegate_; | 62 PushMessagingInvalidationHandlerDelegate* const delegate_; |
| 61 | 63 |
| 62 DISALLOW_COPY_AND_ASSIGN(PushMessagingInvalidationHandler); | 64 DISALLOW_COPY_AND_ASSIGN(PushMessagingInvalidationHandler); |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 } // namespace extensions | 67 } // namespace extensions |
| 66 | 68 |
| 67 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDAT
ION_HANDLER_H_ | 69 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDAT
ION_HANDLER_H_ |
| OLD | NEW |