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

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: Responses to Fred's comments 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
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 16 matching lines...) Expand all
70 }; 68 };
71 69
72 // SyncManager encapsulates syncable::Directory and serves as the parent of all 70 // SyncManager encapsulates syncable::Directory and serves as the parent of all
73 // other objects in the sync API. If multiple threads interact with the same 71 // other objects in the sync API. If multiple threads interact with the same
74 // local sync repository (i.e. the same sqlite database), they should share a 72 // local sync repository (i.e. the same sqlite database), they should share a
75 // single SyncManager instance. The caller should typically create one 73 // single SyncManager instance. The caller should typically create one
76 // SyncManager for the lifetime of a user session. 74 // SyncManager for the lifetime of a user session.
77 // 75 //
78 // Unless stated otherwise, all methods of SyncManager should be called on the 76 // Unless stated otherwise, all methods of SyncManager should be called on the
79 // same thread. 77 // same thread.
80 class SYNC_EXPORT SyncManager { 78 class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler {
81 public: 79 public:
82 // An interface the embedding application implements to be notified 80 // An interface the embedding application implements to be notified
83 // on change events. Note that these methods may be called on *any* 81 // on change events. Note that these methods may be called on *any*
84 // thread. 82 // thread.
85 class SYNC_EXPORT ChangeDelegate { 83 class SYNC_EXPORT ChangeDelegate {
86 public: 84 public:
87 // Notify the delegate that changes have been applied to the sync model. 85 // Notify the delegate that changes have been applied to the sync model.
88 // 86 //
89 // This will be invoked on the same thread as on which ApplyChanges was 87 // This will be invoked on the same thread as on which ApplyChanges was
90 // called. |changes| is an array of size |change_count|, and contains the 88 // called. |changes| is an array of size |change_count|, and contains the
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 const base::FilePath& database_location, 308 const base::FilePath& database_location,
311 const WeakHandle<JsEventHandler>& event_handler, 309 const WeakHandle<JsEventHandler>& event_handler,
312 const std::string& sync_server_and_path, 310 const std::string& sync_server_and_path,
313 int sync_server_port, 311 int sync_server_port,
314 bool use_ssl, 312 bool use_ssl,
315 scoped_ptr<HttpPostProviderFactory> post_factory, 313 scoped_ptr<HttpPostProviderFactory> post_factory,
316 const std::vector<ModelSafeWorker*>& workers, 314 const std::vector<ModelSafeWorker*>& workers,
317 ExtensionsActivityMonitor* extensions_activity_monitor, 315 ExtensionsActivityMonitor* extensions_activity_monitor,
318 ChangeDelegate* change_delegate, 316 ChangeDelegate* change_delegate,
319 const SyncCredentials& credentials, 317 const SyncCredentials& credentials,
320 scoped_ptr<Invalidator> invalidator,
321 const std::string& invalidator_client_id, 318 const std::string& invalidator_client_id,
322 const std::string& restored_key_for_bootstrapping, 319 const std::string& restored_key_for_bootstrapping,
323 const std::string& restored_keystore_key_for_bootstrapping, 320 const std::string& restored_keystore_key_for_bootstrapping,
324 scoped_ptr<InternalComponentsFactory> internal_components_factory, 321 scoped_ptr<InternalComponentsFactory> internal_components_factory,
325 Encryptor* encryptor, 322 Encryptor* encryptor,
326 UnrecoverableErrorHandler* unrecoverable_error_handler, 323 UnrecoverableErrorHandler* unrecoverable_error_handler,
327 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) = 0; 324 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) = 0;
328 325
329 // Throw an unrecoverable error from a transaction (mostly used for 326 // Throw an unrecoverable error from a transaction (mostly used for
330 // testing). 327 // testing).
331 virtual void ThrowUnrecoverableError() = 0; 328 virtual void ThrowUnrecoverableError() = 0;
332 329
333 virtual ModelTypeSet InitialSyncEndedTypes() = 0; 330 virtual ModelTypeSet InitialSyncEndedTypes() = 0;
334 331
335 // Returns those types within |types| that have an empty progress marker 332 // Returns those types within |types| that have an empty progress marker
336 // token. 333 // token.
337 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( 334 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
338 ModelTypeSet types) = 0; 335 ModelTypeSet types) = 0;
339 336
340 // Purge from the directory those types with non-empty progress markers 337 // Purge from the directory those types with non-empty progress markers
341 // but without initial synced ended set. 338 // but without initial synced ended set.
342 // Returns false if an error occurred, true otherwise. 339 // Returns false if an error occurred, true otherwise.
343 virtual bool PurgePartiallySyncedTypes() = 0; 340 virtual bool PurgePartiallySyncedTypes() = 0;
344 341
345 // Update tokens that we're using in Sync. Email must stay the same. 342 // Update tokens that we're using in Sync. Email must stay the same.
346 virtual void UpdateCredentials(const SyncCredentials& credentials) = 0; 343 virtual void UpdateCredentials(const SyncCredentials& credentials) = 0;
347 344
348 // Called when the user disables or enables a sync type.
349 virtual void UpdateEnabledTypes(ModelTypeSet enabled_types) = 0;
350
351 // Forwards to the underlying invalidator (see comments in invalidator.h).
352 virtual void RegisterInvalidationHandler(
353 InvalidationHandler* handler) = 0;
354
355 // Forwards to the underlying notifier (see comments in invalidator.h).
356 virtual void UpdateRegisteredInvalidationIds(
357 InvalidationHandler* handler,
358 const ObjectIdSet& ids) = 0;
359
360 // Forwards to the underlying notifier (see comments in invalidator.h).
361 virtual void UnregisterInvalidationHandler(
362 InvalidationHandler* handler) = 0;
363
364 // Forwards to the underlying notifier (see comments in invalidator.h).
365 virtual void AcknowledgeInvalidation(
366 const invalidation::ObjectId& id,
367 const syncer::AckHandle& ack_handle) = 0;
368
369 // Put the syncer in normal mode ready to perform nudges and polls. 345 // Put the syncer in normal mode ready to perform nudges and polls.
370 virtual void StartSyncingNormally( 346 virtual void StartSyncingNormally(
371 const ModelSafeRoutingInfo& routing_info) = 0; 347 const ModelSafeRoutingInfo& routing_info) = 0;
372 348
373 // Switches the mode of operation to CONFIGURATION_MODE and performs 349 // Switches the mode of operation to CONFIGURATION_MODE and performs
374 // any configuration tasks needed as determined by the params. Once complete, 350 // any configuration tasks needed as determined by the params. Once complete,
375 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is 351 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is
376 // called. 352 // called.
377 // Data whose types are not in |new_routing_info| are purged from sync 353 // Data whose types are not in |new_routing_info| are purged from sync
378 // directory. The purged data is backed up in delete journal for recovery in 354 // directory. The purged data is backed up in delete journal for recovery in
379 // next session if its type is in |failed_types|. 355 // next session if its type is in |failed_types|.
380 // |ready_task| is invoked when the configuration completes. 356 // |ready_task| is invoked when the configuration completes.
381 // |retry_task| is invoked if the configuration job could not immediately 357 // |retry_task| is invoked if the configuration job could not immediately
382 // execute. |ready_task| will still be called when it eventually 358 // execute. |ready_task| will still be called when it eventually
383 // does finish. 359 // does finish.
384 virtual void ConfigureSyncer( 360 virtual void ConfigureSyncer(
385 ConfigureReason reason, 361 ConfigureReason reason,
386 ModelTypeSet types_to_config, 362 ModelTypeSet types_to_config,
387 ModelTypeSet failed_types, 363 ModelTypeSet failed_types,
388 const ModelSafeRoutingInfo& new_routing_info, 364 const ModelSafeRoutingInfo& new_routing_info,
389 const base::Closure& ready_task, 365 const base::Closure& ready_task,
390 const base::Closure& retry_task) = 0; 366 const base::Closure& retry_task) = 0;
391 367
368 // Inform the syncer of a change in the invalidator's state.
369 virtual void OnInvalidatorStateChange(InvalidatorState state) = 0;
370
371 // Inform the syncer that its cached information about a type is obsolete.
372 virtual void OnIncomingInvalidation(
373 const ObjectIdInvalidationMap& invalidation_map) = 0;
374
392 // Adds a listener to be notified of sync events. 375 // Adds a listener to be notified of sync events.
393 // NOTE: It is OK (in fact, it's probably a good idea) to call this before 376 // NOTE: It is OK (in fact, it's probably a good idea) to call this before
394 // having received OnInitializationCompleted. 377 // having received OnInitializationCompleted.
395 virtual void AddObserver(Observer* observer) = 0; 378 virtual void AddObserver(Observer* observer) = 0;
396 379
397 // Remove the given observer. Make sure to call this if the 380 // Remove the given observer. Make sure to call this if the
398 // Observer is being destroyed so the SyncManager doesn't 381 // Observer is being destroyed so the SyncManager doesn't
399 // potentially dereference garbage. 382 // potentially dereference garbage.
400 virtual void RemoveObserver(Observer* observer) = 0; 383 virtual void RemoveObserver(Observer* observer) = 0;
401 384
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // Returns the SyncManager's encryption handler. 422 // Returns the SyncManager's encryption handler.
440 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0; 423 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0;
441 424
442 // Ask the SyncManager to fetch updates for the given types. 425 // Ask the SyncManager to fetch updates for the given types.
443 virtual void RefreshTypes(ModelTypeSet types) = 0; 426 virtual void RefreshTypes(ModelTypeSet types) = 0;
444 }; 427 };
445 428
446 } // namespace syncer 429 } // namespace syncer
447 430
448 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ 431 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698