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

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

Issue 2319973003: [USS] Implement SharedModelTypeProcessor::GetAllNodes for USS (Closed)
Patch Set: change structure of the info a little bit Created 4 years, 3 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/model_type_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/sync/api/entity_data.h" 5 #include "components/sync/api/entity_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h"
12 #include "components/sync/base/time.h"
13 #include "components/sync/base/unique_position.h"
14 #include "components/sync/protocol/proto_value_conversions.h"
10 15
11 namespace syncer_v2 { 16 namespace syncer_v2 {
12 17
18 namespace {
pavely 2016/09/14 17:15:30 nit: new line after "namespace syncer_v2 {" and be
maxbogue 2016/09/14 17:58:02 Since there's already a newline after namespace sy
Gang Wu 2016/09/15 17:12:47 Done.
Gang Wu 2016/09/15 17:12:47 Done.
19 std::string UniquePositionToString(
20 const sync_pb::UniquePosition& unique_position) {
21 return syncer::UniquePosition::FromProto(unique_position).ToDebugString();
22 }
23 } // namespace
24
13 EntityData::EntityData() {} 25 EntityData::EntityData() {}
14 EntityData::~EntityData() {} 26 EntityData::~EntityData() {}
15 27
16 void EntityData::Swap(EntityData* other) { 28 void EntityData::Swap(EntityData* other) {
17 id.swap(other->id); 29 id.swap(other->id);
18 client_tag_hash.swap(other->client_tag_hash); 30 client_tag_hash.swap(other->client_tag_hash);
19 non_unique_name.swap(other->non_unique_name); 31 non_unique_name.swap(other->non_unique_name);
20 32
21 specifics.Swap(&other->specifics); 33 specifics.Swap(&other->specifics);
22 34
23 std::swap(creation_time, other->creation_time); 35 std::swap(creation_time, other->creation_time);
24 std::swap(modification_time, other->modification_time); 36 std::swap(modification_time, other->modification_time);
25 37
26 parent_id.swap(other->parent_id); 38 parent_id.swap(other->parent_id);
27 unique_position.Swap(&other->unique_position); 39 unique_position.Swap(&other->unique_position);
28 } 40 }
29 41
30 EntityDataPtr EntityData::PassToPtr() { 42 EntityDataPtr EntityData::PassToPtr() {
31 EntityDataPtr target; 43 EntityDataPtr target;
32 target.swap_value(this); 44 target.swap_value(this);
33 return target; 45 return target;
34 } 46 }
35 47
48 #define ADD_TO_DICT(dict, value, transform) \
maxbogue 2016/09/14 17:58:02 Despite this being how proto_value_conversions doe
Gang Wu 2016/09/15 17:12:47 Acknowledged.
49 dict->SetString(base::ToUpperASCII(#value), transform(value));
50
51 std::unique_ptr<base::DictionaryValue> EntityData::ToDictionaryValue() {
52 std::unique_ptr<base::DictionaryValue> dict =
53 syncer::EntitySpecificsToValue(specifics);
54 ADD_TO_DICT(dict, id, );
55 ADD_TO_DICT(dict, client_tag_hash, );
56 ADD_TO_DICT(dict, non_unique_name, );
57 ADD_TO_DICT(dict, parent_id, );
58 ADD_TO_DICT(dict, creation_time, syncer::GetTimeDebugString);
59 ADD_TO_DICT(dict, modification_time, syncer::GetTimeDebugString);
60 ADD_TO_DICT(dict, unique_position, UniquePositionToString);
61 return dict;
62 }
63
64 #undef ADD_TO_DICT
65
36 void EntityDataTraits::SwapValue(EntityData* dest, EntityData* src) { 66 void EntityDataTraits::SwapValue(EntityData* dest, EntityData* src) {
37 dest->Swap(src); 67 dest->Swap(src);
38 } 68 }
39 69
40 bool EntityDataTraits::HasValue(const EntityData& value) { 70 bool EntityDataTraits::HasValue(const EntityData& value) {
41 return !value.client_tag_hash.empty(); 71 return !value.client_tag_hash.empty();
42 } 72 }
43 73
44 const EntityData& EntityDataTraits::DefaultValue() { 74 const EntityData& EntityDataTraits::DefaultValue() {
45 CR_DEFINE_STATIC_LOCAL(EntityData, default_instance, ()); 75 CR_DEFINE_STATIC_LOCAL(EntityData, default_instance, ());
46 return default_instance; 76 return default_instance;
47 } 77 }
48 78
49 } // namespace syncer_v2 79 } // namespace syncer_v2
OLDNEW
« no previous file with comments | « components/sync/api/entity_data.h ('k') | components/sync/api/model_type_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698