| 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 // 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_SYNC_INVALIDATION_LISTENER_H_ | 8 #ifndef SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_ |
| 9 #define SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_ | 9 #define SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_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 "sync/base/sync_export.h" | 20 #include "sync/base/sync_export.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/ack_handler.h" | 22 #include "sync/notifier/ack_handler.h" |
| 23 #include "sync/notifier/invalidation_state_tracker.h" | 23 #include "sync/notifier/invalidation_state_tracker.h" |
| 24 #include "sync/notifier/invalidator_state.h" | 24 #include "sync/notifier/invalidator_state.h" |
| 25 #include "sync/notifier/push_client_channel.h" | |
| 26 #include "sync/notifier/state_writer.h" | 25 #include "sync/notifier/state_writer.h" |
| 27 #include "sync/notifier/sync_system_resources.h" | 26 #include "sync/notifier/sync_system_resources.h" |
| 28 #include "sync/notifier/unacked_invalidation_set.h" | 27 #include "sync/notifier/unacked_invalidation_set.h" |
| 29 | 28 |
| 30 namespace buzz { | 29 namespace buzz { |
| 31 class XmppTaskParentInterface; | 30 class XmppTaskParentInterface; |
| 32 } // namespace buzz | 31 } // namespace buzz |
| 33 | 32 |
| 34 namespace notifier { | 33 namespace notifier { |
| 35 class PushClient; | 34 class PushClient; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 60 public: | 59 public: |
| 61 virtual ~Delegate(); | 60 virtual ~Delegate(); |
| 62 | 61 |
| 63 virtual void OnInvalidate( | 62 virtual void OnInvalidate( |
| 64 const ObjectIdInvalidationMap& invalidations) = 0; | 63 const ObjectIdInvalidationMap& invalidations) = 0; |
| 65 | 64 |
| 66 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0; | 65 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0; |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 explicit SyncInvalidationListener( | 68 explicit SyncInvalidationListener( |
| 70 scoped_ptr<notifier::PushClient> push_client); | 69 scoped_ptr<SyncNetworkChannel> network_channel); |
| 71 | 70 |
| 72 // Calls Stop(). | 71 // Calls Stop(). |
| 73 virtual ~SyncInvalidationListener(); | 72 virtual ~SyncInvalidationListener(); |
| 74 | 73 |
| 75 // Does not take ownership of |delegate| or |state_writer|. | 74 // Does not take ownership of |delegate| or |state_writer|. |
| 76 // |invalidation_state_tracker| must be initialized. | 75 // |invalidation_state_tracker| must be initialized. |
| 77 void Start( | 76 void Start( |
| 78 const CreateInvalidationClientCallback& | 77 const CreateInvalidationClientCallback& |
| 79 create_invalidation_client_callback, | 78 create_invalidation_client_callback, |
| 80 const std::string& client_id, const std::string& client_info, | 79 const std::string& client_id, const std::string& client_info, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // This call isn't synchronous so we can't guarantee these invalidations will | 159 // This call isn't synchronous so we can't guarantee these invalidations will |
| 161 // be safely on disk by the end of the call, but it should ensure that the | 160 // be safely on disk by the end of the call, but it should ensure that the |
| 162 // data makes it to disk eventually. | 161 // data makes it to disk eventually. |
| 163 void SaveInvalidations(const ObjectIdInvalidationMap& to_save); | 162 void SaveInvalidations(const ObjectIdInvalidationMap& to_save); |
| 164 | 163 |
| 165 // Emits previously saved invalidations to their registered observers. | 164 // Emits previously saved invalidations to their registered observers. |
| 166 void EmitSavedInvalidations(const ObjectIdInvalidationMap& to_emit); | 165 void EmitSavedInvalidations(const ObjectIdInvalidationMap& to_emit); |
| 167 | 166 |
| 168 WeakHandle<AckHandler> GetThisAsAckHandler(); | 167 WeakHandle<AckHandler> GetThisAsAckHandler(); |
| 169 | 168 |
| 170 PushClientChannel push_client_channel_; | 169 scoped_ptr<SyncNetworkChannel> sync_network_channel_; |
| 171 SyncSystemResources sync_system_resources_; | 170 SyncSystemResources sync_system_resources_; |
| 172 UnackedInvalidationsMap unacked_invalidations_map_; | 171 UnackedInvalidationsMap unacked_invalidations_map_; |
| 173 WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; | 172 WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; |
| 174 Delegate* delegate_; | 173 Delegate* delegate_; |
| 175 scoped_ptr<invalidation::InvalidationClient> invalidation_client_; | 174 scoped_ptr<invalidation::InvalidationClient> invalidation_client_; |
| 176 scoped_ptr<RegistrationManager> registration_manager_; | 175 scoped_ptr<RegistrationManager> registration_manager_; |
| 177 // Stored to pass to |registration_manager_| on start. | 176 // Stored to pass to |registration_manager_| on start. |
| 178 ObjectIdSet registered_ids_; | 177 ObjectIdSet registered_ids_; |
| 179 | 178 |
| 180 // The states of the ticl and the push client. | 179 // The states of the ticl and the push client. |
| 181 InvalidatorState ticl_state_; | 180 InvalidatorState ticl_state_; |
| 182 InvalidatorState push_client_state_; | 181 InvalidatorState push_client_state_; |
| 183 | 182 |
| 184 base::WeakPtrFactory<SyncInvalidationListener> weak_ptr_factory_; | 183 base::WeakPtrFactory<SyncInvalidationListener> weak_ptr_factory_; |
| 185 | 184 |
| 186 DISALLOW_COPY_AND_ASSIGN(SyncInvalidationListener); | 185 DISALLOW_COPY_AND_ASSIGN(SyncInvalidationListener); |
| 187 }; | 186 }; |
| 188 | 187 |
| 189 } // namespace syncer | 188 } // namespace syncer |
| 190 | 189 |
| 191 #endif // SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_ | 190 #endif // SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_ |
| OLD | NEW |