| 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 // An implementation of SyncNotifier that wraps an invalidation | 5 // An implementation of SyncNotifier that wraps an invalidation |
| 6 // client. Handles the details of connecting to XMPP and hooking it | 6 // client. Handles the details of connecting to XMPP and hooking it |
| 7 // up to the invalidation client. | 7 // up to the invalidation client. |
| 8 // | 8 // |
| 9 // You probably don't want to use this directly; use | 9 // You probably don't want to use this directly; use |
| 10 // NonBlockingInvalidationNotifier. | 10 // NonBlockingInvalidationNotifier. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "sync/internal_api/public/syncable/model_type.h" | 23 #include "sync/internal_api/public/syncable/model_type.h" |
| 24 #include "sync/internal_api/public/util/weak_handle.h" | 24 #include "sync/internal_api/public/util/weak_handle.h" |
| 25 #include "sync/notifier/chrome_invalidation_client.h" | 25 #include "sync/notifier/chrome_invalidation_client.h" |
| 26 #include "sync/notifier/invalidation_state_tracker.h" | 26 #include "sync/notifier/invalidation_state_tracker.h" |
| 27 #include "sync/notifier/sync_notifier.h" | 27 #include "sync/notifier/sync_notifier.h" |
| 28 | 28 |
| 29 namespace notifier { | 29 namespace notifier { |
| 30 class PushClient; | 30 class PushClient; |
| 31 } // namespace notifier | 31 } // namespace notifier |
| 32 | 32 |
| 33 namespace csync { | 33 namespace syncer { |
| 34 | 34 |
| 35 // This class must live on the IO thread. | 35 // This class must live on the IO thread. |
| 36 class InvalidationNotifier | 36 class InvalidationNotifier |
| 37 : public SyncNotifier, | 37 : public SyncNotifier, |
| 38 public ChromeInvalidationClient::Listener, | 38 public ChromeInvalidationClient::Listener, |
| 39 public base::NonThreadSafe { | 39 public base::NonThreadSafe { |
| 40 public: | 40 public: |
| 41 // |invalidation_state_tracker| must be initialized. | 41 // |invalidation_state_tracker| must be initialized. |
| 42 InvalidationNotifier( | 42 InvalidationNotifier( |
| 43 scoped_ptr<notifier::PushClient> push_client, | 43 scoped_ptr<notifier::PushClient> push_client, |
| 44 const InvalidationVersionMap& initial_max_invalidation_versions, | 44 const InvalidationVersionMap& initial_max_invalidation_versions, |
| 45 const std::string& initial_invalidation_state, | 45 const std::string& initial_invalidation_state, |
| 46 const csync::WeakHandle<InvalidationStateTracker>& | 46 const syncer::WeakHandle<InvalidationStateTracker>& |
| 47 invalidation_state_tracker, | 47 invalidation_state_tracker, |
| 48 const std::string& client_info); | 48 const std::string& client_info); |
| 49 | 49 |
| 50 virtual ~InvalidationNotifier(); | 50 virtual ~InvalidationNotifier(); |
| 51 | 51 |
| 52 // SyncNotifier implementation. | 52 // SyncNotifier implementation. |
| 53 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; | 53 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; |
| 54 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; | 54 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; |
| 55 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | 55 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; |
| 56 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; | 56 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 77 STOPPED, | 77 STOPPED, |
| 78 CONNECTING, | 78 CONNECTING, |
| 79 STARTED | 79 STARTED |
| 80 }; | 80 }; |
| 81 State state_; | 81 State state_; |
| 82 | 82 |
| 83 // Passed to |invalidation_client_|. | 83 // Passed to |invalidation_client_|. |
| 84 const InvalidationVersionMap initial_max_invalidation_versions_; | 84 const InvalidationVersionMap initial_max_invalidation_versions_; |
| 85 | 85 |
| 86 // Passed to |invalidation_client_|. | 86 // Passed to |invalidation_client_|. |
| 87 const csync::WeakHandle<InvalidationStateTracker> | 87 const syncer::WeakHandle<InvalidationStateTracker> |
| 88 invalidation_state_tracker_; | 88 invalidation_state_tracker_; |
| 89 | 89 |
| 90 // Passed to |invalidation_client_|. | 90 // Passed to |invalidation_client_|. |
| 91 const std::string client_info_; | 91 const std::string client_info_; |
| 92 | 92 |
| 93 // Our observers (which must live on the same thread). | 93 // Our observers (which must live on the same thread). |
| 94 ObserverList<SyncNotifierObserver> observers_; | 94 ObserverList<SyncNotifierObserver> observers_; |
| 95 | 95 |
| 96 // The client ID to pass to |chrome_invalidation_client_|. | 96 // The client ID to pass to |chrome_invalidation_client_|. |
| 97 std::string invalidation_client_id_; | 97 std::string invalidation_client_id_; |
| 98 | 98 |
| 99 // The state to pass to |chrome_invalidation_client_|. | 99 // The state to pass to |chrome_invalidation_client_|. |
| 100 // TODO(tim): This should be made const once migration is completed for bug | 100 // TODO(tim): This should be made const once migration is completed for bug |
| 101 // 124140. | 101 // 124140. |
| 102 std::string invalidation_state_; | 102 std::string invalidation_state_; |
| 103 | 103 |
| 104 // The invalidation client. | 104 // The invalidation client. |
| 105 ChromeInvalidationClient invalidation_client_; | 105 ChromeInvalidationClient invalidation_client_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); | 107 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace csync | 110 } // namespace syncer |
| 111 | 111 |
| 112 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ | 112 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ |
| OLD | NEW |