| 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. |
| 11 | 11 |
| 12 #ifndef SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ | 12 #ifndef SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ |
| 13 #define SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ | 13 #define SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ |
| 14 #pragma once | 14 #pragma once |
| 15 | 15 |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 19 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
| 20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/observer_list.h" | |
| 22 #include "base/threading/non_thread_safe.h" | 21 #include "base/threading/non_thread_safe.h" |
| 23 #include "sync/internal_api/public/base/model_type.h" | 22 #include "sync/internal_api/public/base/model_type.h" |
| 24 #include "sync/internal_api/public/util/weak_handle.h" | 23 #include "sync/internal_api/public/util/weak_handle.h" |
| 25 #include "sync/notifier/chrome_invalidation_client.h" | 24 #include "sync/notifier/chrome_invalidation_client.h" |
| 25 #include "sync/notifier/invalidation_notifier_base.h" |
| 26 #include "sync/notifier/invalidation_state_tracker.h" | 26 #include "sync/notifier/invalidation_state_tracker.h" |
| 27 #include "sync/notifier/sync_notifier.h" | |
| 28 | 27 |
| 29 namespace notifier { | 28 namespace notifier { |
| 30 class PushClient; | 29 class PushClient; |
| 31 } // namespace notifier | 30 } // namespace notifier |
| 32 | 31 |
| 33 namespace syncer { | 32 namespace syncer { |
| 34 | 33 |
| 35 // This class must live on the IO thread. | 34 // This class must live on the IO thread. |
| 36 class InvalidationNotifier | 35 class InvalidationNotifier |
| 37 : public SyncNotifier, | 36 : public InvalidationNotifierBase, |
| 38 public ChromeInvalidationClient::Listener, | 37 public ChromeInvalidationClient::Listener, |
| 39 public base::NonThreadSafe { | 38 public base::NonThreadSafe { |
| 40 public: | 39 public: |
| 41 // |invalidation_state_tracker| must be initialized. | 40 // |invalidation_state_tracker| must be initialized. |
| 42 InvalidationNotifier( | 41 InvalidationNotifier( |
| 43 scoped_ptr<notifier::PushClient> push_client, | 42 scoped_ptr<notifier::PushClient> push_client, |
| 44 const InvalidationVersionMap& initial_max_invalidation_versions, | 43 const InvalidationVersionMap& initial_max_invalidation_versions, |
| 45 const std::string& initial_invalidation_state, | 44 const std::string& initial_invalidation_state, |
| 46 const syncer::WeakHandle<InvalidationStateTracker>& | 45 const syncer::WeakHandle<InvalidationStateTracker>& |
| 47 invalidation_state_tracker, | 46 invalidation_state_tracker, |
| 48 const std::string& client_info); | 47 const std::string& client_info); |
| 49 | 48 |
| 50 virtual ~InvalidationNotifier(); | 49 virtual ~InvalidationNotifier(); |
| 51 | 50 |
| 52 // SyncNotifier implementation. | 51 // SyncNotifier implementation. |
| 53 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; | 52 virtual void AddHandler(SyncNotifierObserver* observer) OVERRIDE; |
| 54 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; | 53 virtual void RemoveHandler(SyncNotifierObserver* observer) OVERRIDE; |
| 54 virtual void ReloadHandlers() 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; |
| 57 virtual void UpdateCredentials( | 57 virtual void UpdateCredentials( |
| 58 const std::string& email, const std::string& token) OVERRIDE; | 58 const std::string& email, const std::string& token) OVERRIDE; |
| 59 virtual void UpdateEnabledTypes( | |
| 60 syncer::ModelTypeSet enabled_types) OVERRIDE; | |
| 61 virtual void SendNotification( | 59 virtual void SendNotification( |
| 62 syncer::ModelTypeSet changed_types) OVERRIDE; | 60 syncer::ModelTypeSet changed_types) OVERRIDE; |
| 63 | 61 |
| 64 // ChromeInvalidationClient::Listener implementation. | 62 // ChromeInvalidationClient::Listener implementation. |
| 65 virtual void OnInvalidate(const ObjectIdPayloadMap& id_payloads) OVERRIDE; | 63 virtual void OnInvalidate(const ObjectIdPayloadMap& id_payloads) OVERRIDE; |
| 66 virtual void OnNotificationsEnabled() OVERRIDE; | 64 virtual void OnNotificationsEnabled() OVERRIDE; |
| 67 virtual void OnNotificationsDisabled( | 65 virtual void OnNotificationsDisabled( |
| 68 NotificationsDisabledReason reason) OVERRIDE; | 66 NotificationsDisabledReason reason) OVERRIDE; |
| 69 | 67 |
| 70 private: | 68 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 82 // Passed to |invalidation_client_|. | 80 // Passed to |invalidation_client_|. |
| 83 const InvalidationVersionMap initial_max_invalidation_versions_; | 81 const InvalidationVersionMap initial_max_invalidation_versions_; |
| 84 | 82 |
| 85 // Passed to |invalidation_client_|. | 83 // Passed to |invalidation_client_|. |
| 86 const syncer::WeakHandle<InvalidationStateTracker> | 84 const syncer::WeakHandle<InvalidationStateTracker> |
| 87 invalidation_state_tracker_; | 85 invalidation_state_tracker_; |
| 88 | 86 |
| 89 // Passed to |invalidation_client_|. | 87 // Passed to |invalidation_client_|. |
| 90 const std::string client_info_; | 88 const std::string client_info_; |
| 91 | 89 |
| 92 // Our observers (which must live on the same thread). | |
| 93 ObserverList<SyncNotifierObserver> observers_; | |
| 94 | |
| 95 // The client ID to pass to |chrome_invalidation_client_|. | 90 // The client ID to pass to |chrome_invalidation_client_|. |
| 96 std::string invalidation_client_id_; | 91 std::string invalidation_client_id_; |
| 97 | 92 |
| 98 // The state to pass to |chrome_invalidation_client_|. | 93 // The state to pass to |chrome_invalidation_client_|. |
| 99 // TODO(tim): This should be made const once migration is completed for bug | 94 // TODO(tim): This should be made const once migration is completed for bug |
| 100 // 124140. | 95 // 124140. |
| 101 std::string invalidation_state_; | 96 std::string invalidation_state_; |
| 102 | 97 |
| 103 // The invalidation client. | 98 // The invalidation client. |
| 104 ChromeInvalidationClient invalidation_client_; | 99 ChromeInvalidationClient invalidation_client_; |
| 105 | 100 |
| 106 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); | 101 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); |
| 107 }; | 102 }; |
| 108 | 103 |
| 109 } // namespace syncer | 104 } // namespace syncer |
| 110 | 105 |
| 111 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ | 106 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ |
| OLD | NEW |