OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // 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 SYNC_NOTIFIER_P2P_INVALIDATOR_H_ | 8 #ifndef SYNC_NOTIFIER_P2P_INVALIDATOR_H_ |
9 #define SYNC_NOTIFIER_P2P_INVALIDATOR_H_ | 9 #define SYNC_NOTIFIER_P2P_INVALIDATOR_H_ |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // Helper notification data class that can be serialized to and | 51 // Helper notification data class that can be serialized to and |
52 // deserialized from a string. | 52 // deserialized from a string. |
53 class SYNC_EXPORT_PRIVATE P2PNotificationData { | 53 class SYNC_EXPORT_PRIVATE P2PNotificationData { |
54 public: | 54 public: |
55 // Initializes with an empty sender ID, target set to NOTIFY_SELF, | 55 // Initializes with an empty sender ID, target set to NOTIFY_SELF, |
56 // and empty changed types. | 56 // and empty changed types. |
57 P2PNotificationData(); | 57 P2PNotificationData(); |
58 P2PNotificationData(const std::string& sender_id, | 58 P2PNotificationData(const std::string& sender_id, |
59 P2PNotificationTarget target, | 59 P2PNotificationTarget target, |
60 const ObjectIdInvalidationMap& invalidation_map, | 60 const ObjectIdInvalidationMap& invalidation_map); |
61 IncomingInvalidationSource source); | |
62 | 61 |
63 ~P2PNotificationData(); | 62 ~P2PNotificationData(); |
64 | 63 |
65 // Returns true if the given ID is targeted by this notification. | 64 // Returns true if the given ID is targeted by this notification. |
66 bool IsTargeted(const std::string& id) const; | 65 bool IsTargeted(const std::string& id) const; |
67 | 66 |
68 const ObjectIdInvalidationMap& GetIdInvalidationMap() const; | 67 const ObjectIdInvalidationMap& GetIdInvalidationMap() const; |
69 | 68 |
70 IncomingInvalidationSource GetSource() const; | |
71 | |
72 bool Equals(const P2PNotificationData& other) const; | 69 bool Equals(const P2PNotificationData& other) const; |
73 | 70 |
74 std::string ToString() const; | 71 std::string ToString() const; |
75 | 72 |
76 // Returns whether parsing |str| was successful. If parsing was | 73 // Returns whether parsing |str| was successful. If parsing was |
77 // unsuccessful, the state of the notification is undefined. | 74 // unsuccessful, the state of the notification is undefined. |
78 bool ResetFromString(const std::string& str); | 75 bool ResetFromString(const std::string& str); |
79 | 76 |
80 private: | 77 private: |
81 // The unique ID of the client that sent the notification. | 78 // The unique ID of the client that sent the notification. |
82 std::string sender_id_; | 79 std::string sender_id_; |
83 // The intendent recipient(s) of the notification. | 80 // The intendent recipient(s) of the notification. |
84 P2PNotificationTarget target_; | 81 P2PNotificationTarget target_; |
85 // The invalidation map for the notification. | 82 // The invalidation map for the notification. |
86 ObjectIdInvalidationMap invalidation_map_; | 83 ObjectIdInvalidationMap invalidation_map_; |
87 // The source of the invalidation. | |
88 IncomingInvalidationSource source_; | |
89 }; | 84 }; |
90 | 85 |
91 class SYNC_EXPORT_PRIVATE P2PInvalidator | 86 class SYNC_EXPORT_PRIVATE P2PInvalidator |
92 : public Invalidator, | 87 : public Invalidator, |
93 public NON_EXPORTED_BASE(notifier::PushClientObserver) { | 88 public NON_EXPORTED_BASE(notifier::PushClientObserver) { |
94 public: | 89 public: |
95 // The |send_notification_target| parameter was added to allow us to send | 90 // The |send_notification_target| parameter was added to allow us to send |
96 // self-notifications in some cases, but not others. The value should be | 91 // self-notifications in some cases, but not others. The value should be |
97 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS | 92 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS |
98 // to send notifications to all clients except for the one that triggered the | 93 // to send notifications to all clients except for the one that triggered the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 bool notifications_enabled_; | 135 bool notifications_enabled_; |
141 // Which set of clients should be sent notifications. | 136 // Which set of clients should be sent notifications. |
142 P2PNotificationTarget send_notification_target_; | 137 P2PNotificationTarget send_notification_target_; |
143 | 138 |
144 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); | 139 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); |
145 }; | 140 }; |
146 | 141 |
147 } // namespace syncer | 142 } // namespace syncer |
148 | 143 |
149 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ | 144 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ |
OLD | NEW |