| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // A notifier that uses p2p notifications based on XMPP push | 5 // A notifier that uses p2p notifications 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_NOTIFIER_H_ | 8 #ifndef SYNC_NOTIFIER_P2P_NOTIFIER_H_ |
| 9 #define SYNC_NOTIFIER_P2P_NOTIFIER_H_ | 9 #define SYNC_NOTIFIER_P2P_NOTIFIER_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/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "jingle/notifier/listener/push_client_observer.h" | 19 #include "jingle/notifier/listener/push_client_observer.h" |
| 20 #include "sync/internal_api/public/syncable/model_type.h" | 20 #include "sync/internal_api/public/syncable/model_type.h" |
| 21 #include "sync/notifier/notifications_disabled_reason.h" |
| 21 #include "sync/notifier/sync_notifier.h" | 22 #include "sync/notifier/sync_notifier.h" |
| 22 | 23 |
| 23 namespace notifier { | 24 namespace notifier { |
| 24 class PushClient; | 25 class PushClient; |
| 25 } // namespace notifier | 26 } // namespace notifier |
| 26 | 27 |
| 27 namespace sync_notifier { | 28 namespace sync_notifier { |
| 28 | 29 |
| 29 // The channel to use for sync notifications. | 30 // The channel to use for sync notifications. |
| 30 extern const char* kSyncP2PNotificationChannel; | 31 extern const char* kSyncP2PNotificationChannel; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | 101 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; |
| 101 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; | 102 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; |
| 102 virtual void UpdateCredentials( | 103 virtual void UpdateCredentials( |
| 103 const std::string& email, const std::string& token) OVERRIDE; | 104 const std::string& email, const std::string& token) OVERRIDE; |
| 104 virtual void UpdateEnabledTypes( | 105 virtual void UpdateEnabledTypes( |
| 105 syncable::ModelTypeSet enabled_types) OVERRIDE; | 106 syncable::ModelTypeSet enabled_types) OVERRIDE; |
| 106 virtual void SendNotification( | 107 virtual void SendNotification( |
| 107 syncable::ModelTypeSet changed_types) OVERRIDE; | 108 syncable::ModelTypeSet changed_types) OVERRIDE; |
| 108 | 109 |
| 109 // PushClientObserver implementation. | 110 // PushClientObserver implementation. |
| 110 virtual void OnNotificationStateChange(bool notifications_enabled) OVERRIDE; | 111 virtual void OnNotificationsEnabled() OVERRIDE; |
| 112 virtual void OnNotificationsDisabled( |
| 113 notifier::NotificationsDisabledReason reason) OVERRIDE; |
| 111 virtual void OnIncomingNotification( | 114 virtual void OnIncomingNotification( |
| 112 const notifier::Notification& notification) OVERRIDE; | 115 const notifier::Notification& notification) OVERRIDE; |
| 113 | 116 |
| 114 void SendNotificationDataForTest( | 117 void SendNotificationDataForTest( |
| 115 const P2PNotificationData& notification_data); | 118 const P2PNotificationData& notification_data); |
| 116 | 119 |
| 117 private: | 120 private: |
| 118 void SendNotificationData(const P2PNotificationData& notification_data); | 121 void SendNotificationData(const P2PNotificationData& notification_data); |
| 119 | 122 |
| 120 base::NonThreadSafe non_thread_safe_; | 123 base::NonThreadSafe non_thread_safe_; |
| 121 | 124 |
| 122 ObserverList<SyncNotifierObserver> observer_list_; | 125 ObserverList<SyncNotifierObserver> observer_list_; |
| 123 | 126 |
| 124 // The push client. | 127 // The push client. |
| 125 scoped_ptr<notifier::PushClient> push_client_; | 128 scoped_ptr<notifier::PushClient> push_client_; |
| 126 // Our unique ID. | 129 // Our unique ID. |
| 127 std::string unique_id_; | 130 std::string unique_id_; |
| 128 // Whether we have called UpdateCredentials() yet. | 131 // Whether we have called UpdateCredentials() yet. |
| 129 bool logged_in_; | 132 bool logged_in_; |
| 130 // Whether |push_client_| has notified us that notifications are | |
| 131 // enabled. | |
| 132 bool notifications_enabled_; | 133 bool notifications_enabled_; |
| 133 // Which set of clients should be sent notifications. | 134 // Which set of clients should be sent notifications. |
| 134 P2PNotificationTarget send_notification_target_; | 135 P2PNotificationTarget send_notification_target_; |
| 135 | 136 |
| 136 syncable::ModelTypeSet enabled_types_; | 137 syncable::ModelTypeSet enabled_types_; |
| 137 }; | 138 }; |
| 138 | 139 |
| 139 } // namespace sync_notifier | 140 } // namespace sync_notifier |
| 140 | 141 |
| 141 #endif // SYNC_NOTIFIER_P2P_NOTIFIER_H_ | 142 #endif // SYNC_NOTIFIER_P2P_NOTIFIER_H_ |
| OLD | NEW |