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

Side by Side Diff: components/sync/test/fake_server/bookmark_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/bookmark_entity.h" 5 #include "components/sync/test/fake_server/bookmark_entity.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 8
9 using std::string; 9 using std::string;
10 10
11 namespace fake_server { 11 namespace fake_server {
12 namespace { 12 namespace {
13 13
14 // Returns true if and only if |client_entity| is a bookmark. 14 // Returns true if and only if |client_entity| is a bookmark.
15 bool IsBookmark(const sync_pb::SyncEntity& client_entity) { 15 bool IsBookmark(const sync_pb::SyncEntity& client_entity) {
16 return syncer::GetModelType(client_entity) == syncer::BOOKMARKS; 16 return syncer::GetModelType(client_entity) == syncer::BOOKMARKS;
17 } 17 }
18 18
19 } // namespace 19 } // namespace
20 20
21 BookmarkEntity::~BookmarkEntity() {} 21 BookmarkEntity::~BookmarkEntity() {}
22 22
23 // static 23 // static
24 std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateNew( 24 std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateNew(
25 const sync_pb::SyncEntity& client_entity, 25 const sync_pb::SyncEntity& client_entity,
26 const string& parent_id, 26 const string& parent_id,
27 const string& client_guid) { 27 const string& client_guid) {
28 CHECK_EQ(0, client_entity.version()) << "New entities must have version = 0."; 28 // New entities must have version = 0.
29 CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark."; 29 CHECK_EQ(0, client_entity.version());
30 // The given entity must be a bookmark.
31 CHECK(IsBookmark(client_entity));
30 32
31 const string id = 33 const string id =
32 FakeServerEntity::CreateId(syncer::BOOKMARKS, base::GenerateGUID()); 34 FakeServerEntity::CreateId(syncer::BOOKMARKS, base::GenerateGUID());
33 const string originator_cache_guid = client_guid; 35 const string originator_cache_guid = client_guid;
34 const string originator_client_item_id = client_entity.id_string(); 36 const string originator_client_item_id = client_entity.id_string();
35 37
36 return std::unique_ptr<FakeServerEntity>(new BookmarkEntity( 38 return std::unique_ptr<FakeServerEntity>(new BookmarkEntity(
37 id, client_entity.version(), client_entity.name(), originator_cache_guid, 39 id, client_entity.version(), client_entity.name(), originator_cache_guid,
38 originator_client_item_id, client_entity.unique_position(), 40 originator_client_item_id, client_entity.unique_position(),
39 client_entity.specifics(), client_entity.folder(), parent_id, 41 client_entity.specifics(), client_entity.folder(), parent_id,
40 client_entity.ctime(), client_entity.mtime())); 42 client_entity.ctime(), client_entity.mtime()));
41 } 43 }
42 44
43 // static 45 // static
44 std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateUpdatedVersion( 46 std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateUpdatedVersion(
45 const sync_pb::SyncEntity& client_entity, 47 const sync_pb::SyncEntity& client_entity,
46 const FakeServerEntity& current_server_entity, 48 const FakeServerEntity& current_server_entity,
47 const string& parent_id) { 49 const string& parent_id) {
48 CHECK_NE(0, client_entity.version()) << "Existing entities must not have a " 50 // Existing entities must not have a version = 0.
49 << "version = 0."; 51 CHECK_NE(0, client_entity.version());
50 CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark."; 52 // The given entity must be a bookmark.
53 CHECK(IsBookmark(client_entity));
51 54
52 const BookmarkEntity& current_bookmark_entity = 55 const BookmarkEntity& current_bookmark_entity =
53 static_cast<const BookmarkEntity&>(current_server_entity); 56 static_cast<const BookmarkEntity&>(current_server_entity);
54 const string originator_cache_guid = 57 const string originator_cache_guid =
55 current_bookmark_entity.originator_cache_guid_; 58 current_bookmark_entity.originator_cache_guid_;
56 const string originator_client_item_id = 59 const string originator_client_item_id =
57 current_bookmark_entity.originator_client_item_id_; 60 current_bookmark_entity.originator_client_item_id_;
58 61
59 return std::unique_ptr<FakeServerEntity>(new BookmarkEntity( 62 return std::unique_ptr<FakeServerEntity>(new BookmarkEntity(
60 client_entity.id_string(), client_entity.version(), client_entity.name(), 63 client_entity.id_string(), client_entity.version(), client_entity.name(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 113
111 sync_pb::UniquePosition* unique_position = proto->mutable_unique_position(); 114 sync_pb::UniquePosition* unique_position = proto->mutable_unique_position();
112 unique_position->CopyFrom(unique_position_); 115 unique_position->CopyFrom(unique_position_);
113 } 116 }
114 117
115 bool BookmarkEntity::IsFolder() const { 118 bool BookmarkEntity::IsFolder() const {
116 return is_folder_; 119 return is_folder_;
117 } 120 }
118 121
119 } // namespace fake_server 122 } // namespace fake_server
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698