OLD | NEW |
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 "services/catalog/store.h" | 8 #include "services/catalog/store.h" |
9 #include "services/shell/public/cpp/names.h" | 9 #include "services/shell/public/cpp/names.h" |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 116 } |
117 } | 117 } |
118 return true; | 118 return true; |
119 } | 119 } |
120 | 120 |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 Entry::Entry() {} | 123 Entry::Entry() {} |
124 Entry::Entry(const std::string& name) | 124 Entry::Entry(const std::string& name) |
125 : name_(name), qualifier_(shell::GetNamePath(name)), display_name_(name) {} | 125 : name_(name), qualifier_(shell::GetNamePath(name)), display_name_(name) {} |
| 126 Entry::Entry(const Entry& other) = default; |
126 Entry::~Entry() {} | 127 Entry::~Entry() {} |
127 | 128 |
128 std::unique_ptr<base::DictionaryValue> Entry::Serialize() const { | 129 std::unique_ptr<base::DictionaryValue> Entry::Serialize() const { |
129 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 130 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
130 value->SetInteger(Store::kManifestVersionKey, 1); | 131 value->SetInteger(Store::kManifestVersionKey, 1); |
131 value->SetString(Store::kNameKey, name_); | 132 value->SetString(Store::kNameKey, name_); |
132 value->SetString(Store::kDisplayNameKey, display_name_); | 133 value->SetString(Store::kDisplayNameKey, display_name_); |
133 value->SetString(Store::kQualifierKey, qualifier_); | 134 value->SetString(Store::kQualifierKey, qualifier_); |
134 std::unique_ptr<base::DictionaryValue> spec(new base::DictionaryValue); | 135 std::unique_ptr<base::DictionaryValue> spec(new base::DictionaryValue); |
135 | 136 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 if (value.HasKey(Store::kServicesKey)) { | 234 if (value.HasKey(Store::kServicesKey)) { |
234 const base::ListValue* services = nullptr; | 235 const base::ListValue* services = nullptr; |
235 value.GetList(Store::kServicesKey, &services); | 236 value.GetList(Store::kServicesKey, &services); |
236 for (size_t i = 0; i < services->GetSize(); ++i) { | 237 for (size_t i = 0; i < services->GetSize(); ++i) { |
237 const base::DictionaryValue* service = nullptr; | 238 const base::DictionaryValue* service = nullptr; |
238 services->GetDictionary(i, &service); | 239 services->GetDictionary(i, &service); |
239 std::unique_ptr<Entry> child = Entry::Deserialize(*service); | 240 std::unique_ptr<Entry> child = Entry::Deserialize(*service); |
240 if (child) { | 241 if (child) { |
241 child->set_package(entry.get()); | 242 child->set_package(entry.get()); |
242 // Caller must assume ownership of these items. | 243 // Caller must assume ownership of these items. |
243 entry->children_.emplace_back(std::move(child)); | 244 entry->services_.insert(child.release()); |
244 } | 245 } |
245 } | 246 } |
246 } | 247 } |
247 | 248 |
248 return entry; | 249 return entry; |
249 } | 250 } |
250 | 251 |
251 bool Entry::ProvidesClass(const std::string& clazz) const { | 252 bool Entry::ProvidesClass(const std::string& clazz) const { |
252 return capabilities_.provided.find(clazz) != capabilities_.provided.end(); | 253 return capabilities_.provided.find(clazz) != capabilities_.provided.end(); |
253 } | 254 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 catalog::mojom::EntryPtr | 288 catalog::mojom::EntryPtr |
288 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( | 289 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( |
289 const catalog::Entry& input) { | 290 const catalog::Entry& input) { |
290 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); | 291 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); |
291 result->name = input.name(); | 292 result->name = input.name(); |
292 result->display_name = input.display_name(); | 293 result->display_name = input.display_name(); |
293 return result; | 294 return result; |
294 } | 295 } |
295 | 296 |
296 } // namespace mojo | 297 } // namespace mojo |
OLD | NEW |