Chromium Code Reviews| 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(), |
| 39 client_entity.client_defined_unique_tag(), | 38 client_entity.client_defined_unique_tag(), |
| 40 client_entity.specifics(), | 39 client_entity.specifics(), |
| 41 client_entity.ctime(), | 40 client_entity.ctime(), |
| 42 client_entity.mtime()); | 41 client_entity.mtime()); |
| 43 } | 42 } |
| 44 | 43 |
| 45 // static | 44 // static |
| 46 FakeServerEntity* UniqueClientEntity::CreateUpdatedVersion( | 45 FakeServerEntity* UniqueClientEntity::CreateUpdatedVersion( |
| 47 const sync_pb::SyncEntity& client_entity, | 46 const sync_pb::SyncEntity& client_entity, |
| 48 FakeServerEntity* current_server_entity) { | 47 FakeServerEntity* current_server_entity) { |
| 48 CHECK(current_server_entity != NULL) << "An existing server entity must be " | |
|
rlarocque
2014/06/09 21:28:48
I think the "!= NULL" is redundant here.
pval...(no longer on Chromium)
2014/06/09 23:29:27
removed per the top-level comment
| |
| 49 << "provided."; | |
| 49 return new UniqueClientEntity(client_entity.id_string(), | 50 return new UniqueClientEntity(client_entity.id_string(), |
| 50 current_server_entity->GetModelType(), | 51 current_server_entity->GetModelType(), |
| 51 client_entity.version(), | 52 client_entity.version(), |
| 52 client_entity.name(), | 53 client_entity.name(), |
| 53 client_entity.parent_id_string(), | 54 client_entity.parent_id_string(), |
| 54 client_entity.client_defined_unique_tag(), | 55 client_entity.client_defined_unique_tag(), |
| 55 client_entity.specifics(), | 56 client_entity.specifics(), |
| 56 client_entity.ctime(), | 57 client_entity.ctime(), |
| 57 client_entity.mtime()); | 58 client_entity.mtime()); |
| 58 } | 59 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 98 |
| 98 bool UniqueClientEntity::IsDeleted() const { | 99 bool UniqueClientEntity::IsDeleted() const { |
| 99 return false; | 100 return false; |
| 100 } | 101 } |
| 101 | 102 |
| 102 bool UniqueClientEntity::IsFolder() const { | 103 bool UniqueClientEntity::IsFolder() const { |
| 103 return false; | 104 return false; |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace fake_server | 107 } // namespace fake_server |
| OLD | NEW |