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