Chromium Code Reviews| Index: sync/engine/model_type_sync_worker_impl.h |
| diff --git a/sync/engine/model_type_sync_worker_impl.h b/sync/engine/model_type_sync_worker_impl.h |
| index 6905c5081c571e37625dcbcf0c7bf17e8bc62be6..11e2ccde982761b2888d0e21ef4447c5c97641ed 100644 |
| --- a/sync/engine/model_type_sync_worker_impl.h |
| +++ b/sync/engine/model_type_sync_worker_impl.h |
| @@ -10,11 +10,13 @@ |
| #include "base/threading/non_thread_safe.h" |
| #include "sync/base/sync_export.h" |
| #include "sync/engine/commit_contributor.h" |
| +#include "sync/engine/cryptographer_provider.h" |
| #include "sync/engine/model_type_sync_worker.h" |
| #include "sync/engine/nudge_handler.h" |
| #include "sync/engine/update_handler.h" |
| #include "sync/internal_api/public/base/model_type.h" |
| #include "sync/internal_api/public/non_blocking_sync_common.h" |
| +#include "sync/internal_api/public/sync_encryption_handler.h" |
| #include "sync/protocol/sync.pb.h" |
| namespace base { |
| @@ -51,14 +53,22 @@ class SYNC_EXPORT ModelTypeSyncWorkerImpl : public UpdateHandler, |
| public ModelTypeSyncWorker, |
| public base::NonThreadSafe { |
| public: |
| - ModelTypeSyncWorkerImpl(ModelType type, |
| - const DataTypeState& initial_state, |
| - NudgeHandler* nudge_handler, |
| - scoped_ptr<ModelTypeSyncProxy> type_sync_proxy); |
| + ModelTypeSyncWorkerImpl( |
| + ModelType type, |
| + const DataTypeState& initial_state, |
| + const UpdateResponseDataList& saved_inapplicable_updates, |
| + CryptographerProvider* cryptographer_provider, |
| + NudgeHandler* nudge_handler, |
| + scoped_ptr<ModelTypeSyncProxy> type_sync_proxy); |
| virtual ~ModelTypeSyncWorkerImpl(); |
| ModelType GetModelType() const; |
| + bool IsEncryptionRequired() const; |
| + void SetEncryptionKeyName(const std::string& name); |
| + |
| + void OnCryptographerStateChanged(); |
| + |
| // UpdateHandler implementation. |
| virtual void GetDownloadProgress( |
| sync_pb::DataTypeProgressMarker* progress_marker) const OVERRIDE; |
| @@ -87,20 +97,39 @@ class SYNC_EXPORT ModelTypeSyncWorkerImpl : public UpdateHandler, |
| private: |
| typedef std::map<std::string, EntityTracker*> EntityMap; |
| + typedef std::map<std::string, UpdateResponseData*> UpdateMap; |
| // Stores a single commit request in this object's internal state. |
| void StorePendingCommit(const CommitRequestData& request); |
| - // Returns true if all data type state required for commits is available. In |
| - // practice, this means that it returns true from the time this object first |
| - // receives notice of a successful update fetch from the server. |
| - bool CanCommitItems() const; |
| + // Returns true if this type has successfully fetched all available updates |
| + // from the server at least once. Our state may or may not be stale, but at |
| + // least we know that it was valid at some point in the past. |
| + bool IsTypeInitialized() const; |
| + |
| + // Returns true if this type is prepared to commit items. |
| + // Currently, this depends on having downloaded the initial data and having |
| + // the |
| + // encryption settings in a good state. |
|
stanisc
2014/07/30 00:30:05
merge with the previous line
Nicolas Zea
2014/07/30 00:34:16
nit: merge onto previous line
rlarocque
2014/07/30 21:56:01
Done.
|
| + bool CanCommitItems(Cryptographer* cryptographer) const; |
| // Initializes the parts of a commit entity that are the responsibility of |
| // this class, and not the EntityTracker. 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); |
| + void HelpInitializeCommitEntity(Cryptographer* cryptographer, |
| + sync_pb::SyncEntity* commit_entity); |
| + |
| + // Attempts to decrypt pending updates stored in the EntityMap. If |
| + // successful, will remove the update from the its EntityTracker and forward |
| + // it to the proxy thread for application. |
| + void TryDecryptPendingUpdates(); |
| + |
| + // Attempts to decrypt the given specifics. Assumes |
| + // cryptographer->CanDecrypt(specifics) returned true. |
| + static bool DecryptSpecifics(Cryptographer* cryptographer, |
|
stanisc
2014/07/30 00:30:04
Consider calling this TryDecryptSpecifics. Also co
rlarocque
2014/07/30 21:56:01
I'm reluctant to call it TryDecryptSpecifics() bec
|
| + const sync_pb::EntitySpecifics& in, |
| + sync_pb::EntitySpecifics* out); |
| ModelType type_; |
| @@ -111,6 +140,10 @@ class SYNC_EXPORT ModelTypeSyncWorkerImpl : public UpdateHandler, |
| // This is NULL when no proxy is connected.. |
| scoped_ptr<ModelTypeSyncProxy> type_sync_proxy_; |
| + // A helper to provide access to the syncable::Directory's cryptographer. |
| + // Not owned. |
| + CryptographerProvider* cryptographer_provider_; |
| + |
| // Interface used to access and send nudges to the sync scheduler. Not owned. |
| NudgeHandler* nudge_handler_; |