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

Side by Side Diff: components/sync/api/entity_data.cc

Issue 2401223002: [Sync] Renaming sync/api* to sync/model*. (Closed)
Patch Set: Missed a comment in a DEPS file, and rebasing. Created 4 years, 2 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 | « components/sync/api/entity_data.h ('k') | components/sync/api/entity_data_unittest.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 #include "components/sync/api/entity_data.h"
6
7 #include <algorithm>
8 #include <utility>
9
10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h"
13 #include "components/sync/base/time.h"
14 #include "components/sync/base/unique_position.h"
15 #include "components/sync/protocol/proto_value_conversions.h"
16
17 namespace syncer {
18
19 namespace {
20
21 std::string UniquePositionToString(
22 const sync_pb::UniquePosition& unique_position) {
23 return UniquePosition::FromProto(unique_position).ToDebugString();
24 }
25
26 } // namespace
27
28 EntityData::EntityData() {}
29 EntityData::~EntityData() {}
30
31 void EntityData::Swap(EntityData* other) {
32 id.swap(other->id);
33 client_tag_hash.swap(other->client_tag_hash);
34 non_unique_name.swap(other->non_unique_name);
35
36 specifics.Swap(&other->specifics);
37
38 std::swap(creation_time, other->creation_time);
39 std::swap(modification_time, other->modification_time);
40
41 parent_id.swap(other->parent_id);
42 unique_position.Swap(&other->unique_position);
43 }
44
45 EntityDataPtr EntityData::PassToPtr() {
46 EntityDataPtr target;
47 target.swap_value(this);
48 return target;
49 }
50
51 #define ADD_TO_DICT(dict, value, transform) \
52 dict->SetString(base::ToUpperASCII(#value), transform(value));
53
54 std::unique_ptr<base::DictionaryValue> EntityData::ToDictionaryValue() {
55 std::unique_ptr<base::DictionaryValue> dict =
56 EntitySpecificsToValue(specifics);
57 ADD_TO_DICT(dict, id, );
58 ADD_TO_DICT(dict, client_tag_hash, );
59 ADD_TO_DICT(dict, non_unique_name, );
60 ADD_TO_DICT(dict, parent_id, );
61 ADD_TO_DICT(dict, creation_time, GetTimeDebugString);
62 ADD_TO_DICT(dict, modification_time, GetTimeDebugString);
63 ADD_TO_DICT(dict, unique_position, UniquePositionToString);
64 return dict;
65 }
66
67 #undef ADD_TO_DICT
68
69 void EntityDataTraits::SwapValue(EntityData* dest, EntityData* src) {
70 dest->Swap(src);
71 }
72
73 bool EntityDataTraits::HasValue(const EntityData& value) {
74 return !value.client_tag_hash.empty();
75 }
76
77 const EntityData& EntityDataTraits::DefaultValue() {
78 CR_DEFINE_STATIC_LOCAL(EntityData, default_instance, ());
79 return default_instance;
80 }
81
82 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/api/entity_data.h ('k') | components/sync/api/entity_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698