Chromium Code Reviews| Index: sync/engine/non_blocking_type_processor_core.h |
| diff --git a/sync/engine/non_blocking_type_processor_core.h b/sync/engine/non_blocking_type_processor_core.h |
| index e2263499562f82fe9515b0455ee40b79ac155636..e18618b7e5d926792fe0ddf4dfb5ee70a4c4b8fa 100644 |
| --- a/sync/engine/non_blocking_type_processor_core.h |
| +++ b/sync/engine/non_blocking_type_processor_core.h |
| @@ -6,10 +6,12 @@ |
| #define SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_CORE_H_ |
| #include "base/memory/weak_ptr.h" |
| +#include "base/stl_util.h" |
| #include "base/threading/non_thread_safe.h" |
| #include "sync/base/sync_export.h" |
| #include "sync/engine/commit_contributor.h" |
| #include "sync/engine/non_blocking_sync_common.h" |
| +#include "sync/engine/non_blocking_type_processor_interface.h" |
|
Nicolas Zea
2014/05/28 23:56:16
can forward declare
rlarocque
2014/05/29 20:54:52
Done.
|
| #include "sync/engine/update_handler.h" |
| #include "sync/internal_api/public/base/model_type.h" |
| #include "sync/protocol/sync.pb.h" |
| @@ -21,6 +23,7 @@ class SingleThreadTaskRunner; |
| namespace syncer { |
| class NonBlockingTypeProcessor; |
| +class SyncThreadSyncEntity; |
| // A smart cache for sync types that use message passing (rather than |
| // transactions and the syncable::Directory) to communicate with the sync |
| @@ -28,9 +31,9 @@ class NonBlockingTypeProcessor; |
| // |
| // When the non-blocking sync type wants to talk with the sync server, it will |
| // send a message from its thread to this object on the sync thread. This |
| -// object is responsible for helping to ensure the appropriate sync server |
| -// communication gets scheduled and executed. The response, if any, will be |
| -// returned to the non-blocking sync type's thread eventually. |
| +// object ensures the appropriate sync server communication gets scheduled and |
| +// executed. The response, if any, will be returned to the non-blocking sync |
| +// type's thread eventually. |
| // |
| // This object also has a role to play in communications in the opposite |
| // direction. Sometimes the sync thread will receive changes from the sync |
| @@ -49,8 +52,8 @@ class SYNC_EXPORT NonBlockingTypeProcessorCore |
| public: |
| NonBlockingTypeProcessorCore( |
| ModelType type, |
| - scoped_refptr<base::SequencedTaskRunner> processor_task_runner, |
| - base::WeakPtr<NonBlockingTypeProcessor> processor); |
| + DataTypeState initial_state, |
|
Nicolas Zea
2014/05/28 23:56:16
const ref?
rlarocque
2014/05/29 20:54:52
Done.
|
| + scoped_ptr<NonBlockingTypeProcessorInterface> processor_interface); |
| virtual ~NonBlockingTypeProcessorCore(); |
| ModelType GetModelType() const; |
| @@ -69,20 +72,47 @@ class SYNC_EXPORT NonBlockingTypeProcessorCore |
| virtual void PassiveApplyUpdates(sessions::StatusController* status) OVERRIDE; |
| // Entry point for NonBlockingTypeProcessor to send commit requests. |
| - void RequestCommits(const CommitRequestDataList& request_list); |
| + void EnqueueForCommit(const CommitRequestDataList& request_list); |
| // CommitContributor implementation. |
| virtual scoped_ptr<CommitContribution> GetContribution( |
| size_t max_entries) OVERRIDE; |
| + // Callback for when our contribution gets a response. |
| + void ProcessCommitResponses(const CommitResponseDataList& response_list); |
|
Nicolas Zea
2014/05/28 23:56:16
OnCommitResponse?
rlarocque
2014/05/29 20:54:52
Done.
|
| + |
| base::WeakPtr<NonBlockingTypeProcessorCore> AsWeakPtr(); |
| private: |
| + typedef std::map<std::string, SyncThreadSyncEntity*> EntityMap; |
| + |
| + // Stores a single commit request in this object's internal state. |
| + void StorePendingCommit(const CommitRequestData& request); |
| + |
| + // Returns true if this object has access to enough state that it |
| + // can commit items. This will be false until the initial update |
| + // fetch is complete. |
| + bool CanCommitItems() const; |
| + |
| + // Initializes the parts of a commit entity that are the responsibility of |
| + // this class, and not the SyncThreadSyncEntity. Some fields, like the |
| + // client-assigned ID, can only be set by an entity with knowledge of the |
| + // entire data type's state. |
| + void HelpInitializeCommitEntity(sync_pb::SyncEntity* commit_entity); |
| + |
| ModelType type_; |
| - sync_pb::DataTypeProgressMarker progress_marker_; |
| - scoped_refptr<base::SequencedTaskRunner> processor_task_runner_; |
| - base::WeakPtr<NonBlockingTypeProcessor> processor_; |
| + // State that applies to the entire model type. |
| + DataTypeState data_type_state_; |
| + |
| + // Abstraction around the NonBlockingTypeProcessor so this class |
| + // doesn't need to know about its specific implementation or |
| + // which thread it's on. This makes it easier to write tests. |
| + scoped_ptr<NonBlockingTypeProcessorInterface> processor_interface_; |
| + |
| + // A map of per-entity information known to this object. |
| + EntityMap entities_; |
| + STLValueDeleter<EntityMap> entities_deleter_; |
| base::WeakPtrFactory<NonBlockingTypeProcessorCore> weak_ptr_factory_; |
| }; |