OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
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_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 #include <string> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/compiler_specific.h" | |
14 #include "base/threading/thread_checker.h" | |
15 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_mapper.h" | |
16 #include "components/invalidation/invalidation_handler.h" | |
17 #include "components/invalidation/invalidation_util.h" | |
18 | |
19 namespace invalidation { | |
20 class InvalidationService; | |
21 } | |
22 | |
23 namespace extensions { | |
24 | |
25 class PushMessagingInvalidationHandlerDelegate; | |
26 | |
27 // This class maps extension IDs to the corresponding object IDs, manages | |
28 // invalidation registrations, and dispatches callbacks for any invalidations | |
29 // received. | |
30 class PushMessagingInvalidationHandler : public PushMessagingInvalidationMapper, | |
31 public syncer::InvalidationHandler { | |
32 public: | |
33 // |service| and |delegate| must remain valid for the lifetime of this object. | |
34 // |extension_ids| is the set of extension IDs for which push messaging is | |
35 // enabled. | |
36 PushMessagingInvalidationHandler( | |
37 invalidation::InvalidationService* service, | |
38 PushMessagingInvalidationHandlerDelegate* delegate); | |
39 ~PushMessagingInvalidationHandler() override; | |
40 | |
41 // PushMessagingInvalidationMapper implementation. | |
42 void SuppressInitialInvalidationsForExtension( | |
43 const std::string& extension_id) override; | |
44 void RegisterExtension(const std::string& extension_id) override; | |
45 void UnregisterExtension(const std::string& extension_id) override; | |
46 | |
47 // InvalidationHandler implementation. | |
48 void OnInvalidatorStateChange(syncer::InvalidatorState state) override; | |
49 void OnIncomingInvalidation( | |
50 const syncer::ObjectIdInvalidationMap& invalidation_map) override; | |
51 std::string GetOwnerName() const override; | |
52 | |
53 const std::set<std::string>& GetRegisteredExtensionsForTest() const { | |
54 return registered_extensions_; | |
55 } | |
56 | |
57 private: | |
58 void UpdateRegistrations(); | |
59 | |
60 base::ThreadChecker thread_checker_; | |
61 invalidation::InvalidationService* const service_; | |
62 std::set<std::string> registered_extensions_; | |
63 syncer::ObjectIdSet suppressed_ids_; | |
64 PushMessagingInvalidationHandlerDelegate* const delegate_; | |
65 std::map<invalidation::ObjectId, | |
66 int64, | |
67 syncer::ObjectIdLessThan> max_object_version_map_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(PushMessagingInvalidationHandler); | |
70 }; | |
71 | |
72 } // namespace extensions | |
73 | |
74 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDAT
ION_HANDLER_H_ | |
OLD | NEW |