| 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 24 matching lines...) Expand all Loading... |
| 35 class InvalidationNotifier | 35 class InvalidationNotifier |
| 36 : public SyncNotifier, | 36 : public SyncNotifier, |
| 37 public ChromeInvalidationClient::Listener, | 37 public ChromeInvalidationClient::Listener, |
| 38 public base::NonThreadSafe { | 38 public base::NonThreadSafe { |
| 39 public: | 39 public: |
| 40 // |invalidation_state_tracker| must be initialized. | 40 // |invalidation_state_tracker| must be initialized. |
| 41 InvalidationNotifier( | 41 InvalidationNotifier( |
| 42 scoped_ptr<notifier::PushClient> push_client, | 42 scoped_ptr<notifier::PushClient> push_client, |
| 43 const InvalidationVersionMap& initial_max_invalidation_versions, | 43 const InvalidationVersionMap& initial_max_invalidation_versions, |
| 44 const std::string& initial_invalidation_state, | 44 const std::string& initial_invalidation_state, |
| 45 const syncer::WeakHandle<InvalidationStateTracker>& | 45 const WeakHandle<InvalidationStateTracker>& |
| 46 invalidation_state_tracker, | 46 invalidation_state_tracker, |
| 47 const std::string& client_info); | 47 const std::string& client_info); |
| 48 | 48 |
| 49 virtual ~InvalidationNotifier(); | 49 virtual ~InvalidationNotifier(); |
| 50 | 50 |
| 51 // SyncNotifier implementation. | 51 // SyncNotifier implementation. |
| 52 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; | 52 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; |
| 53 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; | 53 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; |
| 54 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | 54 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; |
| 55 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; | 55 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; |
| 56 virtual void UpdateCredentials( | 56 virtual void UpdateCredentials( |
| 57 const std::string& email, const std::string& token) OVERRIDE; | 57 const std::string& email, const std::string& token) OVERRIDE; |
| 58 virtual void UpdateEnabledTypes( | 58 virtual void UpdateEnabledTypes(ModelTypeSet enabled_types) OVERRIDE; |
| 59 syncer::ModelTypeSet enabled_types) OVERRIDE; | 59 virtual void SendNotification(ModelTypeSet changed_types) OVERRIDE; |
| 60 virtual void SendNotification( | |
| 61 syncer::ModelTypeSet changed_types) OVERRIDE; | |
| 62 | 60 |
| 63 // ChromeInvalidationClient::Listener implementation. | 61 // ChromeInvalidationClient::Listener implementation. |
| 64 virtual void OnInvalidate(const ObjectIdPayloadMap& id_payloads) OVERRIDE; | 62 virtual void OnInvalidate(const ObjectIdPayloadMap& id_payloads) OVERRIDE; |
| 65 virtual void OnNotificationsEnabled() OVERRIDE; | 63 virtual void OnNotificationsEnabled() OVERRIDE; |
| 66 virtual void OnNotificationsDisabled( | 64 virtual void OnNotificationsDisabled( |
| 67 NotificationsDisabledReason reason) OVERRIDE; | 65 NotificationsDisabledReason reason) OVERRIDE; |
| 68 | 66 |
| 69 private: | 67 private: |
| 70 // We start off in the STOPPED state. When we get our initial | 68 // We start off in the STOPPED state. When we get our initial |
| 71 // credentials, we connect and move to the CONNECTING state. When | 69 // credentials, we connect and move to the CONNECTING state. When |
| 72 // we're connected we start the invalidation client and move to the | 70 // we're connected we start the invalidation client and move to the |
| 73 // STARTED state. We never go back to a previous state. | 71 // STARTED state. We never go back to a previous state. |
| 74 enum State { | 72 enum State { |
| 75 STOPPED, | 73 STOPPED, |
| 76 CONNECTING, | 74 CONNECTING, |
| 77 STARTED | 75 STARTED |
| 78 }; | 76 }; |
| 79 State state_; | 77 State state_; |
| 80 | 78 |
| 81 // Passed to |invalidation_client_|. | 79 // Passed to |invalidation_client_|. |
| 82 const InvalidationVersionMap initial_max_invalidation_versions_; | 80 const InvalidationVersionMap initial_max_invalidation_versions_; |
| 83 | 81 |
| 84 // Passed to |invalidation_client_|. | 82 // Passed to |invalidation_client_|. |
| 85 const syncer::WeakHandle<InvalidationStateTracker> | 83 const WeakHandle<InvalidationStateTracker> |
| 86 invalidation_state_tracker_; | 84 invalidation_state_tracker_; |
| 87 | 85 |
| 88 // Passed to |invalidation_client_|. | 86 // Passed to |invalidation_client_|. |
| 89 const std::string client_info_; | 87 const std::string client_info_; |
| 90 | 88 |
| 91 // Our observers (which must live on the same thread). | 89 // Our observers (which must live on the same thread). |
| 92 ObserverList<SyncNotifierObserver> observers_; | 90 ObserverList<SyncNotifierObserver> observers_; |
| 93 | 91 |
| 94 // The client ID to pass to |chrome_invalidation_client_|. | 92 // The client ID to pass to |chrome_invalidation_client_|. |
| 95 std::string invalidation_client_id_; | 93 std::string invalidation_client_id_; |
| 96 | 94 |
| 97 // The state to pass to |chrome_invalidation_client_|. | 95 // The state to pass to |chrome_invalidation_client_|. |
| 98 // TODO(tim): This should be made const once migration is completed for bug | 96 // TODO(tim): This should be made const once migration is completed for bug |
| 99 // 124140. | 97 // 124140. |
| 100 std::string invalidation_state_; | 98 std::string invalidation_state_; |
| 101 | 99 |
| 102 // The invalidation client. | 100 // The invalidation client. |
| 103 ChromeInvalidationClient invalidation_client_; | 101 ChromeInvalidationClient invalidation_client_; |
| 104 | 102 |
| 105 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); | 103 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); |
| 106 }; | 104 }; |
| 107 | 105 |
| 108 } // namespace syncer | 106 } // namespace syncer |
| 109 | 107 |
| 110 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ | 108 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ |
| OLD | NEW |