| 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 simple wrapper around invalidation::InvalidationClient that | 5 // A simple wrapper around invalidation::InvalidationClient that |
| 6 // handles all the startup/shutdown details and hookups. | 6 // handles all the startup/shutdown details and hookups. |
| 7 | 7 |
| 8 #ifndef SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ | 8 #ifndef SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ |
| 9 #define SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ | 9 #define SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "google/cacheinvalidation/include/invalidation-listener.h" | 19 #include "google/cacheinvalidation/include/invalidation-listener.h" |
| 20 #include "jingle/notifier/listener/push_client_observer.h" | 20 #include "jingle/notifier/listener/push_client_observer.h" |
| 21 #include "sync/internal_api/public/util/weak_handle.h" | 21 #include "sync/internal_api/public/util/weak_handle.h" |
| 22 #include "sync/notifier/chrome_system_resources.h" | 22 #include "sync/notifier/chrome_system_resources.h" |
| 23 #include "sync/notifier/invalidation_state_tracker.h" | 23 #include "sync/notifier/invalidation_state_tracker.h" |
| 24 #include "sync/notifier/notifications_disabled_reason.h" | 24 #include "sync/notifier/invalidator_state.h" |
| 25 #include "sync/notifier/object_id_state_map.h" | 25 #include "sync/notifier/object_id_state_map.h" |
| 26 #include "sync/notifier/state_writer.h" | 26 #include "sync/notifier/state_writer.h" |
| 27 | 27 |
| 28 namespace buzz { | 28 namespace buzz { |
| 29 class XmppTaskParentInterface; | 29 class XmppTaskParentInterface; |
| 30 } // namespace buzz | 30 } // namespace buzz |
| 31 | 31 |
| 32 namespace notifier { | 32 namespace notifier { |
| 33 class PushClient; | 33 class PushClient; |
| 34 } // namespace notifier | 34 } // namespace notifier |
| (...skipping 16 matching lines...) Expand all Loading... |
| 51 const invalidation::string&, | 51 const invalidation::string&, |
| 52 const invalidation::string&, | 52 const invalidation::string&, |
| 53 invalidation::InvalidationListener*)> CreateInvalidationClientCallback; | 53 invalidation::InvalidationListener*)> CreateInvalidationClientCallback; |
| 54 | 54 |
| 55 class Listener { | 55 class Listener { |
| 56 public: | 56 public: |
| 57 virtual ~Listener(); | 57 virtual ~Listener(); |
| 58 | 58 |
| 59 virtual void OnInvalidate(const ObjectIdStateMap& id_state_map) = 0; | 59 virtual void OnInvalidate(const ObjectIdStateMap& id_state_map) = 0; |
| 60 | 60 |
| 61 virtual void OnNotificationsEnabled() = 0; | 61 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0; |
| 62 | |
| 63 virtual void OnNotificationsDisabled( | |
| 64 NotificationsDisabledReason reason) = 0; | |
| 65 }; | 62 }; |
| 66 | 63 |
| 67 explicit ChromeInvalidationClient( | 64 explicit ChromeInvalidationClient( |
| 68 scoped_ptr<notifier::PushClient> push_client); | 65 scoped_ptr<notifier::PushClient> push_client); |
| 69 | 66 |
| 70 // Calls Stop(). | 67 // Calls Stop(). |
| 71 virtual ~ChromeInvalidationClient(); | 68 virtual ~ChromeInvalidationClient(); |
| 72 | 69 |
| 73 // Does not take ownership of |listener| or |state_writer|. | 70 // Does not take ownership of |listener| or |state_writer|. |
| 74 // |invalidation_state_tracker| must be initialized. | 71 // |invalidation_state_tracker| must be initialized. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 virtual void OnIncomingNotification( | 125 virtual void OnIncomingNotification( |
| 129 const notifier::Notification& notification) OVERRIDE; | 126 const notifier::Notification& notification) OVERRIDE; |
| 130 | 127 |
| 131 void StopForTest(); | 128 void StopForTest(); |
| 132 | 129 |
| 133 void DoRegistrationUpdate(); | 130 void DoRegistrationUpdate(); |
| 134 | 131 |
| 135 private: | 132 private: |
| 136 void Stop(); | 133 void Stop(); |
| 137 | 134 |
| 138 NotificationsDisabledReason GetState() const; | 135 InvalidatorState GetState() const; |
| 139 | 136 |
| 140 void EmitStateChange(); | 137 void EmitStateChange(); |
| 141 | 138 |
| 142 void EmitInvalidation(const ObjectIdStateMap& id_state_map); | 139 void EmitInvalidation(const ObjectIdStateMap& id_state_map); |
| 143 | 140 |
| 144 // Owned by |chrome_system_resources_|. | 141 // Owned by |chrome_system_resources_|. |
| 145 notifier::PushClient* const push_client_; | 142 notifier::PushClient* const push_client_; |
| 146 ChromeSystemResources chrome_system_resources_; | 143 ChromeSystemResources chrome_system_resources_; |
| 147 InvalidationVersionMap max_invalidation_versions_; | 144 InvalidationVersionMap max_invalidation_versions_; |
| 148 WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; | 145 WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; |
| 149 Listener* listener_; | 146 Listener* listener_; |
| 150 scoped_ptr<invalidation::InvalidationClient> invalidation_client_; | 147 scoped_ptr<invalidation::InvalidationClient> invalidation_client_; |
| 151 scoped_ptr<RegistrationManager> registration_manager_; | 148 scoped_ptr<RegistrationManager> registration_manager_; |
| 152 // Stored to pass to |registration_manager_| on start. | 149 // Stored to pass to |registration_manager_| on start. |
| 153 ObjectIdSet registered_ids_; | 150 ObjectIdSet registered_ids_; |
| 154 | 151 |
| 155 // The states of the ticl and the push client (with | 152 // The states of the ticl and the push client. |
| 156 // NO_NOTIFICATION_ERROR meaning notifications are enabled). | 153 InvalidatorState ticl_state_; |
| 157 NotificationsDisabledReason ticl_state_; | 154 InvalidatorState push_client_state_; |
| 158 NotificationsDisabledReason push_client_state_; | |
| 159 | 155 |
| 160 DISALLOW_COPY_AND_ASSIGN(ChromeInvalidationClient); | 156 DISALLOW_COPY_AND_ASSIGN(ChromeInvalidationClient); |
| 161 }; | 157 }; |
| 162 | 158 |
| 163 } // namespace syncer | 159 } // namespace syncer |
| 164 | 160 |
| 165 #endif // SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ | 161 #endif // SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ |
| OLD | NEW |