blob: 5eb7967fee424b6952f74c990cec2327b19906ec [file] [log] [blame]
// Copyright 2013 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.
#ifndef SERVICES_NETWORK_PUBLIC_MOJOM_IP_ENDPOINT_MOJOM_BLINK_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_IP_ENDPOINT_MOJOM_BLINK_H_
#include <stdint.h>
#include <limits>
#include <type_traits>
#include <utility>
#include "base/callback.h"
#include "base/macros.h"
#include "base/optional.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#if BUILDFLAG(MOJO_TRACE_ENABLED)
#include "base/trace_event/trace_event.h"
#endif
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "services/network/public/mojom/ip_endpoint.mojom-shared.h"
#include "services/network/public/mojom/ip_endpoint.mojom-blink-forward.h"
#include "services/network/public/mojom/ip_address.mojom-blink.h"
#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
#include "mojo/public/cpp/bindings/lib/native_enum_serialization.h"
#include "mojo/public/cpp/bindings/lib/native_struct_serialization.h"
#ifdef KYTHE_IS_RUNNING
#pragma kythe_inline_metadata "Metadata comment"
#endif
namespace network {
namespace mojom {
namespace blink {
// @generated_from: network.mojom.IPEndPoint
class IPEndPoint {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<IPEndPoint, T>::value>;
using DataView = IPEndPointDataView;
using Data_ = internal::IPEndPoint_Data;
template <typename... Args>
static IPEndPointPtr New(Args&&... args) {
return IPEndPointPtr(
base::in_place, std::forward<Args>(args)...);
}
template <typename U>
static IPEndPointPtr From(const U& u) {
return mojo::TypeConverter<IPEndPointPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, IPEndPoint>::Convert(*this);
}
IPEndPoint();
IPEndPoint(
::network::mojom::blink::IPAddressPtr address,
uint16_t port);
~IPEndPoint();
// Clone() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Clone() or copy
// constructor/assignment are available for members.
template <typename StructPtrType = IPEndPointPtr>
IPEndPointPtr Clone() const;
// Equals() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Equals() or == operator
// are available for members.
template <typename T, IPEndPoint::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename UserType>
static WTF::Vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
IPEndPoint::DataView, WTF::Vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
IPEndPoint::DataView>(input);
}
// The returned Message is serialized only if the message is moved
// cross-process or cross-language. Otherwise if the message is Deserialized
// as the same UserType |input| will just be moved to |output| in
// DeserializeFromMessage.
template <typename UserType>
static mojo::Message WrapAsMessage(UserType input) {
return mojo::Message(std::make_unique<
internal::IPEndPoint_UnserializedMessageContext<
UserType, IPEndPoint::DataView>>(0, 0, std::move(input)));
}
template <typename UserType>
static bool Deserialize(const void* data,
size_t data_num_bytes,
UserType* output) {
return mojo::internal::DeserializeImpl<IPEndPoint::DataView>(
data, data_num_bytes, std::vector<mojo::ScopedHandle>(), output, Validate);
}
template <typename UserType>
static bool Deserialize(const WTF::Vector<uint8_t>& input,
UserType* output) {
return IPEndPoint::Deserialize(
input.size() == 0 ? nullptr : &input.front(), input.size(), output);
}
template <typename UserType>
static bool DeserializeFromMessage(mojo::Message input,
UserType* output) {
auto context = input.TakeUnserializedContext<
internal::IPEndPoint_UnserializedMessageContext<
UserType, IPEndPoint::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<IPEndPoint::DataView>(
input.payload(), input.payload_num_bytes(),
std::move(*input.mutable_handles()), output, Validate);
}
// @generated_from: network.mojom.IPEndPoint.address
::network::mojom::blink::IPAddressPtr address;
// @generated_from: network.mojom.IPEndPoint.port
uint16_t port;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
DISALLOW_COPY_AND_ASSIGN(IPEndPoint);
};
// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, IPEndPoint::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, IPEndPoint::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, IPEndPoint::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, IPEndPoint::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
template <typename StructPtrType>
IPEndPointPtr IPEndPoint::Clone() const {
return New(
mojo::Clone(address),
mojo::Clone(port)
);
}
template <typename T, IPEndPoint::EnableIfSame<T>*>
bool IPEndPoint::Equals(const T& other_struct) const {
if (!mojo::Equals(this->address, other_struct.address))
return false;
if (!mojo::Equals(this->port, other_struct.port))
return false;
return true;
}
template <typename T, IPEndPoint::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.address < rhs.address)
return true;
if (rhs.address < lhs.address)
return false;
if (lhs.port < rhs.port)
return true;
if (rhs.port < lhs.port)
return false;
return false;
}
} // namespace blink
} // namespace mojom
} // namespace network
namespace mojo {
template <>
struct StructTraits<::network::mojom::blink::IPEndPoint::DataView,
::network::mojom::blink::IPEndPointPtr> {
static bool IsNull(const ::network::mojom::blink::IPEndPointPtr& input) { return !input; }
static void SetToNull(::network::mojom::blink::IPEndPointPtr* output) { output->reset(); }
static const decltype(::network::mojom::blink::IPEndPoint::address)& address(
const ::network::mojom::blink::IPEndPointPtr& input) {
return input->address;
}
static decltype(::network::mojom::blink::IPEndPoint::port) port(
const ::network::mojom::blink::IPEndPointPtr& input) {
return input->port;
}
static bool Read(::network::mojom::blink::IPEndPoint::DataView input, ::network::mojom::blink::IPEndPointPtr* output);
};
} // namespace mojo
#endif // SERVICES_NETWORK_PUBLIC_MOJOM_IP_ENDPOINT_MOJOM_BLINK_H_
/* Metadata comment
eyJtZXRhIjogW3siZW5kIjogMjIyMiwgImJlZ2luIjogMjIxMiwgImVkZ2UiOiAiJS9reXRoZS9l
ZGdlL2dlbmVyYXRlcyIsICJ0eXBlIjogImFuY2hvcl9kZWZpbmVzIiwgInZuYW1lIjogeyJjb3Jw
dXMiOiAiY2hyb21pdW0uZ29vZ2xlc291cmNlLmNvbS9jaHJvbWl1bS9zcmMiLCAibGFuZ3VhZ2Ui
OiAibW9qb20iLCAic2lnbmF0dXJlIjogIm5ldHdvcmsubW9qb20uSVBFbmRQb2ludCJ9fSwgeyJl
bmQiOiA1NzE0LCAiYmVnaW4iOiA1NzA3LCAiZWRnZSI6ICIlL2t5dGhlL2VkZ2UvZ2VuZXJhdGVz
IiwgInR5cGUiOiAiYW5jaG9yX2RlZmluZXMiLCAidm5hbWUiOiB7ImNvcnB1cyI6ICJjaHJvbWl1
bS5nb29nbGVzb3VyY2UuY29tL2Nocm9taXVtL3NyYyIsICJsYW5ndWFnZSI6ICJtb2pvbSIsICJz
aWduYXR1cmUiOiAibmV0d29yay5tb2pvbS5JUEVuZFBvaW50LmFkZHJlc3MifX0sIHsiZW5kIjog
NTc4NCwgImJlZ2luIjogNTc4MCwgImVkZ2UiOiAiJS9reXRoZS9lZGdlL2dlbmVyYXRlcyIsICJ0
eXBlIjogImFuY2hvcl9kZWZpbmVzIiwgInZuYW1lIjogeyJjb3JwdXMiOiAiY2hyb21pdW0uZ29v
Z2xlc291cmNlLmNvbS9jaHJvbWl1bS9zcmMiLCAibGFuZ3VhZ2UiOiAibW9qb20iLCAic2lnbmF0
dXJlIjogIm5ldHdvcmsubW9qb20uSVBFbmRQb2ludC5wb3J0In19XSwgInR5cGUiOiAia3l0aGUw
In0=
*/