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

Side by Side Diff: components/sync/engine_impl/loopback_server/persistent_unique_client_entity.cc

Issue 2887343002: wip 3 (Closed)
Patch Set: cleanup Created 3 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/engine_impl/loopback_server/persistent_unique_client_e ntity.h" 5 #include "components/sync/engine_impl/loopback_server/persistent_unique_client_e ntity.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "components/sync/base/hash_util.h"
8 #include "components/sync/engine_impl/loopback_server/persistent_permanent_entit y.h" 9 #include "components/sync/engine_impl/loopback_server/persistent_permanent_entit y.h"
9 #include "components/sync/protocol/sync.pb.h" 10 #include "components/sync/protocol/sync.pb.h"
10 11
11 using std::string; 12 using std::string;
12 13
13 namespace syncer { 14 namespace syncer {
14 15
15 PersistentUniqueClientEntity::PersistentUniqueClientEntity( 16 PersistentUniqueClientEntity::PersistentUniqueClientEntity(
16 const string& id, 17 const string& id,
17 ModelType model_type, 18 ModelType model_type,
(...skipping 20 matching lines...) Expand all
38 "tag."; 39 "tag.";
39 ModelType model_type = GetModelTypeFromSpecifics(client_entity.specifics()); 40 ModelType model_type = GetModelTypeFromSpecifics(client_entity.specifics());
40 string id = EffectiveIdForClientTaggedEntity(client_entity); 41 string id = EffectiveIdForClientTaggedEntity(client_entity);
41 return std::unique_ptr<LoopbackServerEntity>(new PersistentUniqueClientEntity( 42 return std::unique_ptr<LoopbackServerEntity>(new PersistentUniqueClientEntity(
42 id, model_type, client_entity.version(), client_entity.name(), 43 id, model_type, client_entity.version(), client_entity.name(),
43 client_entity.client_defined_unique_tag(), client_entity.specifics(), 44 client_entity.client_defined_unique_tag(), client_entity.specifics(),
44 client_entity.ctime(), client_entity.mtime())); 45 client_entity.ctime(), client_entity.mtime()));
45 } 46 }
46 47
47 // static 48 // static
49 std::unique_ptr<LoopbackServerEntity>
50 PersistentUniqueClientEntity::CreateForInjection(
51 const string& name,
52 const sync_pb::EntitySpecifics& entity_specifics) {
53 ModelType model_type = GetModelTypeFromSpecifics(entity_specifics);
54 string client_defined_unique_tag = GenerateSyncableHash(model_type, name);
55 string id =
56 LoopbackServerEntity::CreateId(model_type, client_defined_unique_tag);
57 return std::unique_ptr<LoopbackServerEntity>(new PersistentUniqueClientEntity(
58 id, model_type, 0, name, client_defined_unique_tag, entity_specifics,
59 1337, 1337));
60 }
61
62 // static
48 std::string PersistentUniqueClientEntity::EffectiveIdForClientTaggedEntity( 63 std::string PersistentUniqueClientEntity::EffectiveIdForClientTaggedEntity(
49 const sync_pb::SyncEntity& entity) { 64 const sync_pb::SyncEntity& entity) {
50 return LoopbackServerEntity::CreateId( 65 return LoopbackServerEntity::CreateId(
51 GetModelTypeFromSpecifics(entity.specifics()), 66 GetModelTypeFromSpecifics(entity.specifics()),
52 entity.client_defined_unique_tag()); 67 entity.client_defined_unique_tag());
53 } 68 }
54 69
55 bool PersistentUniqueClientEntity::RequiresParentId() const { 70 bool PersistentUniqueClientEntity::RequiresParentId() const {
56 return false; 71 return false;
57 } 72 }
(...skipping 12 matching lines...) Expand all
70 void PersistentUniqueClientEntity::SerializeAsProto( 85 void PersistentUniqueClientEntity::SerializeAsProto(
71 sync_pb::SyncEntity* proto) const { 86 sync_pb::SyncEntity* proto) const {
72 LoopbackServerEntity::SerializeBaseProtoFields(proto); 87 LoopbackServerEntity::SerializeBaseProtoFields(proto);
73 88
74 proto->set_client_defined_unique_tag(client_defined_unique_tag_); 89 proto->set_client_defined_unique_tag(client_defined_unique_tag_);
75 proto->set_ctime(creation_time_); 90 proto->set_ctime(creation_time_);
76 proto->set_mtime(last_modified_time_); 91 proto->set_mtime(last_modified_time_);
77 } 92 }
78 93
79 } // namespace syncer 94 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698