diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-26 09:57:48 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-26 09:57:48 +0000 |
commit | a74bfd94b772bd2fd2fb6a4c86ab7fa28bae5e09 (patch) | |
tree | cd65affbec838521ffaaa82797e59e9d0d5b3bfe /sync/internal_api/public | |
parent | 599bdcf987a713e054225e9d9908374cd95c05c7 (diff) | |
download | chromium_src-a74bfd94b772bd2fd2fb6a4c86ab7fa28bae5e09.zip chromium_src-a74bfd94b772bd2fd2fb6a4c86ab7fa28bae5e09.tar.gz chromium_src-a74bfd94b772bd2fd2fb6a4c86ab7fa28bae5e09.tar.bz2 |
Introduce NonBlockingDataTypeController
The NonBlockingDataTypeController tracks the sync state of
a non-blocking data type and sends signals to its components from the UI
thread. It is responsible for enabling and disabling sync for a data
type according to user preference and the availbility of the sync
backend.
This CL also includes some changes to the NonBlockingDataTypeProcessor,
which is currently just a stub of what will eventually become
non-blocking sync's model thread component, so that it can be used in
testing NonBlockingDataTypeController.
BUG=351005
Review URL: https://codereview.chromium.org/249843002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266344 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/public')
-rw-r--r-- | sync/internal_api/public/non_blocking_type_processor.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/sync/internal_api/public/non_blocking_type_processor.h b/sync/internal_api/public/non_blocking_type_processor.h index 0198c27..3745088 100644 --- a/sync/internal_api/public/non_blocking_type_processor.h +++ b/sync/internal_api/public/non_blocking_type_processor.h @@ -24,8 +24,20 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe { NonBlockingTypeProcessor(ModelType type); virtual ~NonBlockingTypeProcessor(); + // Returns true if this object believes that sync is preferred for this type. + // + // By "preferred", we mean that a policy decision has been made that this + // type should be synced. Most of the time this is controlled by a user + // clicking a checkbox on the settings page. + // + // The canonical preferred state is based on SyncPrefs on the UI thread. At + // best, this value is stale and may lag behind the one set on the UI thread. + // Before this type has registered with the UI thread, it's mostly just an + // informed guess. + bool IsPreferred() const; + // Returns true if the handshake with sync thread is complete. - bool IsEnabled() const; + bool IsConnected() const; // Returns the model type handled by this processor. ModelType GetModelType() const; @@ -33,10 +45,14 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe { // Starts the handshake with the sync thread. void Enable(SyncCoreProxy* core_proxy); - // Severs all ties to the sync thread. + // Severs all ties to the sync thread and may delete local sync state. // Another call to Enable() can be used to re-establish this connection. void Disable(); + // Severs all ties to the sync thread. + // Another call to Enable() can be used to re-establish this connection. + void Disconnect(); + // Callback used to process the handshake response. void OnConnect(base::WeakPtr<NonBlockingTypeProcessorCore> core, scoped_refptr<base::SequencedTaskRunner> sync_thread); @@ -46,7 +62,14 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe { private: ModelType type_; sync_pb::DataTypeProgressMarker progress_marker_; - bool enabled_; + + // Whether or not sync is preferred for this type. This is a cached copy of + // the canonical copy information on the UI thread. + bool is_preferred_; + + // Whether or not this object has completed its initial handshake with the + // SyncCoreProxy. + bool is_connected_; base::WeakPtr<NonBlockingTypeProcessorCore> core_; scoped_refptr<base::SequencedTaskRunner> sync_thread_; |