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 // 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_CHROME_INVALIDATION_CLIENT_H_ | 8 #ifndef SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ |
9 #define SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ | 9 #define SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.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/notifier/chrome_system_resources.h" | 20 #include "sync/notifier/chrome_system_resources.h" |
21 #include "sync/notifier/invalidation_version_tracker.h" | 21 #include "sync/notifier/invalidation_state_tracker.h" |
22 #include "sync/notifier/state_writer.h" | 22 #include "sync/notifier/state_writer.h" |
23 #include "sync/syncable/model_type.h" | 23 #include "sync/syncable/model_type.h" |
24 #include "sync/syncable/model_type_payload_map.h" | 24 #include "sync/syncable/model_type_payload_map.h" |
25 #include "sync/util/weak_handle.h" | 25 #include "sync/util/weak_handle.h" |
26 | 26 |
27 namespace buzz { | 27 namespace buzz { |
28 class XmppTaskParentInterface; | 28 class XmppTaskParentInterface; |
29 } // namespace buzz | 29 } // namespace buzz |
30 | 30 |
31 namespace sync_notifier { | 31 namespace sync_notifier { |
(...skipping 18 matching lines...) Expand all Loading... |
50 | 50 |
51 virtual void OnSessionStatusChanged(bool has_session) = 0; | 51 virtual void OnSessionStatusChanged(bool has_session) = 0; |
52 }; | 52 }; |
53 | 53 |
54 ChromeInvalidationClient(); | 54 ChromeInvalidationClient(); |
55 | 55 |
56 // Calls Stop(). | 56 // Calls Stop(). |
57 virtual ~ChromeInvalidationClient(); | 57 virtual ~ChromeInvalidationClient(); |
58 | 58 |
59 // Does not take ownership of |listener| or |state_writer|. | 59 // Does not take ownership of |listener| or |state_writer|. |
60 // |invalidation_version_tracker| must be initialized. | 60 // |invalidation_state_tracker| must be initialized. |
61 // |base_task| must still be non-NULL. | 61 // |base_task| must still be non-NULL. |
62 void Start( | 62 void Start( |
63 const std::string& client_id, const std::string& client_info, | 63 const std::string& client_id, const std::string& client_info, |
64 const std::string& state, | 64 const std::string& state, |
65 const InvalidationVersionMap& initial_max_invalidation_versions, | 65 const InvalidationVersionMap& initial_max_invalidation_versions, |
66 const browser_sync::WeakHandle<InvalidationVersionTracker>& | 66 const browser_sync::WeakHandle<InvalidationStateTracker>& |
67 invalidation_version_tracker, | 67 invalidation_state_tracker, |
68 Listener* listener, | 68 Listener* listener, |
69 StateWriter* state_writer, | 69 StateWriter* state_writer, |
70 base::WeakPtr<buzz::XmppTaskParentInterface> base_task); | 70 base::WeakPtr<buzz::XmppTaskParentInterface> base_task); |
71 | 71 |
72 void Stop(); | 72 void Stop(); |
73 | 73 |
74 // Changes the task used to |base_task|, which must still be | 74 // Changes the task used to |base_task|, which must still be |
75 // non-NULL. Must only be called between calls to Start() and | 75 // non-NULL. Must only be called between calls to Start() and |
76 // Stop(). | 76 // Stop(). |
77 void ChangeBaseTask(base::WeakPtr<buzz::XmppTaskParentInterface> base_task); | 77 void ChangeBaseTask(base::WeakPtr<buzz::XmppTaskParentInterface> base_task); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 private: | 116 private: |
117 friend class ChromeInvalidationClientTest; | 117 friend class ChromeInvalidationClientTest; |
118 | 118 |
119 void EmitInvalidation( | 119 void EmitInvalidation( |
120 syncable::ModelTypeSet types, const std::string& payload); | 120 syncable::ModelTypeSet types, const std::string& payload); |
121 | 121 |
122 base::NonThreadSafe non_thread_safe_; | 122 base::NonThreadSafe non_thread_safe_; |
123 ChromeSystemResources chrome_system_resources_; | 123 ChromeSystemResources chrome_system_resources_; |
124 InvalidationVersionMap max_invalidation_versions_; | 124 InvalidationVersionMap max_invalidation_versions_; |
125 browser_sync::WeakHandle<InvalidationVersionTracker> | 125 browser_sync::WeakHandle<InvalidationStateTracker> |
126 invalidation_version_tracker_; | 126 invalidation_state_tracker_; |
127 Listener* listener_; | 127 Listener* listener_; |
128 StateWriter* state_writer_; | 128 StateWriter* state_writer_; |
129 scoped_ptr<invalidation::InvalidationClient> invalidation_client_; | 129 scoped_ptr<invalidation::InvalidationClient> invalidation_client_; |
130 scoped_ptr<CacheInvalidationPacketHandler> | 130 scoped_ptr<CacheInvalidationPacketHandler> |
131 cache_invalidation_packet_handler_; | 131 cache_invalidation_packet_handler_; |
132 scoped_ptr<RegistrationManager> registration_manager_; | 132 scoped_ptr<RegistrationManager> registration_manager_; |
133 // Stored to pass to |registration_manager_| on start. | 133 // Stored to pass to |registration_manager_| on start. |
134 syncable::ModelTypeSet registered_types_; | 134 syncable::ModelTypeSet registered_types_; |
135 bool ticl_ready_; | 135 bool ticl_ready_; |
136 | 136 |
137 DISALLOW_COPY_AND_ASSIGN(ChromeInvalidationClient); | 137 DISALLOW_COPY_AND_ASSIGN(ChromeInvalidationClient); |
138 }; | 138 }; |
139 | 139 |
140 } // namespace sync_notifier | 140 } // namespace sync_notifier |
141 | 141 |
142 #endif // SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ | 142 #endif // SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ |
OLD | NEW |