| 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 #ifndef SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ | 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ |
| 6 #define SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ | 6 #define SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ |
| 7 | 7 |
| 8 #include "services/shell/public/cpp/capabilities.h" | 8 #include "services/shell/public/cpp/capabilities.h" |
| 9 #include "services/shell/public/interfaces/capabilities.mojom.h" | 9 #include "services/shell/public/interfaces/capabilities.mojom.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 | 12 |
| 13 template <> | 13 template <> |
| 14 struct StructTraits<shell::mojom::CapabilityRequest, shell::CapabilityRequest> { | 14 struct StructTraits<shell::mojom::CapabilityRequest::DataView, |
| 15 shell::CapabilityRequest> { |
| 15 static const shell::Classes& classes( | 16 static const shell::Classes& classes( |
| 16 const shell::CapabilityRequest& request) { | 17 const shell::CapabilityRequest& request) { |
| 17 return request.classes; | 18 return request.classes; |
| 18 } | 19 } |
| 19 static const shell::Interfaces& interfaces( | 20 static const shell::Interfaces& interfaces( |
| 20 const shell::CapabilityRequest& request) { | 21 const shell::CapabilityRequest& request) { |
| 21 return request.interfaces; | 22 return request.interfaces; |
| 22 } | 23 } |
| 23 static bool Read(shell::mojom::CapabilityRequestDataView data, | 24 static bool Read(shell::mojom::CapabilityRequestDataView data, |
| 24 shell::CapabilityRequest* out) { | 25 shell::CapabilityRequest* out) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 std::string interface; | 38 std::string interface; |
| 38 if (!interfaces_data_view.Read(i, &interface)) | 39 if (!interfaces_data_view.Read(i, &interface)) |
| 39 return false; | 40 return false; |
| 40 out->interfaces.insert(std::move(interface)); | 41 out->interfaces.insert(std::move(interface)); |
| 41 } | 42 } |
| 42 return true; | 43 return true; |
| 43 } | 44 } |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 template <> | 47 template <> |
| 47 struct StructTraits<shell::mojom::CapabilitySpec, shell::CapabilitySpec> { | 48 struct StructTraits<shell::mojom::CapabilitySpec::DataView, |
| 49 shell::CapabilitySpec> { |
| 48 static const std::map<shell::Class, shell::Interfaces>& provided( | 50 static const std::map<shell::Class, shell::Interfaces>& provided( |
| 49 const shell::CapabilitySpec& spec) { | 51 const shell::CapabilitySpec& spec) { |
| 50 return spec.provided; | 52 return spec.provided; |
| 51 } | 53 } |
| 52 static const std::map<shell::Name, shell::CapabilityRequest>& required( | 54 static const std::map<shell::Name, shell::CapabilityRequest>& required( |
| 53 const shell::CapabilitySpec& spec) { | 55 const shell::CapabilitySpec& spec) { |
| 54 return spec.required; | 56 return spec.required; |
| 55 } | 57 } |
| 56 static bool Read(shell::mojom::CapabilitySpecDataView data, | 58 static bool Read(shell::mojom::CapabilitySpecDataView data, |
| 57 shell::CapabilitySpec* out) { | 59 shell::CapabilitySpec* out) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 out->provided[clazz] = std::move(interfaces); | 76 out->provided[clazz] = std::move(interfaces); |
| 75 } | 77 } |
| 76 | 78 |
| 77 return data.ReadRequired(&out->required); | 79 return data.ReadRequired(&out->required); |
| 78 } | 80 } |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace mojo | 83 } // namespace mojo |
| 82 | 84 |
| 83 #endif // SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ | 85 #endif // SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ |
| OLD | NEW |