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_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
16 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
17 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
18 #include "google_apis/gaia/oauth2_token_service.h" | 19 #include "google_apis/gaia/oauth2_token_service.h" |
19 #include "sync/base/sync_export.h" | 20 #include "sync/base/sync_export.h" |
| 21 #include "sync/internal_api/public/base/invalidation_interface.h" |
20 #include "sync/internal_api/public/base/model_type.h" | 22 #include "sync/internal_api/public/base/model_type.h" |
21 #include "sync/internal_api/public/change_record.h" | 23 #include "sync/internal_api/public/change_record.h" |
22 #include "sync/internal_api/public/configure_reason.h" | 24 #include "sync/internal_api/public/configure_reason.h" |
23 #include "sync/internal_api/public/engine/model_safe_worker.h" | 25 #include "sync/internal_api/public/engine/model_safe_worker.h" |
24 #include "sync/internal_api/public/engine/sync_status.h" | 26 #include "sync/internal_api/public/engine/sync_status.h" |
25 #include "sync/internal_api/public/events/protocol_event.h" | 27 #include "sync/internal_api/public/events/protocol_event.h" |
26 #include "sync/internal_api/public/sync_context_proxy.h" | 28 #include "sync/internal_api/public/sync_context_proxy.h" |
27 #include "sync/internal_api/public/sync_encryption_handler.h" | 29 #include "sync/internal_api/public/sync_encryption_handler.h" |
28 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 30 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
29 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 31 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 }; | 84 }; |
83 | 85 |
84 // SyncManager encapsulates syncable::Directory and serves as the parent of all | 86 // SyncManager encapsulates syncable::Directory and serves as the parent of all |
85 // other objects in the sync API. If multiple threads interact with the same | 87 // other objects in the sync API. If multiple threads interact with the same |
86 // local sync repository (i.e. the same sqlite database), they should share a | 88 // local sync repository (i.e. the same sqlite database), they should share a |
87 // single SyncManager instance. The caller should typically create one | 89 // single SyncManager instance. The caller should typically create one |
88 // SyncManager for the lifetime of a user session. | 90 // SyncManager for the lifetime of a user session. |
89 // | 91 // |
90 // Unless stated otherwise, all methods of SyncManager should be called on the | 92 // Unless stated otherwise, all methods of SyncManager should be called on the |
91 // same thread. | 93 // same thread. |
92 class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler { | 94 class SYNC_EXPORT SyncManager { |
93 public: | 95 public: |
94 // An interface the embedding application implements to be notified | 96 // An interface the embedding application implements to be notified |
95 // on change events. Note that these methods may be called on *any* | 97 // on change events. Note that these methods may be called on *any* |
96 // thread. | 98 // thread. |
97 class SYNC_EXPORT ChangeDelegate { | 99 class SYNC_EXPORT ChangeDelegate { |
98 public: | 100 public: |
99 // Notify the delegate that changes have been applied to the sync model. | 101 // Notify the delegate that changes have been applied to the sync model. |
100 // | 102 // |
101 // This will be invoked on the same thread as on which ApplyChanges was | 103 // This will be invoked on the same thread as on which ApplyChanges was |
102 // called. |changes| is an array of size |change_count|, and contains the | 104 // 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... |
307 ModelTypeSet to_unapply, | 309 ModelTypeSet to_unapply, |
308 const ModelSafeRoutingInfo& new_routing_info, | 310 const ModelSafeRoutingInfo& new_routing_info, |
309 const base::Closure& ready_task, | 311 const base::Closure& ready_task, |
310 const base::Closure& retry_task) = 0; | 312 const base::Closure& retry_task) = 0; |
311 | 313 |
312 // Inform the syncer of a change in the invalidator's state. | 314 // Inform the syncer of a change in the invalidator's state. |
313 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0; | 315 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0; |
314 | 316 |
315 // Inform the syncer that its cached information about a type is obsolete. | 317 // Inform the syncer that its cached information about a type is obsolete. |
316 virtual void OnIncomingInvalidation( | 318 virtual void OnIncomingInvalidation( |
317 const ObjectIdInvalidationMap& invalidation_map) = 0; | 319 syncer::ModelType type, |
| 320 scoped_ptr<syncer::InvalidationInterface> invalidation) = 0; |
318 | 321 |
319 // Adds a listener to be notified of sync events. | 322 // Adds a listener to be notified of sync events. |
320 // NOTE: It is OK (in fact, it's probably a good idea) to call this before | 323 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
321 // having received OnInitializationCompleted. | 324 // having received OnInitializationCompleted. |
322 virtual void AddObserver(Observer* observer) = 0; | 325 virtual void AddObserver(Observer* observer) = 0; |
323 | 326 |
324 // Remove the given observer. Make sure to call this if the | 327 // Remove the given observer. Make sure to call this if the |
325 // Observer is being destroyed so the SyncManager doesn't | 328 // Observer is being destroyed so the SyncManager doesn't |
326 // potentially dereference garbage. | 329 // potentially dereference garbage. |
327 virtual void RemoveObserver(Observer* observer) = 0; | 330 virtual void RemoveObserver(Observer* observer) = 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 syncer::TypeDebugInfoObserver* observer) = 0; | 379 syncer::TypeDebugInfoObserver* observer) = 0; |
377 | 380 |
378 // Request that all current counter values be emitted as though they had just | 381 // Request that all current counter values be emitted as though they had just |
379 // been updated. Useful for initializing new observers' state. | 382 // been updated. Useful for initializing new observers' state. |
380 virtual void RequestEmitDebugInfo() = 0; | 383 virtual void RequestEmitDebugInfo() = 0; |
381 }; | 384 }; |
382 | 385 |
383 } // namespace syncer | 386 } // namespace syncer |
384 | 387 |
385 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 388 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
OLD | NEW |