| OLD | NEW |
| 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 "sync/test/fake_server/unique_client_entity.h" | 5 #include "sync/test/fake_server/unique_client_entity.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| 11 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" |
| 12 #include "sync/protocol/sync.pb.h" | 12 #include "sync/protocol/sync.pb.h" |
| 13 #include "sync/test/fake_server/fake_server_entity.h" | 13 #include "sync/test/fake_server/fake_server_entity.h" |
| 14 | 14 |
| 15 using std::string; | 15 using std::string; |
| 16 | 16 |
| 17 using syncer::ModelType; | 17 using syncer::ModelType; |
| 18 | 18 |
| 19 namespace fake_server { | 19 namespace fake_server { |
| 20 | 20 |
| 21 UniqueClientEntity::~UniqueClientEntity() { } | 21 UniqueClientEntity::~UniqueClientEntity() { } |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 FakeServerEntity* UniqueClientEntity::CreateNew( | 24 FakeServerEntity* UniqueClientEntity::CreateNew( |
| 25 const sync_pb::SyncEntity& client_entity) { | 25 const sync_pb::SyncEntity& client_entity) { |
| 26 DCHECK(client_entity.has_client_defined_unique_tag()); | 26 CHECK(client_entity.has_client_defined_unique_tag()) |
| 27 DCHECK(!client_entity.folder()); | 27 << "A UniqueClientEntity must have a client-defined unique tag."; |
| 28 DCHECK(!client_entity.deleted()); | |
| 29 ModelType model_type = | 28 ModelType model_type = |
| 30 syncer::GetModelTypeFromSpecifics(client_entity.specifics()); | 29 syncer::GetModelTypeFromSpecifics(client_entity.specifics()); |
| 31 string id = client_entity.version() == 0 ? | 30 string id = client_entity.version() == 0 ? |
| 32 FakeServerEntity::CreateId(model_type, base::GenerateGUID()) : | 31 FakeServerEntity::CreateId(model_type, base::GenerateGUID()) : |
| 33 client_entity.id_string(); | 32 client_entity.id_string(); |
| 34 return new UniqueClientEntity(id, | 33 return new UniqueClientEntity(id, |
| 35 model_type, | 34 model_type, |
| 36 client_entity.version(), | 35 client_entity.version(), |
| 37 client_entity.name(), | 36 client_entity.name(), |
| 38 client_entity.parent_id_string(), | 37 client_entity.parent_id_string(), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 96 |
| 98 bool UniqueClientEntity::IsDeleted() const { | 97 bool UniqueClientEntity::IsDeleted() const { |
| 99 return false; | 98 return false; |
| 100 } | 99 } |
| 101 | 100 |
| 102 bool UniqueClientEntity::IsFolder() const { | 101 bool UniqueClientEntity::IsFolder() const { |
| 103 return false; | 102 return false; |
| 104 } | 103 } |
| 105 | 104 |
| 106 } // namespace fake_server | 105 } // namespace fake_server |
| OLD | NEW |