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

Side by Side Diff: services/catalog/entry.cc

Issue 1910673002: Convert //services 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
« no previous file with comments | « services/catalog/entry.h ('k') | services/catalog/entry_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/catalog/entry.h" 5 #include "services/catalog/entry.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "mojo/util/filename_util.h" 8 #include "mojo/util/filename_util.h"
9 #include "services/catalog/store.h" 9 #include "services/catalog/store.h"
10 #include "services/shell/public/cpp/names.h" 10 #include "services/shell/public/cpp/names.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 } // namespace 101 } // namespace
102 102
103 Entry::Entry() {} 103 Entry::Entry() {}
104 Entry::Entry(const std::string& name) 104 Entry::Entry(const std::string& name)
105 : name_(name), qualifier_(shell::GetNamePath(name)), display_name_(name) {} 105 : name_(name), qualifier_(shell::GetNamePath(name)), display_name_(name) {}
106 Entry::Entry(const Entry& other) = default; 106 Entry::Entry(const Entry& other) = default;
107 Entry::~Entry() {} 107 Entry::~Entry() {}
108 108
109 scoped_ptr<base::DictionaryValue> Entry::Serialize() const { 109 std::unique_ptr<base::DictionaryValue> Entry::Serialize() const {
110 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue); 110 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue);
111 value->SetInteger(Store::kManifestVersionKey, 1); 111 value->SetInteger(Store::kManifestVersionKey, 1);
112 value->SetString(Store::kNameKey, name_); 112 value->SetString(Store::kNameKey, name_);
113 value->SetString(Store::kDisplayNameKey, display_name_); 113 value->SetString(Store::kDisplayNameKey, display_name_);
114 value->SetString(Store::kQualifierKey, qualifier_); 114 value->SetString(Store::kQualifierKey, qualifier_);
115 scoped_ptr<base::DictionaryValue> spec(new base::DictionaryValue); 115 std::unique_ptr<base::DictionaryValue> spec(new base::DictionaryValue);
116 116
117 scoped_ptr<base::DictionaryValue> provided(new base::DictionaryValue); 117 std::unique_ptr<base::DictionaryValue> provided(new base::DictionaryValue);
118 for (const auto& i : capabilities_.provided) { 118 for (const auto& i : capabilities_.provided) {
119 scoped_ptr<base::ListValue> interfaces(new base::ListValue); 119 std::unique_ptr<base::ListValue> interfaces(new base::ListValue);
120 for (const auto& interface_name : i.second) 120 for (const auto& interface_name : i.second)
121 interfaces->AppendString(interface_name); 121 interfaces->AppendString(interface_name);
122 provided->Set(i.first, std::move(interfaces)); 122 provided->Set(i.first, std::move(interfaces));
123 } 123 }
124 spec->Set(Store::kCapabilities_ProvidedKey, std::move(provided)); 124 spec->Set(Store::kCapabilities_ProvidedKey, std::move(provided));
125 125
126 scoped_ptr<base::DictionaryValue> required(new base::DictionaryValue); 126 std::unique_ptr<base::DictionaryValue> required(new base::DictionaryValue);
127 for (const auto& i : capabilities_.required) { 127 for (const auto& i : capabilities_.required) {
128 scoped_ptr<base::DictionaryValue> request(new base::DictionaryValue); 128 std::unique_ptr<base::DictionaryValue> request(new base::DictionaryValue);
129 scoped_ptr<base::ListValue> classes(new base::ListValue); 129 std::unique_ptr<base::ListValue> classes(new base::ListValue);
130 for (const auto& class_name : i.second.classes) 130 for (const auto& class_name : i.second.classes)
131 classes->AppendString(class_name); 131 classes->AppendString(class_name);
132 request->Set(Store::kCapabilities_ClassesKey, std::move(classes)); 132 request->Set(Store::kCapabilities_ClassesKey, std::move(classes));
133 scoped_ptr<base::ListValue> interfaces(new base::ListValue); 133 std::unique_ptr<base::ListValue> interfaces(new base::ListValue);
134 for (const auto& interface_name : i.second.interfaces) 134 for (const auto& interface_name : i.second.interfaces)
135 interfaces->AppendString(interface_name); 135 interfaces->AppendString(interface_name);
136 request->Set(Store::kCapabilities_InterfacesKey, std::move(interfaces)); 136 request->Set(Store::kCapabilities_InterfacesKey, std::move(interfaces));
137 required->Set(i.first, std::move(request)); 137 required->Set(i.first, std::move(request));
138 } 138 }
139 spec->Set(Store::kCapabilities_RequiredKey, std::move(required)); 139 spec->Set(Store::kCapabilities_RequiredKey, std::move(required));
140 140
141 value->Set(Store::kCapabilitiesKey, std::move(spec)); 141 value->Set(Store::kCapabilitiesKey, std::move(spec));
142 return value; 142 return value;
143 } 143 }
144 144
145 // static 145 // static
146 scoped_ptr<Entry> Entry::Deserialize(const base::DictionaryValue& value) { 146 std::unique_ptr<Entry> Entry::Deserialize(const base::DictionaryValue& value) {
147 scoped_ptr<Entry> entry(new Entry); 147 std::unique_ptr<Entry> entry(new Entry);
148 int manifest_version = 0; 148 int manifest_version = 0;
149 if (value.HasKey(Store::kManifestVersionKey)) 149 if (value.HasKey(Store::kManifestVersionKey))
150 CHECK(value.GetInteger(Store::kManifestVersionKey, &manifest_version)); 150 CHECK(value.GetInteger(Store::kManifestVersionKey, &manifest_version));
151 std::string name_string; 151 std::string name_string;
152 if (!value.GetString(Store::kNameKey, &name_string)) { 152 if (!value.GetString(Store::kNameKey, &name_string)) {
153 LOG(ERROR) << "Entry::Deserialize: dictionary has no name key"; 153 LOG(ERROR) << "Entry::Deserialize: dictionary has no name key";
154 return nullptr; 154 return nullptr;
155 } 155 }
156 if (!shell::IsValidName(name_string)) { 156 if (!shell::IsValidName(name_string)) {
157 LOG(WARNING) << "Entry::Deserialize: " << name_string << " is not a valid " 157 LOG(WARNING) << "Entry::Deserialize: " << name_string << " is not a valid "
(...skipping 23 matching lines...) Expand all
181 entry->set_capabilities(BuildCapabilitiesV0(*capabilities)); 181 entry->set_capabilities(BuildCapabilitiesV0(*capabilities));
182 else 182 else
183 entry->set_capabilities(BuildCapabilitiesV1(*capabilities)); 183 entry->set_capabilities(BuildCapabilitiesV1(*capabilities));
184 184
185 if (value.HasKey(Store::kApplicationsKey)) { 185 if (value.HasKey(Store::kApplicationsKey)) {
186 const base::ListValue* applications = nullptr; 186 const base::ListValue* applications = nullptr;
187 value.GetList(Store::kApplicationsKey, &applications); 187 value.GetList(Store::kApplicationsKey, &applications);
188 for (size_t i = 0; i < applications->GetSize(); ++i) { 188 for (size_t i = 0; i < applications->GetSize(); ++i) {
189 const base::DictionaryValue* application = nullptr; 189 const base::DictionaryValue* application = nullptr;
190 applications->GetDictionary(i, &application); 190 applications->GetDictionary(i, &application);
191 scoped_ptr<Entry> child = Entry::Deserialize(*application); 191 std::unique_ptr<Entry> child = Entry::Deserialize(*application);
192 if (child) { 192 if (child) {
193 child->set_package(entry.get()); 193 child->set_package(entry.get());
194 // Caller must assume ownership of these items. 194 // Caller must assume ownership of these items.
195 entry->applications_.insert(child.release()); 195 entry->applications_.insert(child.release());
196 } 196 }
197 } 197 }
198 } 198 }
199 199
200 return entry; 200 return entry;
201 } 201 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 catalog::mojom::EntryPtr 239 catalog::mojom::EntryPtr
240 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( 240 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert(
241 const catalog::Entry& input) { 241 const catalog::Entry& input) {
242 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); 242 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New());
243 result->name = input.name(); 243 result->name = input.name();
244 result->display_name = input.display_name(); 244 result->display_name = input.display_name();
245 return result; 245 return result;
246 } 246 }
247 247
248 } // namespace mojo 248 } // namespace mojo
OLDNEW
« no previous file with comments | « services/catalog/entry.h ('k') | services/catalog/entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698