Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: sync/api/entity_data.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/api/entity_change.cc ('k') | sync/api/entity_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 SYNC_API_ENTITY_DATA_H_
6 #define SYNC_API_ENTITY_DATA_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/time/time.h"
14 #include "sync/base/sync_export.h"
15 #include "sync/internal_api/public/util/proto_value_ptr.h"
16 #include "sync/protocol/sync.pb.h"
17
18 namespace syncer_v2 {
19
20 struct EntityData;
21
22 struct SYNC_EXPORT EntityDataTraits {
23 static void SwapValue(EntityData* dest, EntityData* src);
24 static bool HasValue(const EntityData& value);
25 static const EntityData& DefaultValue();
26 };
27
28 typedef syncer::ProtoValuePtr<EntityData, EntityDataTraits> EntityDataPtr;
29 typedef std::vector<EntityDataPtr> EntityDataList;
30 typedef std::map<std::string, EntityDataPtr> EntityDataMap;
31
32 // A light-weight container for sync entity data which represents either
33 // local data created on the ModelTypeService side or remote data created
34 // on ModelTypeWorker.
35 // EntityData is supposed to be wrapped and passed by reference.
36 struct SYNC_EXPORT EntityData {
37 public:
38 EntityData();
39 ~EntityData();
40
41 // 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
43 // a temporary client sync ID.
44 std::string id;
45
46 // A hash based on the client tag and model type.
47 // Used for various map lookups. Should always be available.
48 // Sent to the server as SyncEntity::client_defined_unique_tag.
49 std::string client_tag_hash;
50
51 // Entity name, used mostly for Debug purposes.
52 std::string non_unique_name;
53
54 // Model type specific sync data.
55 sync_pb::EntitySpecifics specifics;
56
57 // Entity creation and modification timestamps.
58 base::Time creation_time;
59 base::Time modification_time;
60
61 // Sync ID of the parent entity. This is supposed to be set only for
62 // hierarchical datatypes (e.g. Bookmarks).
63 std::string parent_id;
64
65 // Unique position of an entity among its siblings. This is supposed to be
66 // set only for datatypes that support positioning (e.g. Bookmarks).
67 sync_pb::UniquePosition unique_position;
68
69 // True if EntityData represents deleted entity; otherwise false.
70 // Note that EntityData would be considered to represent a deletion if its
71 // specifics hasn't been set.
72 bool is_deleted() const { return specifics.ByteSize() == 0; }
73
74 // Transfers this struct's data to EntityDataPtr.
75 // The return value must be assigned into another EntityDataPtr.
76 EntityDataPtr PassToPtr() WARN_UNUSED_RESULT;
77
78 private:
79 friend struct EntityDataTraits;
80 // Used to transfer the data without copying.
81 void Swap(EntityData* other);
82
83 DISALLOW_COPY_AND_ASSIGN(EntityData);
84 };
85
86 } // namespace syncer_v2
87
88 #endif // SYNC_API_ENTITY_DATA_H_
OLDNEW
« no previous file with comments | « sync/api/entity_change.cc ('k') | sync/api/entity_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698