| OLD | NEW |
| (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 #include "mojo/shell/public/cpp/capabilities.h" | |
| 6 | |
| 7 namespace mojo { | |
| 8 | |
| 9 CapabilityRequest::CapabilityRequest() {} | |
| 10 CapabilityRequest::CapabilityRequest(const CapabilityRequest& other) = default; | |
| 11 CapabilityRequest::~CapabilityRequest() {} | |
| 12 | |
| 13 bool CapabilityRequest::operator==(const CapabilityRequest& other) const { | |
| 14 return other.classes == classes && other.interfaces == interfaces; | |
| 15 } | |
| 16 | |
| 17 bool CapabilityRequest::operator<(const CapabilityRequest& other) const { | |
| 18 return std::tie(classes, interfaces) < | |
| 19 std::tie(other.classes, other.interfaces); | |
| 20 } | |
| 21 | |
| 22 CapabilitySpec::CapabilitySpec() {} | |
| 23 CapabilitySpec::CapabilitySpec(const CapabilitySpec& other) = default; | |
| 24 CapabilitySpec::~CapabilitySpec() {} | |
| 25 | |
| 26 bool CapabilitySpec::operator==(const CapabilitySpec& other) const { | |
| 27 return other.provided == provided && other.required == required; | |
| 28 } | |
| 29 | |
| 30 bool CapabilitySpec::operator<(const CapabilitySpec& other) const { | |
| 31 return std::tie(provided, required) < | |
| 32 std::tie(other.provided, other.required); | |
| 33 } | |
| 34 | |
| 35 // static | |
| 36 shell::mojom::CapabilitySpecPtr | |
| 37 TypeConverter<shell::mojom::CapabilitySpecPtr, CapabilitySpec>::Convert( | |
| 38 const CapabilitySpec& input) { | |
| 39 shell::mojom::CapabilitySpecPtr spec(shell::mojom::CapabilitySpec::New()); | |
| 40 spec->provided = | |
| 41 mojo::Map<mojo::String, mojo::Array<mojo::String>>::From(input.provided); | |
| 42 spec->required = | |
| 43 mojo::Map<mojo::String, shell::mojom::CapabilityRequestPtr>::From( | |
| 44 input.required); | |
| 45 return spec; | |
| 46 } | |
| 47 | |
| 48 // static | |
| 49 CapabilitySpec | |
| 50 TypeConverter<CapabilitySpec, shell::mojom::CapabilitySpecPtr>::Convert( | |
| 51 const shell::mojom::CapabilitySpecPtr& input) { | |
| 52 CapabilitySpec spec; | |
| 53 spec.provided = input->provided.To<std::map<Class, Interfaces>>(); | |
| 54 spec.required = | |
| 55 input->required.To<std::map<Name, CapabilityRequest>>(); | |
| 56 return spec; | |
| 57 } | |
| 58 | |
| 59 // static | |
| 60 shell::mojom::CapabilityRequestPtr | |
| 61 TypeConverter<shell::mojom::CapabilityRequestPtr, | |
| 62 CapabilityRequest>::Convert( | |
| 63 const CapabilityRequest& input) { | |
| 64 shell::mojom::CapabilityRequestPtr request( | |
| 65 shell::mojom::CapabilityRequest::New()); | |
| 66 request->classes = mojo::Array<mojo::String>::From(input.classes); | |
| 67 request->interfaces = mojo::Array<mojo::String>::From(input.interfaces); | |
| 68 return request; | |
| 69 } | |
| 70 | |
| 71 // static | |
| 72 CapabilityRequest | |
| 73 TypeConverter<CapabilityRequest, | |
| 74 shell::mojom::CapabilityRequestPtr>::Convert( | |
| 75 const shell::mojom::CapabilityRequestPtr& input) { | |
| 76 CapabilityRequest request; | |
| 77 request.classes = input->classes.To<std::set<std::string>>(); | |
| 78 request.interfaces = input->interfaces.To<std::set<std::string>>(); | |
| 79 return request; | |
| 80 } | |
| 81 | |
| 82 } // namespace mojo | |
| OLD | NEW |