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

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

Issue 2495523002: Change 'LOG(ERROR)' to 'VLOG(1)' in mojo bits. (Closed)
Patch Set: badmessage Created 4 years, 1 month 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 | « no previous file | services/service_manager/public/cpp/lib/interface_registry.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/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 #include "services/service_manager/public/cpp/names.h" 10 #include "services/service_manager/public/cpp/names.h"
11 11
12 namespace catalog { 12 namespace catalog {
13 namespace { 13 namespace {
14 14
15 bool ReadStringSet(const base::ListValue& list_value, 15 bool ReadStringSet(const base::ListValue& list_value,
16 std::set<std::string>* string_set) { 16 std::set<std::string>* string_set) {
17 DCHECK(string_set); 17 DCHECK(string_set);
18 for (const auto& value_value : list_value) { 18 for (const auto& value_value : list_value) {
19 std::string value; 19 std::string value;
20 if (!value_value->GetAsString(&value)) { 20 if (!value_value->GetAsString(&value)) {
21 LOG(ERROR) << "Entry::Deserialize: list member must be a string"; 21 VLOG(1) << "Entry::Deserialize: list member must be a string";
22 return false; 22 return false;
23 } 23 }
24 string_set->insert(value); 24 string_set->insert(value);
25 } 25 }
26 return true; 26 return true;
27 } 27 }
28 28
29 bool ReadStringSetFromValue(const base::Value& value, 29 bool ReadStringSetFromValue(const base::Value& value,
30 std::set<std::string>* string_set) { 30 std::set<std::string>* string_set) {
31 const base::ListValue* list_value = nullptr; 31 const base::ListValue* list_value = nullptr;
32 if (!value.GetAsList(&list_value)) { 32 if (!value.GetAsList(&list_value)) {
33 LOG(ERROR) << "Entry::Deserialize: Value must be a list."; 33 VLOG(1) << "Entry::Deserialize: Value must be a list.";
34 return false; 34 return false;
35 } 35 }
36 return ReadStringSet(*list_value, string_set); 36 return ReadStringSet(*list_value, string_set);
37 } 37 }
38 38
39 bool BuildInterfaceProviderSpec( 39 bool BuildInterfaceProviderSpec(
40 const base::DictionaryValue& value, 40 const base::DictionaryValue& value,
41 service_manager::InterfaceProviderSpec* interface_provider_specs) { 41 service_manager::InterfaceProviderSpec* interface_provider_specs) {
42 DCHECK(interface_provider_specs); 42 DCHECK(interface_provider_specs);
43 const base::DictionaryValue* provides_value = nullptr; 43 const base::DictionaryValue* provides_value = nullptr;
44 if (value.HasKey(Store::kInterfaceProviderSpecs_ProvidesKey) && 44 if (value.HasKey(Store::kInterfaceProviderSpecs_ProvidesKey) &&
45 !value.GetDictionary(Store::kInterfaceProviderSpecs_ProvidesKey, 45 !value.GetDictionary(Store::kInterfaceProviderSpecs_ProvidesKey,
46 &provides_value)) { 46 &provides_value)) {
47 LOG(ERROR) << "Entry::Deserialize: " 47 VLOG(1) << "Entry::Deserialize: "
48 << Store::kInterfaceProviderSpecs_ProvidesKey 48 << Store::kInterfaceProviderSpecs_ProvidesKey
49 << " must be a dictionary."; 49 << " must be a dictionary.";
50 return false; 50 return false;
51 } 51 }
52 if (provides_value) { 52 if (provides_value) {
53 base::DictionaryValue::Iterator it(*provides_value); 53 base::DictionaryValue::Iterator it(*provides_value);
54 for(; !it.IsAtEnd(); it.Advance()) { 54 for(; !it.IsAtEnd(); it.Advance()) {
55 service_manager::InterfaceSet interfaces; 55 service_manager::InterfaceSet interfaces;
56 if (!ReadStringSetFromValue(it.value(), &interfaces)) { 56 if (!ReadStringSetFromValue(it.value(), &interfaces)) {
57 LOG(ERROR) << "Entry::Deserialize: Invalid interface list in provided " 57 VLOG(1) << "Entry::Deserialize: Invalid interface list in provided "
58 << " capabilities dictionary"; 58 << " capabilities dictionary";
59 return false; 59 return false;
60 } 60 }
61 interface_provider_specs->provides[it.key()] = interfaces; 61 interface_provider_specs->provides[it.key()] = interfaces;
62 } 62 }
63 } 63 }
64 64
65 const base::DictionaryValue* requires_value = nullptr; 65 const base::DictionaryValue* requires_value = nullptr;
66 if (value.HasKey(Store::kInterfaceProviderSpecs_RequiresKey) && 66 if (value.HasKey(Store::kInterfaceProviderSpecs_RequiresKey) &&
67 !value.GetDictionary(Store::kInterfaceProviderSpecs_RequiresKey, 67 !value.GetDictionary(Store::kInterfaceProviderSpecs_RequiresKey,
68 &requires_value)) { 68 &requires_value)) {
69 LOG(ERROR) << "Entry::Deserialize: " 69 VLOG(1) << "Entry::Deserialize: "
70 << Store::kInterfaceProviderSpecs_RequiresKey 70 << Store::kInterfaceProviderSpecs_RequiresKey
71 << " must be a dictionary."; 71 << " must be a dictionary.";
72 return false; 72 return false;
73 } 73 }
74 if (requires_value) { 74 if (requires_value) {
75 base::DictionaryValue::Iterator it(*requires_value); 75 base::DictionaryValue::Iterator it(*requires_value);
76 for (; !it.IsAtEnd(); it.Advance()) { 76 for (; !it.IsAtEnd(); it.Advance()) {
77 service_manager::CapabilitySet capabilities; 77 service_manager::CapabilitySet capabilities;
78 const base::ListValue* entry_value = nullptr; 78 const base::ListValue* entry_value = nullptr;
79 if (!it.value().GetAsList(&entry_value)) { 79 if (!it.value().GetAsList(&entry_value)) {
80 LOG(ERROR) << "Entry::Deserialize: " 80 VLOG(1) << "Entry::Deserialize: "
81 << Store::kInterfaceProviderSpecs_RequiresKey 81 << Store::kInterfaceProviderSpecs_RequiresKey
82 << " entry must be a list."; 82 << " entry must be a list.";
83 return false; 83 return false;
84 } 84 }
85 if (!ReadStringSet(*entry_value, &capabilities)) { 85 if (!ReadStringSet(*entry_value, &capabilities)) {
86 LOG(ERROR) << "Entry::Deserialize: Invalid capabilities list in " 86 VLOG(1) << "Entry::Deserialize: Invalid capabilities list in "
87 << "requires dictionary."; 87 << "requires dictionary.";
88 return false; 88 return false;
89 } 89 }
90 90
91 interface_provider_specs->requires[it.key()] = capabilities; 91 interface_provider_specs->requires[it.key()] = capabilities;
92 } 92 }
93 } 93 }
94 return true; 94 return true;
95 } 95 }
96 96
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return value; 134 return value;
135 } 135 }
136 136
137 // static 137 // static
138 std::unique_ptr<Entry> Entry::Deserialize(const base::DictionaryValue& value) { 138 std::unique_ptr<Entry> Entry::Deserialize(const base::DictionaryValue& value) {
139 auto entry = base::MakeUnique<Entry>(); 139 auto entry = base::MakeUnique<Entry>();
140 140
141 // Name. 141 // Name.
142 std::string name_string; 142 std::string name_string;
143 if (!value.GetString(Store::kNameKey, &name_string)) { 143 if (!value.GetString(Store::kNameKey, &name_string)) {
144 LOG(ERROR) << "Entry::Deserialize: dictionary has no " 144 VLOG(1) << "Entry::Deserialize: dictionary has no "
145 << Store::kNameKey << " key"; 145 << Store::kNameKey << " key";
146 return nullptr; 146 return nullptr;
147 } 147 }
148 if (!service_manager::IsValidName(name_string)) { 148 if (!service_manager::IsValidName(name_string)) {
149 LOG(ERROR) << "Entry::Deserialize: " << name_string << " is not a valid " 149 VLOG(1) << "Entry::Deserialize: " << name_string << " is not a valid "
150 << "Mojo name"; 150 << "Mojo name";
151 return nullptr; 151 return nullptr;
152 } 152 }
153 entry->set_name(name_string); 153 entry->set_name(name_string);
154 154
155 // Human-readable name. 155 // Human-readable name.
156 std::string display_name; 156 std::string display_name;
157 if (!value.GetString(Store::kDisplayNameKey, &display_name)) { 157 if (!value.GetString(Store::kDisplayNameKey, &display_name)) {
158 LOG(ERROR) << "Entry::Deserialize: dictionary has no " 158 VLOG(1) << "Entry::Deserialize: dictionary has no "
159 << Store::kDisplayNameKey << " key"; 159 << Store::kDisplayNameKey << " key";
160 return nullptr; 160 return nullptr;
161 } 161 }
162 entry->set_display_name(display_name); 162 entry->set_display_name(display_name);
163 163
164 // InterfaceProvider specs. 164 // InterfaceProvider specs.
165 const base::DictionaryValue* interface_provider_specs = nullptr; 165 const base::DictionaryValue* interface_provider_specs = nullptr;
166 if (!value.GetDictionary(Store::kInterfaceProviderSpecsKey, 166 if (!value.GetDictionary(Store::kInterfaceProviderSpecsKey,
167 &interface_provider_specs)) { 167 &interface_provider_specs)) {
168 LOG(ERROR) << "Entry::Deserialize: dictionary has no " 168 VLOG(1) << "Entry::Deserialize: dictionary has no "
169 << Store::kInterfaceProviderSpecsKey << " key"; 169 << Store::kInterfaceProviderSpecsKey << " key";
170 return nullptr; 170 return nullptr;
171 } 171 }
172 172
173 base::DictionaryValue::Iterator it(*interface_provider_specs); 173 base::DictionaryValue::Iterator it(*interface_provider_specs);
174 for (; !it.IsAtEnd(); it.Advance()) { 174 for (; !it.IsAtEnd(); it.Advance()) {
175 const base::DictionaryValue* spec_value = nullptr; 175 const base::DictionaryValue* spec_value = nullptr;
176 if (!interface_provider_specs->GetDictionary(it.key(), &spec_value)) { 176 if (!interface_provider_specs->GetDictionary(it.key(), &spec_value)) {
177 LOG(ERROR) << "Entry::Deserialize: value of InterfaceProvider map for " 177 VLOG(1) << "Entry::Deserialize: value of InterfaceProvider map for "
178 << "key: " << it.key() << " not a dictionary."; 178 << "key: " << it.key() << " not a dictionary.";
179 return nullptr; 179 return nullptr;
180 } 180 }
181 181
182 service_manager::InterfaceProviderSpec spec; 182 service_manager::InterfaceProviderSpec spec;
183 if (!BuildInterfaceProviderSpec(*spec_value, &spec)) { 183 if (!BuildInterfaceProviderSpec(*spec_value, &spec)) {
184 LOG(ERROR) << "Entry::Deserialize: failed to build InterfaceProvider " 184 VLOG(1) << "Entry::Deserialize: failed to build InterfaceProvider "
185 << "spec for key: " << it.key(); 185 << "spec for key: " << it.key();
186 return nullptr; 186 return nullptr;
187 } 187 }
188 entry->AddInterfaceProviderSpec(it.key(), spec); 188 entry->AddInterfaceProviderSpec(it.key(), spec);
189 } 189 }
190 190
191 if (value.HasKey(Store::kServicesKey)) { 191 if (value.HasKey(Store::kServicesKey)) {
192 const base::ListValue* services = nullptr; 192 const base::ListValue* services = nullptr;
193 value.GetList(Store::kServicesKey, &services); 193 value.GetList(Store::kServicesKey, &services);
194 for (size_t i = 0; i < services->GetSize(); ++i) { 194 for (size_t i = 0; i < services->GetSize(); ++i) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 catalog::mojom::EntryPtr 257 catalog::mojom::EntryPtr
258 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( 258 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert(
259 const catalog::Entry& input) { 259 const catalog::Entry& input) {
260 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); 260 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New());
261 result->name = input.name(); 261 result->name = input.name();
262 result->display_name = input.display_name(); 262 result->display_name = input.display_name();
263 return result; 263 return result;
264 } 264 }
265 265
266 } // namespace mojo 266 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | services/service_manager/public/cpp/lib/interface_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698