diff options
author | maxbogue <maxbogue@chromium.org> | 2015-11-23 11:26:56 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-23 19:27:55 +0000 |
commit | f09d94201b089399747476e4bab4b81a176ba675 (patch) | |
tree | acc8282fdb84ef886346400ef4930f0e6d2f0e9f /sync/api | |
parent | 46afb30171cfbf9e2e0431decc67e9ced81c7716 (diff) | |
download | chromium_src-f09d94201b089399747476e4bab4b81a176ba675.zip chromium_src-f09d94201b089399747476e4bab4b81a176ba675.tar.gz chromium_src-f09d94201b089399747476e4bab4b81a176ba675.tar.bz2 |
[Sync] USS: Add EntityChange.
BUG=536895,543405
Review URL: https://codereview.chromium.org/1458013003
Cr-Commit-Position: refs/heads/master@{#361153}
Diffstat (limited to 'sync/api')
-rw-r--r-- | sync/api/entity_change.cc | 33 | ||||
-rw-r--r-- | sync/api/entity_change.h | 46 | ||||
-rw-r--r-- | sync/api/model_type_service.h | 4 |
3 files changed, 81 insertions, 2 deletions
diff --git a/sync/api/entity_change.cc b/sync/api/entity_change.cc new file mode 100644 index 0000000..e2f2bed --- /dev/null +++ b/sync/api/entity_change.cc @@ -0,0 +1,33 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "sync/api/entity_change.h" + +namespace syncer_v2 { + +// static +EntityChange EntityChange::CreateAdd(std::string client_key, + EntityDataPtr data) { + return EntityChange(client_key, ACTION_ADD, data); +} + +// static +EntityChange EntityChange::CreateUpdate(std::string client_key, + EntityDataPtr data) { + return EntityChange(client_key, ACTION_UPDATE, data); +} + +// static +EntityChange EntityChange::CreateDelete(std::string client_key) { + return EntityChange(client_key, ACTION_DELETE, EntityDataPtr()); +} + +EntityChange::EntityChange(std::string client_key, + ChangeType type, + EntityDataPtr data) + : client_key_(client_key), type_(type), data_(data){}; + +EntityChange::~EntityChange() {} + +} // namespace syncer_v2 diff --git a/sync/api/entity_change.h b/sync/api/entity_change.h new file mode 100644 index 0000000..88e3812 --- /dev/null +++ b/sync/api/entity_change.h @@ -0,0 +1,46 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SYNC_API_ENTITY_CHANGE_H_ +#define SYNC_API_ENTITY_CHANGE_H_ + +#include <string> +#include <vector> + +#include "sync/api/entity_data.h" +#include "sync/base/sync_export.h" + +namespace syncer_v2 { + +class SYNC_EXPORT EntityChange { + public: + enum ChangeType { + ACTION_ADD, + ACTION_UPDATE, + ACTION_DELETE + }; + + static EntityChange CreateAdd(std::string client_key, EntityDataPtr data); + static EntityChange CreateUpdate(std::string client_key, EntityDataPtr data); + static EntityChange CreateDelete(std::string client_key); + + virtual ~EntityChange(); + + std::string client_key() const { return client_key_; } + ChangeType type() const { return type_; } + const EntityData& data() const { return data_.value(); } + + private: + EntityChange(std::string client_key, ChangeType type, EntityDataPtr data); + + const std::string client_key_; + const ChangeType type_; + const EntityDataPtr data_; +}; + +typedef std::vector<EntityChange> EntityChangeList; + +} // namespace syncer_v2 + +#endif // SYNC_API_ENTITY_CHANGE_H_ diff --git a/sync/api/model_type_service.h b/sync/api/model_type_service.h index 473c9c1..c09271b 100644 --- a/sync/api/model_type_service.h +++ b/sync/api/model_type_service.h @@ -10,6 +10,7 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" +#include "sync/api/entity_change.h" #include "sync/api/entity_data.h" #include "sync/api/model_type_change_processor.h" #include "sync/base/sync_export.h" @@ -49,10 +50,9 @@ class SYNC_EXPORT ModelTypeService { EntityDataList entity_data_list) = 0; // Apply changes from the sync server locally. - // TODO(skym): The change type should be in here somehow. virtual syncer::SyncError ApplySyncChanges( MetadataChanges* metadata_changes, - EntityDataList entity_data_list) = 0; + EntityChangeList entity_changes) = 0; // Asynchronously retrieve the sync metadata. virtual void LoadMetadata(MetadataCallback callback) = 0; |