| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 for (size_t i = 0; i < classes_data_view.size(); ++i) { | 28 for (size_t i = 0; i < classes_data_view.size(); ++i) { |
| 29 std::string clazz; | 29 std::string clazz; |
| 30 if (!classes_data_view.Read(i, &clazz)) | 30 if (!classes_data_view.Read(i, &clazz)) |
| 31 return false; | 31 return false; |
| 32 out->classes.insert(std::move(clazz)); | 32 out->classes.insert(std::move(clazz)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 ArrayDataView<StringDataView> interfaces_data_view; | 35 ArrayDataView<StringDataView> interfaces_data_view; |
| 36 data.GetInterfacesDataView(&interfaces_data_view); | 36 data.GetInterfacesDataView(&interfaces_data_view); |
| 37 for (size_t i = 0; i < interfaces_data_view.size(); ++i) { | 37 for (size_t i = 0; i < interfaces_data_view.size(); ++i) { |
| 38 std::string interface; | 38 std::string interface_name; |
| 39 if (!interfaces_data_view.Read(i, &interface)) | 39 if (!interfaces_data_view.Read(i, &interface_name)) |
| 40 return false; | 40 return false; |
| 41 out->interfaces.insert(std::move(interface)); | 41 out->interfaces.insert(std::move(interface_name)); |
| 42 } | 42 } |
| 43 return true; | 43 return true; |
| 44 } | 44 } |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 template <> | 47 template <> |
| 48 struct StructTraits<shell::mojom::CapabilitySpec::DataView, | 48 struct StructTraits<shell::mojom::CapabilitySpec::DataView, |
| 49 shell::CapabilitySpec> { | 49 shell::CapabilitySpec> { |
| 50 static const std::map<shell::Class, shell::Interfaces>& provided( | 50 static const std::map<shell::Class, shell::Interfaces>& provided( |
| 51 const shell::CapabilitySpec& spec) { | 51 const shell::CapabilitySpec& spec) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 63 | 63 |
| 64 for (size_t i = 0; i < provided_data_view.keys().size(); ++i) { | 64 for (size_t i = 0; i < provided_data_view.keys().size(); ++i) { |
| 65 std::string clazz; | 65 std::string clazz; |
| 66 if (!provided_data_view.keys().Read(i, &clazz)) | 66 if (!provided_data_view.keys().Read(i, &clazz)) |
| 67 return false; | 67 return false; |
| 68 | 68 |
| 69 std::vector<std::string> interfaces_vec; | 69 std::vector<std::string> interfaces_vec; |
| 70 if (!provided_data_view.values().Read(i, &interfaces_vec)) | 70 if (!provided_data_view.values().Read(i, &interfaces_vec)) |
| 71 return false; | 71 return false; |
| 72 std::set<std::string> interfaces; | 72 std::set<std::string> interfaces; |
| 73 for (const auto& interface : interfaces_vec) | 73 for (const auto& interface_name : interfaces_vec) |
| 74 interfaces.insert(interface); | 74 interfaces.insert(interface_name); |
| 75 | 75 |
| 76 out->provided[clazz] = std::move(interfaces); | 76 out->provided[clazz] = std::move(interfaces); |
| 77 } | 77 } |
| 78 | 78 |
| 79 return data.ReadRequired(&out->required); | 79 return data.ReadRequired(&out->required); |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace mojo | 83 } // namespace mojo |
| 84 | 84 |
| 85 #endif // SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ | 85 #endif // SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_STRUCT_TRAITS_H_ |
| OLD | NEW |