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 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "net/base/network_change_notifier.h" | 11 #include "net/base/network_change_notifier.h" |
12 #include "sync/engine/all_status.h" | 12 #include "sync/engine/all_status.h" |
13 #include "sync/engine/net/server_connection_manager.h" | 13 #include "sync/engine/net/server_connection_manager.h" |
14 #include "sync/engine/sync_engine_event.h" | 14 #include "sync/engine/sync_engine_event.h" |
15 #include "sync/engine/throttled_data_type_tracker.h" | 15 #include "sync/engine/throttled_data_type_tracker.h" |
16 #include "sync/engine/traffic_recorder.h" | 16 #include "sync/engine/traffic_recorder.h" |
17 #include "sync/internal_api/change_reorder_buffer.h" | 17 #include "sync/internal_api/change_reorder_buffer.h" |
18 #include "sync/internal_api/debug_info_event_listener.h" | 18 #include "sync/internal_api/debug_info_event_listener.h" |
19 #include "sync/internal_api/js_mutation_event_observer.h" | 19 #include "sync/internal_api/js_mutation_event_observer.h" |
20 #include "sync/internal_api/js_sync_encryption_handler_observer.h" | 20 #include "sync/internal_api/js_sync_encryption_handler_observer.h" |
21 #include "sync/internal_api/js_sync_manager_observer.h" | 21 #include "sync/internal_api/js_sync_manager_observer.h" |
22 #include "sync/internal_api/public/sync_manager.h" | 22 #include "sync/internal_api/public/sync_manager.h" |
23 #include "sync/internal_api/sync_encryption_handler_impl.h" | 23 #include "sync/internal_api/sync_encryption_handler_impl.h" |
24 #include "sync/js/js_backend.h" | 24 #include "sync/js/js_backend.h" |
25 #include "sync/notifier/invalidation_handler.h" | 25 #include "sync/notifier/invalidation_handler.h" |
26 #include "sync/notifier/notifications_disabled_reason.h" | 26 #include "sync/notifier/invalidator_state.h" |
27 #include "sync/syncable/directory_change_delegate.h" | 27 #include "sync/syncable/directory_change_delegate.h" |
28 #include "sync/util/cryptographer.h" | 28 #include "sync/util/cryptographer.h" |
29 #include "sync/util/time.h" | 29 #include "sync/util/time.h" |
30 | 30 |
31 namespace syncer { | 31 namespace syncer { |
32 | 32 |
33 class SyncAPIServerConnectionManager; | 33 class SyncAPIServerConnectionManager; |
34 class WriteNode; | 34 class WriteNode; |
35 class WriteTransaction; | 35 class WriteTransaction; |
36 | 36 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 160 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
161 syncable::BaseTransaction* trans) OVERRIDE; | 161 syncable::BaseTransaction* trans) OVERRIDE; |
162 virtual void HandleCalculateChangesChangeEventFromSyncApi( | 162 virtual void HandleCalculateChangesChangeEventFromSyncApi( |
163 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 163 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
164 syncable::BaseTransaction* trans) OVERRIDE; | 164 syncable::BaseTransaction* trans) OVERRIDE; |
165 virtual void HandleCalculateChangesChangeEventFromSyncer( | 165 virtual void HandleCalculateChangesChangeEventFromSyncer( |
166 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 166 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
167 syncable::BaseTransaction* trans) OVERRIDE; | 167 syncable::BaseTransaction* trans) OVERRIDE; |
168 | 168 |
169 // InvalidationHandler implementation. | 169 // InvalidationHandler implementation. |
170 virtual void OnNotificationsEnabled() OVERRIDE; | 170 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; |
171 virtual void OnNotificationsDisabled( | 171 virtual void OnIncomingInvalidation( |
172 NotificationsDisabledReason reason) OVERRIDE; | |
173 virtual void OnIncomingNotification( | |
174 const ObjectIdStateMap& id_state_map, | 172 const ObjectIdStateMap& id_state_map, |
175 IncomingNotificationSource source) OVERRIDE; | 173 IncomingInvalidationSource source) OVERRIDE; |
176 | 174 |
177 // Called only by our NetworkChangeNotifier. | 175 // Called only by our NetworkChangeNotifier. |
178 virtual void OnIPAddressChanged() OVERRIDE; | 176 virtual void OnIPAddressChanged() OVERRIDE; |
179 | 177 |
180 const SyncScheduler* scheduler() const; | 178 const SyncScheduler* scheduler() const; |
181 | 179 |
182 private: | 180 private: |
183 friend class SyncManagerTest; | 181 friend class SyncManagerTest; |
184 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); | 182 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); |
185 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnNotificationStateChange); | 183 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnNotificationStateChange); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 void UpdateNotificationInfo( | 255 void UpdateNotificationInfo( |
258 const ModelTypeStateMap& type_state_map); | 256 const ModelTypeStateMap& type_state_map); |
259 | 257 |
260 // Checks for server reachabilty and requests a nudge. | 258 // Checks for server reachabilty and requests a nudge. |
261 void OnIPAddressChangedImpl(); | 259 void OnIPAddressChangedImpl(); |
262 | 260 |
263 // Helper function used only by the constructor. | 261 // Helper function used only by the constructor. |
264 void BindJsMessageHandler( | 262 void BindJsMessageHandler( |
265 const std::string& name, UnboundJsMessageHandler unbound_message_handler); | 263 const std::string& name, UnboundJsMessageHandler unbound_message_handler); |
266 | 264 |
267 // Helper function used by OnNotifications{Enabled,Disabled}(). | |
268 void OnNotificationStateChange(NotificationsDisabledReason reason); | |
269 | |
270 // Returned pointer is owned by the caller. | 265 // Returned pointer is owned by the caller. |
271 static DictionaryValue* NotificationInfoToValue( | 266 static DictionaryValue* NotificationInfoToValue( |
272 const NotificationInfoMap& notification_info); | 267 const NotificationInfoMap& notification_info); |
273 | 268 |
274 static std::string NotificationInfoToString( | 269 static std::string NotificationInfoToString( |
275 const NotificationInfoMap& notification_info); | 270 const NotificationInfoMap& notification_info); |
276 | 271 |
277 // JS message handlers. | 272 // JS message handlers. |
278 JsArgList GetNotificationState(const JsArgList& args); | 273 JsArgList GetNotificationState(const JsArgList& args); |
279 JsArgList GetNotificationInfo(const JsArgList& args); | 274 JsArgList GetNotificationInfo(const JsArgList& args); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 // TRANSACTION_COMPLETE step by HandleTransactionCompleteChangeEvent. | 341 // TRANSACTION_COMPLETE step by HandleTransactionCompleteChangeEvent. |
347 ChangeReorderBuffer change_buffers_[MODEL_TYPE_COUNT]; | 342 ChangeReorderBuffer change_buffers_[MODEL_TYPE_COUNT]; |
348 | 343 |
349 SyncManager::ChangeDelegate* change_delegate_; | 344 SyncManager::ChangeDelegate* change_delegate_; |
350 | 345 |
351 // Set to true once Init has been called. | 346 // Set to true once Init has been called. |
352 bool initialized_; | 347 bool initialized_; |
353 | 348 |
354 bool observing_ip_address_changes_; | 349 bool observing_ip_address_changes_; |
355 | 350 |
356 NotificationsDisabledReason notifications_disabled_reason_; | 351 InvalidatorState invalidator_state_; |
357 | 352 |
358 // Map used to store the notification info to be displayed in | 353 // Map used to store the notification info to be displayed in |
359 // about:sync page. | 354 // about:sync page. |
360 NotificationInfoMap notification_info_map_; | 355 NotificationInfoMap notification_info_map_; |
361 | 356 |
362 // These are for interacting with chrome://sync-internals. | 357 // These are for interacting with chrome://sync-internals. |
363 JsMessageHandlerMap js_message_handlers_; | 358 JsMessageHandlerMap js_message_handlers_; |
364 WeakHandle<JsEventHandler> js_event_handler_; | 359 WeakHandle<JsEventHandler> js_event_handler_; |
365 JsSyncManagerObserver js_sync_manager_observer_; | 360 JsSyncManagerObserver js_sync_manager_observer_; |
366 JsMutationEventObserver js_mutation_event_observer_; | 361 JsMutationEventObserver js_mutation_event_observer_; |
(...skipping 14 matching lines...) Expand all Loading... |
381 // changing passphrases, and in general handles sync-specific interactions | 376 // changing passphrases, and in general handles sync-specific interactions |
382 // with the cryptographer. | 377 // with the cryptographer. |
383 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_; | 378 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_; |
384 | 379 |
385 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); | 380 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); |
386 }; | 381 }; |
387 | 382 |
388 } // namespace syncer | 383 } // namespace syncer |
389 | 384 |
390 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 385 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
OLD | NEW |