| Index: mojo/shell/public/cpp/lib/capabilities.cc
|
| diff --git a/mojo/shell/public/cpp/lib/capabilities.cc b/mojo/shell/public/cpp/lib/capabilities.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..60dda30f9453a34a371de3193def43a116774f78
|
| --- /dev/null
|
| +++ b/mojo/shell/public/cpp/lib/capabilities.cc
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "mojo/shell/public/cpp/capabilities.h"
|
| +
|
| +namespace mojo {
|
| +namespace caps {
|
| +
|
| +bool CapabilityRequest::operator==(const CapabilityRequest& other) const {
|
| + return other.classes == classes && other.interfaces == interfaces;
|
| +}
|
| +
|
| +bool CapabilitySpec::operator==(const CapabilitySpec& other) const {
|
| + return other.provided == provided && other.required == required;
|
| +}
|
| +
|
| +} // namespace caps
|
| +
|
| +// static
|
| +shell::mojom::CapabilitySpecPtr
|
| +TypeConverter<shell::mojom::CapabilitySpecPtr, caps::CapabilitySpec>::Convert(
|
| + const caps::CapabilitySpec& input) {
|
| + shell::mojom::CapabilitySpecPtr spec(shell::mojom::CapabilitySpec::New());
|
| + spec->provided =
|
| + mojo::Map<mojo::String, mojo::Array<mojo::String>>::From(input.provided);
|
| + spec->required =
|
| + mojo::Map<mojo::String, shell::mojom::CapabilityRequestPtr>::From(
|
| + input.required);
|
| + return spec;
|
| +}
|
| +
|
| +// static
|
| +caps::CapabilitySpec
|
| +TypeConverter<caps::CapabilitySpec, shell::mojom::CapabilitySpecPtr>::Convert(
|
| + const shell::mojom::CapabilitySpecPtr& input) {
|
| + caps::CapabilitySpec spec;
|
| + spec.provided = input->provided.To<std::map<caps::Class, caps::Interfaces>>();
|
| + spec.required =
|
| + input->required.To<std::map<caps::Name, caps::CapabilityRequest>>();
|
| + return spec;
|
| +}
|
| +
|
| +// static
|
| +shell::mojom::CapabilityRequestPtr
|
| +TypeConverter<shell::mojom::CapabilityRequestPtr,
|
| + caps::CapabilityRequest>::Convert(
|
| + const caps::CapabilityRequest& input) {
|
| + shell::mojom::CapabilityRequestPtr request(
|
| + shell::mojom::CapabilityRequest::New());
|
| + request->classes = mojo::Array<mojo::String>::From(input.classes);
|
| + request->interfaces = mojo::Array<mojo::String>::From(input.interfaces);
|
| + return request;
|
| +}
|
| +
|
| +// static
|
| +caps::CapabilityRequest
|
| +TypeConverter<caps::CapabilityRequest,
|
| + shell::mojom::CapabilityRequestPtr>::Convert(
|
| + const shell::mojom::CapabilityRequestPtr& input) {
|
| + caps::CapabilityRequest request;
|
| + request.classes = input->classes.To<std::set<std::string>>();
|
| + request.interfaces = input->interfaces.To<std::set<std::string>>();
|
| + return request;
|
| +}
|
| +
|
| +} // namespace mojo
|
|
|