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

Side by Side Diff: services/service_manager/public/cpp/capabilities_struct_traits.h

Issue 2420253002: Rename shell namespace to service_manager (Closed)
Patch Set: . Created 4 years, 2 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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_
7 7
8 #include "services/service_manager/public/cpp/capabilities.h" 8 #include "services/service_manager/public/cpp/capabilities.h"
9 #include "services/service_manager/public/interfaces/capabilities.mojom.h" 9 #include "services/service_manager/public/interfaces/capabilities.mojom.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 template <> 13 template <>
14 struct StructTraits<shell::mojom::CapabilitySpec::DataView, 14 struct StructTraits<service_manager::mojom::CapabilitySpec::DataView,
15 shell::CapabilitySpec> { 15 service_manager::CapabilitySpec> {
16 static const std::map<shell::Class, shell::Interfaces>& provided( 16 static const std::map<service_manager::Class, service_manager::Interfaces>&
17 const shell::CapabilitySpec& spec) { 17 provided(const service_manager::CapabilitySpec& spec) {
18 return spec.provided; 18 return spec.provided;
19 } 19 }
20 static const std::map<shell::Name, shell::Classes>& required( 20 static const std::map<service_manager::Name, service_manager::Classes>&
21 const shell::CapabilitySpec& spec) { 21 required(const service_manager::CapabilitySpec& spec) {
22 return spec.required; 22 return spec.required;
23 } 23 }
24 static bool Read(shell::mojom::CapabilitySpecDataView data, 24 static bool Read(service_manager::mojom::CapabilitySpecDataView data,
25 shell::CapabilitySpec* out) { 25 service_manager::CapabilitySpec* out) {
26 return data.ReadProvided(&out->provided) && 26 return data.ReadProvided(&out->provided) &&
27 data.ReadRequired(&out->required); 27 data.ReadRequired(&out->required);
28 } 28 }
29 }; 29 };
30 30
31 template <> 31 template <>
32 struct StructTraits<shell::mojom::Interfaces::DataView, 32 struct StructTraits<service_manager::mojom::Interfaces::DataView,
33 shell::Interfaces> { 33 service_manager::Interfaces> {
34 static std::vector<std::string> interfaces(const shell::Interfaces& spec) { 34 static std::vector<std::string> interfaces(
35 const service_manager::Interfaces& spec) {
35 std::vector<std::string> vec; 36 std::vector<std::string> vec;
36 for (const auto& interface_name : spec) 37 for (const auto& interface_name : spec)
37 vec.push_back(interface_name); 38 vec.push_back(interface_name);
38 return vec; 39 return vec;
39 } 40 }
40 static bool Read(shell::mojom::InterfacesDataView data, 41 static bool Read(service_manager::mojom::InterfacesDataView data,
41 shell::Interfaces* out) { 42 service_manager::Interfaces* out) {
42 ArrayDataView<StringDataView> interfaces_data_view; 43 ArrayDataView<StringDataView> interfaces_data_view;
43 data.GetInterfacesDataView(&interfaces_data_view); 44 data.GetInterfacesDataView(&interfaces_data_view);
44 for (size_t i = 0; i < interfaces_data_view.size(); ++i) { 45 for (size_t i = 0; i < interfaces_data_view.size(); ++i) {
45 std::string interface_name; 46 std::string interface_name;
46 if (!interfaces_data_view.Read(i, &interface_name)) 47 if (!interfaces_data_view.Read(i, &interface_name))
47 return false; 48 return false;
48 out->insert(std::move(interface_name)); 49 out->insert(std::move(interface_name));
49 } 50 }
50 return true; 51 return true;
51 } 52 }
52 }; 53 };
53 54
54 template <> 55 template <>
55 struct StructTraits<shell::mojom::Classes::DataView, 56 struct StructTraits<service_manager::mojom::Classes::DataView,
56 shell::Classes> { 57 service_manager::Classes> {
57 static std::vector<std::string> classes(const shell::Classes& spec) { 58 static std::vector<std::string> classes(
59 const service_manager::Classes& spec) {
58 std::vector<std::string> vec; 60 std::vector<std::string> vec;
59 for (const auto& class_name : spec) 61 for (const auto& class_name : spec)
60 vec.push_back(class_name); 62 vec.push_back(class_name);
61 return vec; 63 return vec;
62 } 64 }
63 static bool Read(shell::mojom::ClassesDataView data, shell::Classes* out) { 65 static bool Read(service_manager::mojom::ClassesDataView data,
66 service_manager::Classes* out) {
64 ArrayDataView<StringDataView> classes_data_view; 67 ArrayDataView<StringDataView> classes_data_view;
65 data.GetClassesDataView(&classes_data_view); 68 data.GetClassesDataView(&classes_data_view);
66 for (size_t i = 0; i < classes_data_view.size(); ++i) { 69 for (size_t i = 0; i < classes_data_view.size(); ++i) {
67 std::string class_name; 70 std::string class_name;
68 if (!classes_data_view.Read(i, &class_name)) 71 if (!classes_data_view.Read(i, &class_name))
69 return false; 72 return false;
70 out->insert(std::move(class_name)); 73 out->insert(std::move(class_name));
71 } 74 }
72 return true; 75 return true;
73 } 76 }
74 }; 77 };
75 78
76 } // namespace mojo 79 } // namespace mojo
77 80
78 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ 81 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « services/service_manager/public/cpp/capabilities.typemap ('k') | services/service_manager/public/cpp/connect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698