OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // An invalidator that uses p2p invalidations based on XMPP push | 5 // An invalidator that uses p2p invalidations based on XMPP push |
6 // notifications. Used only for sync integration tests. | 6 // notifications. Used only for sync integration tests. |
7 | 7 |
8 #ifndef COMPONENTS_INVALIDATION_IMPL_P2P_INVALIDATOR_H_ | 8 #ifndef COMPONENTS_INVALIDATION_IMPL_P2P_INVALIDATOR_H_ |
9 #define COMPONENTS_INVALIDATION_IMPL_P2P_INVALIDATOR_H_ | 9 #define COMPONENTS_INVALIDATION_IMPL_P2P_INVALIDATOR_H_ |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // The intended recipient(s) of a P2P notification. | 37 // The intended recipient(s) of a P2P notification. |
38 enum P2PNotificationTarget { | 38 enum P2PNotificationTarget { |
39 NOTIFY_SELF, | 39 NOTIFY_SELF, |
40 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF, | 40 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF, |
41 NOTIFY_OTHERS, | 41 NOTIFY_OTHERS, |
42 NOTIFY_ALL, | 42 NOTIFY_ALL, |
43 LAST_NOTIFICATION_TARGET = NOTIFY_ALL | 43 LAST_NOTIFICATION_TARGET = NOTIFY_ALL |
44 }; | 44 }; |
45 | 45 |
46 INVALIDATION_EXPORT_PRIVATE std::string P2PNotificationTargetToString( | 46 INVALIDATION_EXPORT std::string P2PNotificationTargetToString( |
47 P2PNotificationTarget target); | 47 P2PNotificationTarget target); |
48 | 48 |
49 // If |target_str| can't be parsed, assumes NOTIFY_SELF. | 49 // If |target_str| can't be parsed, assumes NOTIFY_SELF. |
50 INVALIDATION_EXPORT_PRIVATE P2PNotificationTarget | 50 INVALIDATION_EXPORT P2PNotificationTarget |
51 P2PNotificationTargetFromString(const std::string& target_str); | 51 P2PNotificationTargetFromString(const std::string& target_str); |
52 | 52 |
53 // Helper notification data class that can be serialized to and | 53 // Helper notification data class that can be serialized to and |
54 // deserialized from a string. | 54 // deserialized from a string. |
55 class INVALIDATION_EXPORT_PRIVATE P2PNotificationData { | 55 class INVALIDATION_EXPORT P2PNotificationData { |
56 public: | 56 public: |
57 // Initializes with an empty sender ID, target set to NOTIFY_SELF, | 57 // Initializes with an empty sender ID, target set to NOTIFY_SELF, |
58 // and empty changed types. | 58 // and empty changed types. |
59 P2PNotificationData(); | 59 P2PNotificationData(); |
60 P2PNotificationData(const std::string& sender_id, | 60 P2PNotificationData(const std::string& sender_id, |
61 P2PNotificationTarget target, | 61 P2PNotificationTarget target, |
62 const ObjectIdInvalidationMap& invalidation_map); | 62 const ObjectIdInvalidationMap& invalidation_map); |
63 | 63 |
64 ~P2PNotificationData(); | 64 ~P2PNotificationData(); |
65 | 65 |
(...skipping 12 matching lines...) Expand all Loading... |
78 | 78 |
79 private: | 79 private: |
80 // The unique ID of the client that sent the notification. | 80 // The unique ID of the client that sent the notification. |
81 std::string sender_id_; | 81 std::string sender_id_; |
82 // The intendent recipient(s) of the notification. | 82 // The intendent recipient(s) of the notification. |
83 P2PNotificationTarget target_; | 83 P2PNotificationTarget target_; |
84 // The invalidation map for the notification. | 84 // The invalidation map for the notification. |
85 ObjectIdInvalidationMap invalidation_map_; | 85 ObjectIdInvalidationMap invalidation_map_; |
86 }; | 86 }; |
87 | 87 |
88 class INVALIDATION_EXPORT_PRIVATE P2PInvalidator | 88 class INVALIDATION_EXPORT P2PInvalidator |
89 : public Invalidator, | 89 : public Invalidator, |
90 public NON_EXPORTED_BASE(notifier::PushClientObserver) { | 90 public NON_EXPORTED_BASE(notifier::PushClientObserver) { |
91 public: | 91 public: |
92 // The |send_notification_target| parameter was added to allow us to send | 92 // The |send_notification_target| parameter was added to allow us to send |
93 // self-notifications in some cases, but not others. The value should be | 93 // self-notifications in some cases, but not others. The value should be |
94 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS | 94 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS |
95 // to send notifications to all clients except for the one that triggered the | 95 // to send notifications to all clients except for the one that triggered the |
96 // notification. See crbug.com/97780. | 96 // notification. See crbug.com/97780. |
97 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, | 97 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, |
98 const std::string& invalidator_client_id, | 98 const std::string& invalidator_client_id, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 bool notifications_enabled_; | 139 bool notifications_enabled_; |
140 // Which set of clients should be sent notifications. | 140 // Which set of clients should be sent notifications. |
141 P2PNotificationTarget send_notification_target_; | 141 P2PNotificationTarget send_notification_target_; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); | 143 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); |
144 }; | 144 }; |
145 | 145 |
146 } // namespace syncer | 146 } // namespace syncer |
147 | 147 |
148 #endif // COMPONENTS_INVALIDATION_IMPL_P2P_INVALIDATOR_H_ | 148 #endif // COMPONENTS_INVALIDATION_IMPL_P2P_INVALIDATOR_H_ |
OLD | NEW |