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

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

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

Powered by Google App Engine
This is Rietveld 408576698