| OLD | NEW |
| 1 // Copyright (c) 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 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "jingle/notifier/listener/push_client_observer.h" | 19 #include "jingle/notifier/listener/push_client_observer.h" |
| 20 #include "sync/base/sync_export.h" |
| 20 #include "sync/internal_api/public/base/model_type.h" | 21 #include "sync/internal_api/public/base/model_type.h" |
| 21 #include "sync/notifier/invalidator.h" | 22 #include "sync/notifier/invalidator.h" |
| 22 #include "sync/notifier/invalidator_registrar.h" | 23 #include "sync/notifier/invalidator_registrar.h" |
| 23 #include "sync/notifier/invalidator_state.h" | 24 #include "sync/notifier/invalidator_state.h" |
| 24 | 25 |
| 25 namespace notifier { | 26 namespace notifier { |
| 26 class PushClient; | 27 class PushClient; |
| 27 } // namespace notifier | 28 } // namespace notifier |
| 28 | 29 |
| 29 namespace syncer { | 30 namespace syncer { |
| 30 | 31 |
| 31 // The channel to use for sync notifications. | 32 // The channel to use for sync notifications. |
| 32 extern const char kSyncP2PNotificationChannel[]; | 33 SYNC_EXPORT_PRIVATE extern const char kSyncP2PNotificationChannel[]; |
| 33 | 34 |
| 34 // The intended recipient(s) of a P2P notification. | 35 // The intended recipient(s) of a P2P notification. |
| 35 enum P2PNotificationTarget { | 36 enum P2PNotificationTarget { |
| 36 NOTIFY_SELF, | 37 NOTIFY_SELF, |
| 37 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF, | 38 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF, |
| 38 NOTIFY_OTHERS, | 39 NOTIFY_OTHERS, |
| 39 NOTIFY_ALL, | 40 NOTIFY_ALL, |
| 40 LAST_NOTIFICATION_TARGET = NOTIFY_ALL | 41 LAST_NOTIFICATION_TARGET = NOTIFY_ALL |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 std::string P2PNotificationTargetToString( | 44 std::string P2PNotificationTargetToString( |
| 44 P2PNotificationTarget target); | 45 P2PNotificationTarget target); |
| 45 | 46 |
| 46 // If |target_str| can't be parsed, assumes NOTIFY_SELF. | 47 // If |target_str| can't be parsed, assumes NOTIFY_SELF. |
| 47 P2PNotificationTarget P2PNotificationTargetFromString( | 48 P2PNotificationTarget P2PNotificationTargetFromString( |
| 48 const std::string& target_str); | 49 const std::string& target_str); |
| 49 | 50 |
| 50 // Helper notification data class that can be serialized to and | 51 // Helper notification data class that can be serialized to and |
| 51 // deserialized from a string. | 52 // deserialized from a string. |
| 52 class P2PNotificationData { | 53 class SYNC_EXPORT_PRIVATE P2PNotificationData { |
| 53 public: | 54 public: |
| 54 // Initializes with an empty sender ID, target set to NOTIFY_SELF, | 55 // Initializes with an empty sender ID, target set to NOTIFY_SELF, |
| 55 // and empty changed types. | 56 // and empty changed types. |
| 56 P2PNotificationData(); | 57 P2PNotificationData(); |
| 57 P2PNotificationData(const std::string& sender_id, | 58 P2PNotificationData(const std::string& sender_id, |
| 58 P2PNotificationTarget target, | 59 P2PNotificationTarget target, |
| 59 const ObjectIdInvalidationMap& invalidation_map, | 60 const ObjectIdInvalidationMap& invalidation_map, |
| 60 IncomingInvalidationSource source); | 61 IncomingInvalidationSource source); |
| 61 | 62 |
| 62 ~P2PNotificationData(); | 63 ~P2PNotificationData(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 bool notifications_enabled_; | 140 bool notifications_enabled_; |
| 140 // Which set of clients should be sent notifications. | 141 // Which set of clients should be sent notifications. |
| 141 P2PNotificationTarget send_notification_target_; | 142 P2PNotificationTarget send_notification_target_; |
| 142 | 143 |
| 143 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); | 144 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 } // namespace syncer | 147 } // namespace syncer |
| 147 | 148 |
| 148 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ | 149 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ |
| OLD | NEW |