| 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_H_ | 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_H_ |
| 6 #define SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_H_ | 6 #define SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "services/shell/public/interfaces/shell_resolver.mojom.h" | 12 #include "services/shell/public/interfaces/shell_resolver.mojom.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace shell { |
| 15 |
| 15 using Class = std::string; | 16 using Class = std::string; |
| 16 using Classes = std::set<std::string>; | 17 using Classes = std::set<std::string>; |
| 17 using Interface = std::string; | 18 using Interface = std::string; |
| 18 using Interfaces = std::set<std::string>; | 19 using Interfaces = std::set<std::string>; |
| 19 using Name = std::string; | 20 using Name = std::string; |
| 20 | 21 |
| 21 // See comments in services/shell/public/interfaces/capabilities.mojom for a | 22 // See comments in services/shell/public/interfaces/capabilities.mojom for a |
| 22 // description of CapabilityRequest and CapabilitySpec. | 23 // description of CapabilityRequest and CapabilitySpec. |
| 23 | 24 |
| 24 struct CapabilityRequest { | 25 struct CapabilityRequest { |
| 25 CapabilityRequest(); | 26 CapabilityRequest(); |
| 26 CapabilityRequest(const CapabilityRequest& other); | 27 CapabilityRequest(const CapabilityRequest& other); |
| 27 ~CapabilityRequest(); | 28 ~CapabilityRequest(); |
| 28 bool operator==(const CapabilityRequest& other) const; | 29 bool operator==(const CapabilityRequest& other) const; |
| 29 bool operator<(const CapabilityRequest& other) const; | 30 bool operator<(const CapabilityRequest& other) const; |
| 30 Classes classes; | 31 Classes classes; |
| 31 Interfaces interfaces; | 32 Interfaces interfaces; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 struct CapabilitySpec { | 35 struct CapabilitySpec { |
| 35 CapabilitySpec(); | 36 CapabilitySpec(); |
| 36 CapabilitySpec(const CapabilitySpec& other); | 37 CapabilitySpec(const CapabilitySpec& other); |
| 37 ~CapabilitySpec(); | 38 ~CapabilitySpec(); |
| 38 bool operator==(const CapabilitySpec& other) const; | 39 bool operator==(const CapabilitySpec& other) const; |
| 39 bool operator<(const CapabilitySpec& other) const; | 40 bool operator<(const CapabilitySpec& other) const; |
| 40 std::map<Class, Interfaces> provided; | 41 std::map<Class, Interfaces> provided; |
| 41 std::map<Name, CapabilityRequest> required; | 42 std::map<Name, CapabilityRequest> required; |
| 42 }; | 43 }; |
| 43 | 44 |
| 45 } // namespace shell |
| 46 |
| 47 namespace mojo { |
| 48 |
| 44 template <> | 49 template <> |
| 45 struct TypeConverter<shell::mojom::CapabilitySpecPtr, CapabilitySpec> { | 50 struct TypeConverter<shell::mojom::CapabilitySpecPtr, shell::CapabilitySpec> { |
| 46 static shell::mojom::CapabilitySpecPtr Convert( | 51 static shell::mojom::CapabilitySpecPtr Convert( |
| 47 const CapabilitySpec& input); | 52 const shell::CapabilitySpec& input); |
| 48 }; | 53 }; |
| 54 |
| 49 template <> | 55 template <> |
| 50 struct TypeConverter<CapabilitySpec, shell::mojom::CapabilitySpecPtr> { | 56 struct TypeConverter<shell::CapabilitySpec, shell::mojom::CapabilitySpecPtr> { |
| 51 static CapabilitySpec Convert( | 57 static shell::CapabilitySpec Convert( |
| 52 const shell::mojom::CapabilitySpecPtr& input); | 58 const shell::mojom::CapabilitySpecPtr& input); |
| 53 }; | 59 }; |
| 54 | 60 |
| 55 template <> | 61 template <> |
| 56 struct TypeConverter<shell::mojom::CapabilityRequestPtr, | 62 struct TypeConverter<shell::mojom::CapabilityRequestPtr, |
| 57 CapabilityRequest> { | 63 shell::CapabilityRequest> { |
| 58 static shell::mojom::CapabilityRequestPtr Convert( | 64 static shell::mojom::CapabilityRequestPtr Convert( |
| 59 const CapabilityRequest& input); | 65 const shell::CapabilityRequest& input); |
| 60 }; | 66 }; |
| 67 |
| 61 template <> | 68 template <> |
| 62 struct TypeConverter<CapabilityRequest, | 69 struct TypeConverter<shell::CapabilityRequest, |
| 63 shell::mojom::CapabilityRequestPtr> { | 70 shell::mojom::CapabilityRequestPtr> { |
| 64 static CapabilityRequest Convert( | 71 static shell::CapabilityRequest Convert( |
| 65 const shell::mojom::CapabilityRequestPtr& input); | 72 const shell::mojom::CapabilityRequestPtr& input); |
| 66 }; | 73 }; |
| 74 |
| 67 } // namespace mojo | 75 } // namespace mojo |
| 68 | 76 |
| 69 #endif // SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_H_ | 77 #endif // SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_H_ |
| OLD | NEW |