OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_PUBLIC_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "sync/base/sync_export.h" | 18 #include "sync/base/sync_export.h" |
| 19 #include "sync/internal_api/public/base/invalidation_interface.h" |
19 #include "sync/internal_api/public/base/model_type.h" | 20 #include "sync/internal_api/public/base/model_type.h" |
20 #include "sync/internal_api/public/change_record.h" | 21 #include "sync/internal_api/public/change_record.h" |
21 #include "sync/internal_api/public/configure_reason.h" | 22 #include "sync/internal_api/public/configure_reason.h" |
22 #include "sync/internal_api/public/engine/model_safe_worker.h" | 23 #include "sync/internal_api/public/engine/model_safe_worker.h" |
23 #include "sync/internal_api/public/engine/sync_status.h" | 24 #include "sync/internal_api/public/engine/sync_status.h" |
24 #include "sync/internal_api/public/events/protocol_event.h" | 25 #include "sync/internal_api/public/events/protocol_event.h" |
25 #include "sync/internal_api/public/sync_core_proxy.h" | 26 #include "sync/internal_api/public/sync_core_proxy.h" |
26 #include "sync/internal_api/public/sync_encryption_handler.h" | 27 #include "sync/internal_api/public/sync_encryption_handler.h" |
27 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 28 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
28 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 29 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 }; | 75 }; |
75 | 76 |
76 // SyncManager encapsulates syncable::Directory and serves as the parent of all | 77 // SyncManager encapsulates syncable::Directory and serves as the parent of all |
77 // other objects in the sync API. If multiple threads interact with the same | 78 // other objects in the sync API. If multiple threads interact with the same |
78 // local sync repository (i.e. the same sqlite database), they should share a | 79 // local sync repository (i.e. the same sqlite database), they should share a |
79 // single SyncManager instance. The caller should typically create one | 80 // single SyncManager instance. The caller should typically create one |
80 // SyncManager for the lifetime of a user session. | 81 // SyncManager for the lifetime of a user session. |
81 // | 82 // |
82 // Unless stated otherwise, all methods of SyncManager should be called on the | 83 // Unless stated otherwise, all methods of SyncManager should be called on the |
83 // same thread. | 84 // same thread. |
84 class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler { | 85 class SYNC_EXPORT SyncManager { |
85 public: | 86 public: |
86 // An interface the embedding application implements to be notified | 87 // An interface the embedding application implements to be notified |
87 // on change events. Note that these methods may be called on *any* | 88 // on change events. Note that these methods may be called on *any* |
88 // thread. | 89 // thread. |
89 class SYNC_EXPORT ChangeDelegate { | 90 class SYNC_EXPORT ChangeDelegate { |
90 public: | 91 public: |
91 // Notify the delegate that changes have been applied to the sync model. | 92 // Notify the delegate that changes have been applied to the sync model. |
92 // | 93 // |
93 // This will be invoked on the same thread as on which ApplyChanges was | 94 // This will be invoked on the same thread as on which ApplyChanges was |
94 // called. |changes| is an array of size |change_count|, and contains the | 95 // called. |changes| is an array of size |change_count|, and contains the |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 ModelTypeSet to_unapply, | 300 ModelTypeSet to_unapply, |
300 const ModelSafeRoutingInfo& new_routing_info, | 301 const ModelSafeRoutingInfo& new_routing_info, |
301 const base::Closure& ready_task, | 302 const base::Closure& ready_task, |
302 const base::Closure& retry_task) = 0; | 303 const base::Closure& retry_task) = 0; |
303 | 304 |
304 // Inform the syncer of a change in the invalidator's state. | 305 // Inform the syncer of a change in the invalidator's state. |
305 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0; | 306 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0; |
306 | 307 |
307 // Inform the syncer that its cached information about a type is obsolete. | 308 // Inform the syncer that its cached information about a type is obsolete. |
308 virtual void OnIncomingInvalidation( | 309 virtual void OnIncomingInvalidation( |
309 const ObjectIdInvalidationMap& invalidation_map) = 0; | 310 syncer::ModelType type, |
| 311 scoped_ptr<InvalidationInterface> interface) = 0; |
310 | 312 |
311 // Adds a listener to be notified of sync events. | 313 // Adds a listener to be notified of sync events. |
312 // NOTE: It is OK (in fact, it's probably a good idea) to call this before | 314 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
313 // having received OnInitializationCompleted. | 315 // having received OnInitializationCompleted. |
314 virtual void AddObserver(Observer* observer) = 0; | 316 virtual void AddObserver(Observer* observer) = 0; |
315 | 317 |
316 // Remove the given observer. Make sure to call this if the | 318 // Remove the given observer. Make sure to call this if the |
317 // Observer is being destroyed so the SyncManager doesn't | 319 // Observer is being destroyed so the SyncManager doesn't |
318 // potentially dereference garbage. | 320 // potentially dereference garbage. |
319 virtual void RemoveObserver(Observer* observer) = 0; | 321 virtual void RemoveObserver(Observer* observer) = 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 syncer::TypeDebugInfoObserver* observer) = 0; | 370 syncer::TypeDebugInfoObserver* observer) = 0; |
369 | 371 |
370 // Request that all current counter values be emitted as though they had just | 372 // Request that all current counter values be emitted as though they had just |
371 // been updated. Useful for initializing new observers' state. | 373 // been updated. Useful for initializing new observers' state. |
372 virtual void RequestEmitDebugInfo() = 0; | 374 virtual void RequestEmitDebugInfo() = 0; |
373 }; | 375 }; |
374 | 376 |
375 } // namespace syncer | 377 } // namespace syncer |
376 | 378 |
377 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 379 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
OLD | NEW |