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 Invalidator that wraps an invalidation | 5 // An implementation of Invalidator 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 // NonBlockingInvalidator. |
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 | 14 |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
(...skipping 13 matching lines...) Expand all Loading... |
34 // This class must live on the IO thread. | 34 // This class must live on the IO thread. |
35 // TODO(dcheng): Think of a name better than InvalidationInvalidator. | 35 // TODO(dcheng): Think of a name better than InvalidationInvalidator. |
36 class InvalidationNotifier | 36 class InvalidationNotifier |
37 : public Invalidator, | 37 : public Invalidator, |
38 public SyncInvalidationListener::Delegate, | 38 public SyncInvalidationListener::Delegate, |
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 InvalidationStateMap& initial_invalidation_state_map, |
45 const std::string& invalidation_bootstrap_data, | 45 const std::string& invalidation_bootstrap_data, |
46 const WeakHandle<InvalidationStateTracker>& | 46 const 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 // Invalidator implementation. | 52 // Invalidator implementation. |
53 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; | 53 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; |
54 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | 54 virtual void UpdateRegisteredIds(InvalidationHandler* handler, |
55 const ObjectIdSet& ids) OVERRIDE; | 55 const ObjectIdSet& ids) OVERRIDE; |
56 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; | 56 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; |
| 57 virtual void Acknowledge(const invalidation::ObjectId& id, |
| 58 const AckHandle& ack_handle) OVERRIDE; |
57 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; | 59 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; |
58 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | 60 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; |
59 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; | 61 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; |
60 virtual void UpdateCredentials( | 62 virtual void UpdateCredentials( |
61 const std::string& email, const std::string& token) OVERRIDE; | 63 const std::string& email, const std::string& token) OVERRIDE; |
62 virtual void SendInvalidation( | 64 virtual void SendInvalidation( |
63 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 65 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
64 | 66 |
65 // SyncInvalidationListener::Delegate implementation. | 67 // SyncInvalidationListener::Delegate implementation. |
66 virtual void OnInvalidate( | 68 virtual void OnInvalidate( |
67 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 69 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
68 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | 70 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; |
69 | 71 |
70 private: | 72 private: |
71 // We start off in the STOPPED state. When we get our initial | 73 // We start off in the STOPPED state. When we get our initial |
72 // credentials, we connect and move to the CONNECTING state. When | 74 // credentials, we connect and move to the CONNECTING state. When |
73 // we're connected we start the invalidation client and move to the | 75 // we're connected we start the invalidation client and move to the |
74 // STARTED state. We never go back to a previous state. | 76 // STARTED state. We never go back to a previous state. |
75 enum State { | 77 enum State { |
76 STOPPED, | 78 STOPPED, |
77 CONNECTING, | 79 CONNECTING, |
78 STARTED | 80 STARTED |
79 }; | 81 }; |
80 State state_; | 82 State state_; |
81 | 83 |
82 InvalidatorRegistrar registrar_; | 84 InvalidatorRegistrar registrar_; |
83 | 85 |
84 // Passed to |invalidation_listener_|. | 86 // Passed to |invalidation_listener_|. |
85 const InvalidationVersionMap initial_max_invalidation_versions_; | 87 const InvalidationStateMap initial_invalidation_state_map_; |
86 | 88 |
87 // Passed to |invalidation_listener_|. | 89 // Passed to |invalidation_listener_|. |
88 const WeakHandle<InvalidationStateTracker> | 90 const WeakHandle<InvalidationStateTracker> |
89 invalidation_state_tracker_; | 91 invalidation_state_tracker_; |
90 | 92 |
91 // Passed to |invalidation_listener_|. | 93 // Passed to |invalidation_listener_|. |
92 const std::string client_info_; | 94 const std::string client_info_; |
93 | 95 |
94 // The client ID to pass to |invalidation_listener_|. | 96 // The client ID to pass to |invalidation_listener_|. |
95 std::string client_id_; | 97 std::string client_id_; |
96 | 98 |
97 // The initial bootstrap data to pass to |invalidation_listener_|. | 99 // The initial bootstrap data to pass to |invalidation_listener_|. |
98 // 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 |
99 // 124140. | 101 // 124140. |
100 std::string invalidation_bootstrap_data_; | 102 std::string invalidation_bootstrap_data_; |
101 | 103 |
102 // The invalidation listener. | 104 // The invalidation listener. |
103 SyncInvalidationListener invalidation_listener_; | 105 SyncInvalidationListener invalidation_listener_; |
104 | 106 |
105 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); | 107 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); |
106 }; | 108 }; |
107 | 109 |
108 } // namespace syncer | 110 } // namespace syncer |
109 | 111 |
110 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ | 112 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ |
OLD | NEW |