Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: sync/internal_api/public/sync_manager.h

Issue 15580002: Make use of InvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | sync/internal_api/public/test/fake_sync_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/task_runner.h" 15 #include "base/task_runner.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "sync/base/sync_export.h" 17 #include "sync/base/sync_export.h"
18 #include "sync/internal_api/public/base/model_type.h" 18 #include "sync/internal_api/public/base/model_type.h"
19 #include "sync/internal_api/public/change_record.h" 19 #include "sync/internal_api/public/change_record.h"
20 #include "sync/internal_api/public/configure_reason.h" 20 #include "sync/internal_api/public/configure_reason.h"
21 #include "sync/internal_api/public/engine/model_safe_worker.h" 21 #include "sync/internal_api/public/engine/model_safe_worker.h"
22 #include "sync/internal_api/public/engine/sync_status.h" 22 #include "sync/internal_api/public/engine/sync_status.h"
23 #include "sync/internal_api/public/sync_encryption_handler.h" 23 #include "sync/internal_api/public/sync_encryption_handler.h"
24 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" 24 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
25 #include "sync/internal_api/public/util/weak_handle.h" 25 #include "sync/internal_api/public/util/weak_handle.h"
26 #include "sync/notifier/invalidation_util.h" 26 #include "sync/notifier/invalidation_handler.h"
27 #include "sync/protocol/sync_protocol_error.h" 27 #include "sync/protocol/sync_protocol_error.h"
28 28
29 namespace sync_pb { 29 namespace sync_pb {
30 class EncryptedData; 30 class EncryptedData;
31 } // namespace sync_pb 31 } // namespace sync_pb
32 32
33 namespace syncer { 33 namespace syncer {
34 34
35 class BaseTransaction; 35 class BaseTransaction;
36 class DataTypeDebugInfoListener; 36 class DataTypeDebugInfoListener;
37 class Encryptor; 37 class Encryptor;
38 struct Experiments; 38 struct Experiments;
39 class ExtensionsActivityMonitor; 39 class ExtensionsActivityMonitor;
40 class HttpPostProviderFactory; 40 class HttpPostProviderFactory;
41 class InternalComponentsFactory; 41 class InternalComponentsFactory;
42 class InvalidationHandler;
43 class Invalidator;
44 class JsBackend; 42 class JsBackend;
45 class JsEventHandler; 43 class JsEventHandler;
46 class SyncEncryptionHandler; 44 class SyncEncryptionHandler;
47 class SyncScheduler; 45 class SyncScheduler;
48 class UnrecoverableErrorHandler; 46 class UnrecoverableErrorHandler;
49 struct UserShare; 47 struct UserShare;
50 48
51 namespace sessions { 49 namespace sessions {
52 class SyncSessionSnapshot; 50 class SyncSessionSnapshot;
53 } // namespace sessions 51 } // namespace sessions
(...skipping 14 matching lines...) Expand all
68 }; 66 };
69 67
70 // SyncManager encapsulates syncable::Directory and serves as the parent of all 68 // SyncManager encapsulates syncable::Directory and serves as the parent of all
71 // other objects in the sync API. If multiple threads interact with the same 69 // other objects in the sync API. If multiple threads interact with the same
72 // local sync repository (i.e. the same sqlite database), they should share a 70 // local sync repository (i.e. the same sqlite database), they should share a
73 // single SyncManager instance. The caller should typically create one 71 // single SyncManager instance. The caller should typically create one
74 // SyncManager for the lifetime of a user session. 72 // SyncManager for the lifetime of a user session.
75 // 73 //
76 // Unless stated otherwise, all methods of SyncManager should be called on the 74 // Unless stated otherwise, all methods of SyncManager should be called on the
77 // same thread. 75 // same thread.
78 class SYNC_EXPORT SyncManager { 76 class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler {
79 public: 77 public:
80 // An interface the embedding application implements to be notified 78 // An interface the embedding application implements to be notified
81 // on change events. Note that these methods may be called on *any* 79 // on change events. Note that these methods may be called on *any*
82 // thread. 80 // thread.
83 class SYNC_EXPORT ChangeDelegate { 81 class SYNC_EXPORT ChangeDelegate {
84 public: 82 public:
85 // Notify the delegate that changes have been applied to the sync model. 83 // Notify the delegate that changes have been applied to the sync model.
86 // 84 //
87 // This will be invoked on the same thread as on which ApplyChanges was 85 // This will be invoked on the same thread as on which ApplyChanges was
88 // called. |changes| is an array of size |change_count|, and contains the 86 // called. |changes| is an array of size |change_count|, and contains the
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 const base::FilePath& database_location, 306 const base::FilePath& database_location,
309 const WeakHandle<JsEventHandler>& event_handler, 307 const WeakHandle<JsEventHandler>& event_handler,
310 const std::string& sync_server_and_path, 308 const std::string& sync_server_and_path,
311 int sync_server_port, 309 int sync_server_port,
312 bool use_ssl, 310 bool use_ssl,
313 scoped_ptr<HttpPostProviderFactory> post_factory, 311 scoped_ptr<HttpPostProviderFactory> post_factory,
314 const std::vector<ModelSafeWorker*>& workers, 312 const std::vector<ModelSafeWorker*>& workers,
315 ExtensionsActivityMonitor* extensions_activity_monitor, 313 ExtensionsActivityMonitor* extensions_activity_monitor,
316 ChangeDelegate* change_delegate, 314 ChangeDelegate* change_delegate,
317 const SyncCredentials& credentials, 315 const SyncCredentials& credentials,
318 scoped_ptr<Invalidator> invalidator,
319 const std::string& invalidator_client_id, 316 const std::string& invalidator_client_id,
320 const std::string& restored_key_for_bootstrapping, 317 const std::string& restored_key_for_bootstrapping,
321 const std::string& restored_keystore_key_for_bootstrapping, 318 const std::string& restored_keystore_key_for_bootstrapping,
322 scoped_ptr<InternalComponentsFactory> internal_components_factory, 319 scoped_ptr<InternalComponentsFactory> internal_components_factory,
323 Encryptor* encryptor, 320 Encryptor* encryptor,
324 UnrecoverableErrorHandler* unrecoverable_error_handler, 321 UnrecoverableErrorHandler* unrecoverable_error_handler,
325 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, 322 ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
326 bool use_oauth2_token) = 0; 323 bool use_oauth2_token) = 0;
327 324
328 // Throw an unrecoverable error from a transaction (mostly used for 325 // Throw an unrecoverable error from a transaction (mostly used for
329 // testing). 326 // testing).
330 virtual void ThrowUnrecoverableError() = 0; 327 virtual void ThrowUnrecoverableError() = 0;
331 328
332 virtual ModelTypeSet InitialSyncEndedTypes() = 0; 329 virtual ModelTypeSet InitialSyncEndedTypes() = 0;
333 330
334 // Returns those types within |types| that have an empty progress marker 331 // Returns those types within |types| that have an empty progress marker
335 // token. 332 // token.
336 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( 333 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
337 ModelTypeSet types) = 0; 334 ModelTypeSet types) = 0;
338 335
339 // Purge from the directory those types with non-empty progress markers 336 // Purge from the directory those types with non-empty progress markers
340 // but without initial synced ended set. 337 // but without initial synced ended set.
341 // Returns false if an error occurred, true otherwise. 338 // Returns false if an error occurred, true otherwise.
342 virtual bool PurgePartiallySyncedTypes() = 0; 339 virtual bool PurgePartiallySyncedTypes() = 0;
343 340
344 // Update tokens that we're using in Sync. Email must stay the same. 341 // Update tokens that we're using in Sync. Email must stay the same.
345 virtual void UpdateCredentials(const SyncCredentials& credentials) = 0; 342 virtual void UpdateCredentials(const SyncCredentials& credentials) = 0;
346 343
347 // Called when the user disables or enables a sync type.
348 virtual void UpdateEnabledTypes(ModelTypeSet enabled_types) = 0;
349
350 // Forwards to the underlying invalidator (see comments in invalidator.h).
351 virtual void RegisterInvalidationHandler(
352 InvalidationHandler* handler) = 0;
353
354 // Forwards to the underlying notifier (see comments in invalidator.h).
355 virtual void UpdateRegisteredInvalidationIds(
356 InvalidationHandler* handler,
357 const ObjectIdSet& ids) = 0;
358
359 // Forwards to the underlying notifier (see comments in invalidator.h).
360 virtual void UnregisterInvalidationHandler(
361 InvalidationHandler* handler) = 0;
362
363 // Forwards to the underlying notifier (see comments in invalidator.h).
364 virtual void AcknowledgeInvalidation(
365 const invalidation::ObjectId& id,
366 const syncer::AckHandle& ack_handle) = 0;
367
368 // Put the syncer in normal mode ready to perform nudges and polls. 344 // Put the syncer in normal mode ready to perform nudges and polls.
369 virtual void StartSyncingNormally( 345 virtual void StartSyncingNormally(
370 const ModelSafeRoutingInfo& routing_info) = 0; 346 const ModelSafeRoutingInfo& routing_info) = 0;
371 347
372 // Switches the mode of operation to CONFIGURATION_MODE and performs 348 // Switches the mode of operation to CONFIGURATION_MODE and performs
373 // any configuration tasks needed as determined by the params. Once complete, 349 // any configuration tasks needed as determined by the params. Once complete,
374 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is 350 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is
375 // called. 351 // called.
376 // Data whose types are not in |new_routing_info| are purged from sync 352 // Data whose types are not in |new_routing_info| are purged from sync
377 // directory, unless they're part of |to_ignore|, in which case they're left 353 // directory, unless they're part of |to_ignore|, in which case they're left
378 // untouched. The purged data is backed up in delete journal for recovery in 354 // untouched. The purged data is backed up in delete journal for recovery in
379 // next session if its type is in |to_journal|. If in |to_unapply| 355 // next session if its type is in |to_journal|. If in |to_unapply|
380 // only the local data is removed; the server data is preserved. 356 // only the local data is removed; the server data is preserved.
381 // |ready_task| is invoked when the configuration completes. 357 // |ready_task| is invoked when the configuration completes.
382 // |retry_task| is invoked if the configuration job could not immediately 358 // |retry_task| is invoked if the configuration job could not immediately
383 // execute. |ready_task| will still be called when it eventually 359 // execute. |ready_task| will still be called when it eventually
384 // does finish. 360 // does finish.
385 virtual void ConfigureSyncer( 361 virtual void ConfigureSyncer(
386 ConfigureReason reason, 362 ConfigureReason reason,
387 ModelTypeSet to_download, 363 ModelTypeSet to_download,
388 ModelTypeSet to_purge, 364 ModelTypeSet to_purge,
389 ModelTypeSet to_journal, 365 ModelTypeSet to_journal,
390 ModelTypeSet to_unapply, 366 ModelTypeSet to_unapply,
391 const ModelSafeRoutingInfo& new_routing_info, 367 const ModelSafeRoutingInfo& new_routing_info,
392 const base::Closure& ready_task, 368 const base::Closure& ready_task,
393 const base::Closure& retry_task) = 0; 369 const base::Closure& retry_task) = 0;
394 370
371 // Inform the syncer of a change in the invalidator's state.
372 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0;
373
374 // Inform the syncer that its cached information about a type is obsolete.
375 virtual void OnIncomingInvalidation(
376 const ObjectIdInvalidationMap& invalidation_map) = 0;
377
395 // Adds a listener to be notified of sync events. 378 // Adds a listener to be notified of sync events.
396 // NOTE: It is OK (in fact, it's probably a good idea) to call this before 379 // NOTE: It is OK (in fact, it's probably a good idea) to call this before
397 // having received OnInitializationCompleted. 380 // having received OnInitializationCompleted.
398 virtual void AddObserver(Observer* observer) = 0; 381 virtual void AddObserver(Observer* observer) = 0;
399 382
400 // Remove the given observer. Make sure to call this if the 383 // Remove the given observer. Make sure to call this if the
401 // Observer is being destroyed so the SyncManager doesn't 384 // Observer is being destroyed so the SyncManager doesn't
402 // potentially dereference garbage. 385 // potentially dereference garbage.
403 virtual void RemoveObserver(Observer* observer) = 0; 386 virtual void RemoveObserver(Observer* observer) = 0;
404 387
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // Returns the SyncManager's encryption handler. 425 // Returns the SyncManager's encryption handler.
443 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0; 426 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0;
444 427
445 // Ask the SyncManager to fetch updates for the given types. 428 // Ask the SyncManager to fetch updates for the given types.
446 virtual void RefreshTypes(ModelTypeSet types) = 0; 429 virtual void RefreshTypes(ModelTypeSet types) = 0;
447 }; 430 };
448 431
449 } // namespace syncer 432 } // namespace syncer
450 433
451 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ 434 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | sync/internal_api/public/test/fake_sync_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698