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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 class SYNC_EXPORT_PRIVATE P2PInvalidator | 86 class SYNC_EXPORT_PRIVATE P2PInvalidator |
87 : public Invalidator, | 87 : public Invalidator, |
88 public NON_EXPORTED_BASE(notifier::PushClientObserver) { | 88 public NON_EXPORTED_BASE(notifier::PushClientObserver) { |
89 public: | 89 public: |
90 // 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 |
91 // 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 |
92 // 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 |
93 // 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 |
94 // notification. See crbug.com/97780. | 94 // notification. See crbug.com/97780. |
95 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, | 95 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, |
| 96 const std::string& invalidator_client_id, |
96 P2PNotificationTarget send_notification_target); | 97 P2PNotificationTarget send_notification_target); |
97 | 98 |
98 virtual ~P2PInvalidator(); | 99 virtual ~P2PInvalidator(); |
99 | 100 |
100 // Invalidator implementation. | 101 // Invalidator implementation. |
101 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; | 102 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; |
102 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | 103 virtual void UpdateRegisteredIds(InvalidationHandler* handler, |
103 const ObjectIdSet& ids) OVERRIDE; | 104 const ObjectIdSet& ids) OVERRIDE; |
104 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; | 105 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; |
105 virtual void Acknowledge(const invalidation::ObjectId& id, | 106 virtual void Acknowledge(const invalidation::ObjectId& id, |
106 const AckHandle& ack_handle) OVERRIDE; | 107 const AckHandle& ack_handle) OVERRIDE; |
107 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; | 108 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; |
108 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | |
109 virtual void UpdateCredentials( | 109 virtual void UpdateCredentials( |
110 const std::string& email, const std::string& token) OVERRIDE; | 110 const std::string& email, const std::string& token) OVERRIDE; |
111 virtual void SendInvalidation( | 111 virtual void SendInvalidation( |
112 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 112 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
113 | 113 |
114 // PushClientObserver implementation. | 114 // PushClientObserver implementation. |
115 virtual void OnNotificationsEnabled() OVERRIDE; | 115 virtual void OnNotificationsEnabled() OVERRIDE; |
116 virtual void OnNotificationsDisabled( | 116 virtual void OnNotificationsDisabled( |
117 notifier::NotificationsDisabledReason reason) OVERRIDE; | 117 notifier::NotificationsDisabledReason reason) OVERRIDE; |
118 virtual void OnIncomingNotification( | 118 virtual void OnIncomingNotification( |
119 const notifier::Notification& notification) OVERRIDE; | 119 const notifier::Notification& notification) OVERRIDE; |
120 | 120 |
121 void SendNotificationDataForTest( | 121 void SendNotificationDataForTest( |
122 const P2PNotificationData& notification_data); | 122 const P2PNotificationData& notification_data); |
123 | 123 |
124 private: | 124 private: |
125 void SendNotificationData(const P2PNotificationData& notification_data); | 125 void SendNotificationData(const P2PNotificationData& notification_data); |
126 | 126 |
127 base::ThreadChecker thread_checker_; | 127 base::ThreadChecker thread_checker_; |
128 | 128 |
129 InvalidatorRegistrar registrar_; | 129 InvalidatorRegistrar registrar_; |
130 | 130 |
131 // The push client. | 131 // The push client. |
132 scoped_ptr<notifier::PushClient> push_client_; | 132 scoped_ptr<notifier::PushClient> push_client_; |
133 // Our unique ID. | 133 // Our unique ID. |
134 std::string unique_id_; | 134 std::string invalidator_client_id_; |
135 // Whether we have called UpdateCredentials() yet. | 135 // Whether we have called UpdateCredentials() yet. |
136 bool logged_in_; | 136 bool logged_in_; |
137 bool notifications_enabled_; | 137 bool notifications_enabled_; |
138 // Which set of clients should be sent notifications. | 138 // Which set of clients should be sent notifications. |
139 P2PNotificationTarget send_notification_target_; | 139 P2PNotificationTarget send_notification_target_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); | 141 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); |
142 }; | 142 }; |
143 | 143 |
144 } // namespace syncer | 144 } // namespace syncer |
145 | 145 |
146 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ | 146 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ |
OLD | NEW |