1 // Copyright 2015 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_SYNC_MODEL_ENTITY_CHANGE_H_ 6 #define COMPONENTS_SYNC_MODEL_ENTITY_CHANGE_H_ 7 8 #include <memory> 9 #include <string> 10 #include <vector> 11 12 #include "base/macros.h" 13 #include "components/sync/model/entity_data.h" 14 15 namespace syncer { 16 17 class EntityChange { 18 public: 19 enum ChangeType { ACTION_ADD, ACTION_UPDATE, ACTION_DELETE }; 20 21 static std::unique_ptr<EntityChange> CreateAdd(const std::string& storage_key, 22 EntityData data); 23 static std::unique_ptr<EntityChange> CreateUpdate( 24 const std::string& storage_key, 25 EntityData data); 26 static std::unique_ptr<EntityChange> CreateDelete( 27 const std::string& storage_key); 28 29 virtual ~EntityChange(); 30 storage_key()31 std::string storage_key() const { return storage_key_; } type()32 ChangeType type() const { return type_; } data()33 const EntityData& data() const { return data_; } 34 35 private: 36 EntityChange(const std::string& storage_key, 37 ChangeType type, 38 EntityData data); 39 40 std::string storage_key_; 41 ChangeType type_; 42 EntityData data_; 43 44 DISALLOW_COPY_AND_ASSIGN(EntityChange); 45 }; 46 47 using EntityChangeList = std::vector<std::unique_ptr<EntityChange>>; 48 49 } // namespace syncer 50 51 #endif // COMPONENTS_SYNC_MODEL_ENTITY_CHANGE_H_ 52