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 12 matching lines...) Expand all Loading... |
23 #include "sync/notifier/invalidator_registrar.h" | 23 #include "sync/notifier/invalidator_registrar.h" |
24 #include "sync/notifier/invalidator_state.h" | 24 #include "sync/notifier/invalidator_state.h" |
25 | 25 |
26 namespace notifier { | 26 namespace notifier { |
27 class PushClient; | 27 class PushClient; |
28 } // namespace notifier | 28 } // namespace notifier |
29 | 29 |
30 namespace syncer { | 30 namespace syncer { |
31 | 31 |
32 // The channel to use for sync notifications. | 32 // The channel to use for sync notifications. |
33 SYNC_EXPORT_PRIVATE extern const char kSyncP2PNotificationChannel[]; | 33 SYNC_EXPORT extern const char kSyncP2PNotificationChannel[]; |
34 | 34 |
35 // The intended recipient(s) of a P2P notification. | 35 // The intended recipient(s) of a P2P notification. |
36 enum P2PNotificationTarget { | 36 enum P2PNotificationTarget { |
37 NOTIFY_SELF, | 37 NOTIFY_SELF, |
38 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF, | 38 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF, |
39 NOTIFY_OTHERS, | 39 NOTIFY_OTHERS, |
40 NOTIFY_ALL, | 40 NOTIFY_ALL, |
41 LAST_NOTIFICATION_TARGET = NOTIFY_ALL | 41 LAST_NOTIFICATION_TARGET = NOTIFY_ALL |
42 }; | 42 }; |
43 | 43 |
44 std::string P2PNotificationTargetToString( | 44 SYNC_EXPORT_PRIVATE std::string P2PNotificationTargetToString( |
45 P2PNotificationTarget target); | 45 P2PNotificationTarget target); |
46 | 46 |
47 // If |target_str| can't be parsed, assumes NOTIFY_SELF. | 47 // If |target_str| can't be parsed, assumes NOTIFY_SELF. |
48 P2PNotificationTarget P2PNotificationTargetFromString( | 48 SYNC_EXPORT_PRIVATE P2PNotificationTarget P2PNotificationTargetFromString( |
49 const std::string& target_str); | 49 const std::string& target_str); |
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, |
(...skipping 22 matching lines...) Expand all Loading... |
81 // The unique ID of the client that sent the notification. | 81 // The unique ID of the client that sent the notification. |
82 std::string sender_id_; | 82 std::string sender_id_; |
83 // The intendent recipient(s) of the notification. | 83 // The intendent recipient(s) of the notification. |
84 P2PNotificationTarget target_; | 84 P2PNotificationTarget target_; |
85 // The invalidation map for the notification. | 85 // The invalidation map for the notification. |
86 ObjectIdInvalidationMap invalidation_map_; | 86 ObjectIdInvalidationMap invalidation_map_; |
87 // The source of the invalidation. | 87 // The source of the invalidation. |
88 IncomingInvalidationSource source_; | 88 IncomingInvalidationSource source_; |
89 }; | 89 }; |
90 | 90 |
91 class P2PInvalidator : public Invalidator, | 91 class SYNC_EXPORT_PRIVATE P2PInvalidator |
92 public notifier::PushClientObserver { | 92 : public Invalidator, |
| 93 public NON_EXPORTED_BASE(notifier::PushClientObserver) { |
93 public: | 94 public: |
94 // The |send_notification_target| parameter was added to allow us to send | 95 // The |send_notification_target| parameter was added to allow us to send |
95 // self-notifications in some cases, but not others. The value should be | 96 // self-notifications in some cases, but not others. The value should be |
96 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS | 97 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS |
97 // to send notifications to all clients except for the one that triggered the | 98 // to send notifications to all clients except for the one that triggered the |
98 // notification. See crbug.com/97780. | 99 // notification. See crbug.com/97780. |
99 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, | 100 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, |
100 P2PNotificationTarget send_notification_target); | 101 P2PNotificationTarget send_notification_target); |
101 | 102 |
102 virtual ~P2PInvalidator(); | 103 virtual ~P2PInvalidator(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 bool notifications_enabled_; | 141 bool notifications_enabled_; |
141 // Which set of clients should be sent notifications. | 142 // Which set of clients should be sent notifications. |
142 P2PNotificationTarget send_notification_target_; | 143 P2PNotificationTarget send_notification_target_; |
143 | 144 |
144 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); | 145 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); |
145 }; | 146 }; |
146 | 147 |
147 } // namespace syncer | 148 } // namespace syncer |
148 | 149 |
149 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ | 150 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ |
OLD | NEW |