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