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

Side by Side Diff: components/sync/test/fake_server/permanent_entity.cc

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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/test/fake_server/permanent_entity.h" 5 #include "components/sync/test/fake_server/permanent_entity.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 9
10 using std::string; 10 using std::string;
11 using syncer::ModelType; 11 using syncer::ModelType;
12 12
13 // The parent tag for children of the root entity. Entities with this parent are 13 // The parent tag for children of the root entity. Entities with this parent are
14 // referred to as top level enities. 14 // referred to as top level enities.
15 static const char kRootParentTag[] = "0"; 15 static const char kRootParentTag[] = "0";
16 16
17 namespace fake_server { 17 namespace fake_server {
18 18
19 PermanentEntity::~PermanentEntity() {} 19 PermanentEntity::~PermanentEntity() {}
20 20
21 // static 21 // static
22 std::unique_ptr<FakeServerEntity> PermanentEntity::Create( 22 std::unique_ptr<FakeServerEntity> PermanentEntity::Create(
23 const ModelType& model_type, 23 const ModelType& model_type,
24 const string& server_tag, 24 const string& server_tag,
25 const string& name, 25 const string& name,
26 const string& parent_server_tag) { 26 const string& parent_server_tag) {
27 CHECK(model_type != syncer::UNSPECIFIED) << "The entity's ModelType is " 27 // The entity's ModelType is invalid.
28 << "invalid."; 28 CHECK(model_type != syncer::UNSPECIFIED);
29 CHECK(!server_tag.empty()) << "A PermanentEntity must have a server tag."; 29 // A PermanentEntity must have a server tag.
30 CHECK(!name.empty()) << "The entity must have a non-empty name."; 30 CHECK(!server_tag.empty());
31 CHECK(!parent_server_tag.empty()) << "A PermanentEntity must have a parent " 31 // The entity must have a non-empty name.
32 << "server tag."; 32 CHECK(!name.empty());
33 CHECK(parent_server_tag != kRootParentTag) << "Top-level entities should not " 33 // A PermanentEntity must have a parent server tag.
34 << "be created with this factory."; 34 CHECK(!parent_server_tag.empty());
35 // Top-level entities should not be created with this factory.
36 CHECK(parent_server_tag != kRootParentTag);
35 37
36 string id = FakeServerEntity::CreateId(model_type, server_tag); 38 string id = FakeServerEntity::CreateId(model_type, server_tag);
37 string parent_id = FakeServerEntity::CreateId(model_type, parent_server_tag); 39 string parent_id = FakeServerEntity::CreateId(model_type, parent_server_tag);
38 sync_pb::EntitySpecifics entity_specifics; 40 sync_pb::EntitySpecifics entity_specifics;
39 AddDefaultFieldValue(model_type, &entity_specifics); 41 AddDefaultFieldValue(model_type, &entity_specifics);
40 return std::unique_ptr<FakeServerEntity>(new PermanentEntity( 42 return std::unique_ptr<FakeServerEntity>(new PermanentEntity(
41 id, model_type, name, parent_id, server_tag, entity_specifics)); 43 id, model_type, name, parent_id, server_tag, entity_specifics));
42 } 44 }
43 45
44 // static 46 // static
45 std::unique_ptr<FakeServerEntity> PermanentEntity::CreateTopLevel( 47 std::unique_ptr<FakeServerEntity> PermanentEntity::CreateTopLevel(
46 const ModelType& model_type) { 48 const ModelType& model_type) {
47 CHECK(model_type != syncer::UNSPECIFIED) << "The entity's ModelType is " 49 // The entity's ModelType is invalid.
48 << "invalid."; 50 CHECK(model_type != syncer::UNSPECIFIED);
49 string server_tag = syncer::ModelTypeToRootTag(model_type); 51 string server_tag = syncer::ModelTypeToRootTag(model_type);
50 string name = syncer::ModelTypeToString(model_type); 52 string name = syncer::ModelTypeToString(model_type);
51 string id = FakeServerEntity::GetTopLevelId(model_type); 53 string id = FakeServerEntity::GetTopLevelId(model_type);
52 sync_pb::EntitySpecifics entity_specifics; 54 sync_pb::EntitySpecifics entity_specifics;
53 AddDefaultFieldValue(model_type, &entity_specifics); 55 AddDefaultFieldValue(model_type, &entity_specifics);
54 return std::unique_ptr<FakeServerEntity>(new PermanentEntity( 56 return std::unique_ptr<FakeServerEntity>(new PermanentEntity(
55 id, model_type, name, kRootParentTag, server_tag, entity_specifics)); 57 id, model_type, name, kRootParentTag, server_tag, entity_specifics));
56 } 58 }
57 59
58 // static 60 // static
59 std::unique_ptr<FakeServerEntity> PermanentEntity::CreateUpdatedNigoriEntity( 61 std::unique_ptr<FakeServerEntity> PermanentEntity::CreateUpdatedNigoriEntity(
60 const sync_pb::SyncEntity& client_entity, 62 const sync_pb::SyncEntity& client_entity,
61 const FakeServerEntity& current_server_entity) { 63 const FakeServerEntity& current_server_entity) {
62 ModelType model_type = current_server_entity.model_type(); 64 ModelType model_type = current_server_entity.model_type();
63 CHECK(model_type == syncer::NIGORI) << "This factory only supports NIGORI " 65 // This factory only supports NIGORI entities.
64 << "entities."; 66 CHECK(model_type == syncer::NIGORI);
65 67
66 return base::WrapUnique<FakeServerEntity>(new PermanentEntity( 68 return base::WrapUnique<FakeServerEntity>(new PermanentEntity(
67 current_server_entity.id(), model_type, current_server_entity.GetName(), 69 current_server_entity.id(), model_type, current_server_entity.GetName(),
68 current_server_entity.GetParentId(), 70 current_server_entity.GetParentId(),
69 syncer::ModelTypeToRootTag(model_type), client_entity.specifics())); 71 syncer::ModelTypeToRootTag(model_type), client_entity.specifics()));
70 } 72 }
71 73
72 PermanentEntity::PermanentEntity(const string& id, 74 PermanentEntity::PermanentEntity(const string& id,
73 const ModelType& model_type, 75 const ModelType& model_type,
74 const string& name, 76 const string& name,
(...skipping 21 matching lines...) Expand all
96 98
97 bool PermanentEntity::IsFolder() const { 99 bool PermanentEntity::IsFolder() const {
98 return true; 100 return true;
99 } 101 }
100 102
101 bool PermanentEntity::IsPermanent() const { 103 bool PermanentEntity::IsPermanent() const {
102 return true; 104 return true;
103 } 105 }
104 106
105 } // namespace fake_server 107 } // namespace fake_server
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698