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

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

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

Powered by Google App Engine
This is Rietveld 408576698