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

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

Issue 2611183006: Service Manager: Miscellaneous catalog cleanup (Closed)
Patch Set: Created 3 years, 11 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 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/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "services/catalog/store.h" 9 #include "services/catalog/store.h"
10 10
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 189
190 if (value.HasKey(Store::kServicesKey)) { 190 if (value.HasKey(Store::kServicesKey)) {
191 const base::ListValue* services = nullptr; 191 const base::ListValue* services = nullptr;
192 value.GetList(Store::kServicesKey, &services); 192 value.GetList(Store::kServicesKey, &services);
193 for (size_t i = 0; i < services->GetSize(); ++i) { 193 for (size_t i = 0; i < services->GetSize(); ++i) {
194 const base::DictionaryValue* service = nullptr; 194 const base::DictionaryValue* service = nullptr;
195 services->GetDictionary(i, &service); 195 services->GetDictionary(i, &service);
196 std::unique_ptr<Entry> child = Entry::Deserialize(*service); 196 std::unique_ptr<Entry> child = Entry::Deserialize(*service);
197 if (child) { 197 if (child) {
198 child->set_package(entry.get()); 198 child->set_parent(entry.get());
199 // Caller must assume ownership of these items. 199 entry->children().emplace_back(std::move(child));
200 entry->children_.emplace_back(std::move(child));
201 } 200 }
202 } 201 }
203 } 202 }
204 203
205 return entry; 204 return entry;
206 } 205 }
207 206
208 bool Entry::ProvidesCapability(const std::string& capability) const { 207 bool Entry::ProvidesCapability(const std::string& capability) const {
209 auto it = interface_provider_specs_.find( 208 auto it = interface_provider_specs_.find(
210 service_manager::mojom::kServiceManager_ConnectorSpec); 209 service_manager::mojom::kServiceManager_ConnectorSpec);
(...skipping 16 matching lines...) Expand all
227 const service_manager::InterfaceProviderSpec& spec) { 226 const service_manager::InterfaceProviderSpec& spec) {
228 interface_provider_specs_[name] = spec; 227 interface_provider_specs_[name] = spec;
229 } 228 }
230 229
231 } // catalog 230 } // catalog
232 231
233 namespace mojo { 232 namespace mojo {
234 233
235 // static 234 // static
236 service_manager::mojom::ResolveResultPtr 235 service_manager::mojom::ResolveResultPtr
237 TypeConverter<service_manager::mojom::ResolveResultPtr, 236 TypeConverter<service_manager::mojom::ResolveResultPtr, const catalog::Entry*>
238 catalog::Entry>::Convert(const catalog::Entry& input) { 237 ::Convert(const catalog::Entry* input) {
239 service_manager::mojom::ResolveResultPtr result( 238 service_manager::mojom::ResolveResultPtr result;
240 service_manager::mojom::ResolveResult::New()); 239 if (input) {
241 result->name = input.name(); 240 result = service_manager::mojom::ResolveResult::New();
242 const catalog::Entry& package = input.package() ? *input.package() : input; 241 result->name = input->name();
243 result->resolved_name = package.name(); 242 result->interface_provider_specs = input->interface_provider_specs();
244 result->interface_provider_specs = input.interface_provider_specs(); 243 result->package_path = input->path();
245 if (input.package()) {
246 auto it = package.interface_provider_specs().find(
247 service_manager::mojom::kServiceManager_ConnectorSpec);
248 if (it != package.interface_provider_specs().end())
249 result->package_spec = it->second;
250 } 244 }
251 result->package_path = package.path();
252 return result; 245 return result;
253 } 246 }
254 247
255 // static 248 // static
256 catalog::mojom::EntryPtr 249 catalog::mojom::EntryPtr
257 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( 250 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert(
258 const catalog::Entry& input) { 251 const catalog::Entry& input) {
259 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); 252 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New());
260 result->name = input.name(); 253 result->name = input.name();
261 result->display_name = input.display_name(); 254 result->display_name = input.display_name();
262 return result; 255 return result;
263 } 256 }
264 257
265 } // namespace mojo 258 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698