OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_SYNC_API_ENTITY_DATA_H_ | 5 #ifndef COMPONENTS_SYNC_API_ENTITY_DATA_H_ |
6 #define COMPONENTS_SYNC_API_ENTITY_DATA_H_ | 6 #define COMPONENTS_SYNC_API_ENTITY_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "components/sync/base/proto_value_ptr.h" | 14 #include "components/sync/base/proto_value_ptr.h" |
15 #include "components/sync/base/sync_export.h" | |
16 #include "components/sync/protocol/sync.pb.h" | 15 #include "components/sync/protocol/sync.pb.h" |
17 | 16 |
18 namespace syncer_v2 { | 17 namespace syncer_v2 { |
19 | 18 |
20 struct EntityData; | 19 struct EntityData; |
21 | 20 |
22 struct SYNC_EXPORT EntityDataTraits { | 21 struct EntityDataTraits { |
23 static void SwapValue(EntityData* dest, EntityData* src); | 22 static void SwapValue(EntityData* dest, EntityData* src); |
24 static bool HasValue(const EntityData& value); | 23 static bool HasValue(const EntityData& value); |
25 static const EntityData& DefaultValue(); | 24 static const EntityData& DefaultValue(); |
26 }; | 25 }; |
27 | 26 |
28 typedef syncer::ProtoValuePtr<EntityData, EntityDataTraits> EntityDataPtr; | 27 typedef syncer::ProtoValuePtr<EntityData, EntityDataTraits> EntityDataPtr; |
29 typedef std::vector<EntityDataPtr> EntityDataList; | 28 typedef std::vector<EntityDataPtr> EntityDataList; |
30 typedef std::map<std::string, EntityDataPtr> EntityDataMap; | 29 typedef std::map<std::string, EntityDataPtr> EntityDataMap; |
31 | 30 |
32 // A light-weight container for sync entity data which represents either | 31 // A light-weight container for sync entity data which represents either |
33 // local data created on the ModelTypeService side or remote data created | 32 // local data created on the ModelTypeService side or remote data created |
34 // on ModelTypeWorker. | 33 // on ModelTypeWorker. |
35 // EntityData is supposed to be wrapped and passed by reference. | 34 // EntityData is supposed to be wrapped and passed by reference. |
36 struct SYNC_EXPORT EntityData { | 35 struct EntityData { |
37 public: | 36 public: |
38 EntityData(); | 37 EntityData(); |
39 ~EntityData(); | 38 ~EntityData(); |
40 | 39 |
41 // Typically this is a server assigned sync ID, although for a local change | 40 // Typically this is a server assigned sync ID, although for a local change |
42 // that represents a new entity this field might be either empty or contain | 41 // that represents a new entity this field might be either empty or contain |
43 // a temporary client sync ID. | 42 // a temporary client sync ID. |
44 std::string id; | 43 std::string id; |
45 | 44 |
46 // A hash based on the client tag and model type. | 45 // A hash based on the client tag and model type. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 friend struct EntityDataTraits; | 78 friend struct EntityDataTraits; |
80 // Used to transfer the data without copying. | 79 // Used to transfer the data without copying. |
81 void Swap(EntityData* other); | 80 void Swap(EntityData* other); |
82 | 81 |
83 DISALLOW_COPY_AND_ASSIGN(EntityData); | 82 DISALLOW_COPY_AND_ASSIGN(EntityData); |
84 }; | 83 }; |
85 | 84 |
86 } // namespace syncer_v2 | 85 } // namespace syncer_v2 |
87 | 86 |
88 #endif // COMPONENTS_SYNC_API_ENTITY_DATA_H_ | 87 #endif // COMPONENTS_SYNC_API_ENTITY_DATA_H_ |
OLD | NEW |