blob: 635bd203cc2155b4b8109a17e6e38e1342fc2ed7 [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_TLS_SOCKET_MOJOM_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_TLS_SOCKET_MOJOM_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/tls_socket.mojom-shared.h"
#include "services/network/public/mojom/tls_socket.mojom-forward.h"
#include "services/network/public/mojom/ip_endpoint.mojom-forward.h"
#include "services/network/public/mojom/ssl_config.mojom-forward.h"
#include <string>
#include <vector>
#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 {
class TLSClientSocketProxy;
template <typename ImplRefTraits>
class TLSClientSocketStub;
class TLSClientSocketRequestValidator;
// @generated_from: network.mojom.TLSClientSocket
class TLSClientSocket
: public TLSClientSocketInterfaceBase {
public:
static const char Name_[];
static constexpr uint32_t Version_ = 0;
static constexpr bool PassesAssociatedKinds_ = false;
static constexpr bool HasSyncMethods_ = false;
using Base_ = TLSClientSocketInterfaceBase;
using Proxy_ = TLSClientSocketProxy;
template <typename ImplRefTraits>
using Stub_ = TLSClientSocketStub<ImplRefTraits>;
using RequestValidator_ = TLSClientSocketRequestValidator;
using ResponseValidator_ = mojo::PassThroughFilter;
enum MethodMinVersions : uint32_t {
};
virtual ~TLSClientSocket() {}
};
class TLSClientSocketProxy
: public TLSClientSocket {
public:
using InterfaceType = TLSClientSocket;
explicit TLSClientSocketProxy(mojo::MessageReceiverWithResponder* receiver);
private:
mojo::MessageReceiverWithResponder* receiver_;
};
class TLSClientSocketStubDispatch {
public:
static bool Accept(TLSClientSocket* impl, mojo::Message* message);
static bool AcceptWithResponder(
TLSClientSocket* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};
template <typename ImplRefTraits =
mojo::RawPtrImplRefTraits<TLSClientSocket>>
class TLSClientSocketStub
: public mojo::MessageReceiverWithResponderStatus {
public:
using ImplPointerType = typename ImplRefTraits::PointerType;
TLSClientSocketStub() {}
~TLSClientSocketStub() override {}
void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
ImplPointerType& sink() { return sink_; }
bool Accept(mojo::Message* message) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return TLSClientSocketStubDispatch::Accept(
ImplRefTraits::GetRawPointer(&sink_), message);
}
bool AcceptWithResponder(
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return TLSClientSocketStubDispatch::AcceptWithResponder(
ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
}
private:
ImplPointerType sink_;
};
class TLSClientSocketRequestValidator : public mojo::MessageReceiver {
public:
bool Accept(mojo::Message* message) override;
};
// @generated_from: network.mojom.TLSClientSocketOptions
class TLSClientSocketOptions {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<TLSClientSocketOptions, T>::value>;
using DataView = TLSClientSocketOptionsDataView;
using Data_ = internal::TLSClientSocketOptions_Data;
template <typename... Args>
static TLSClientSocketOptionsPtr New(Args&&... args) {
return TLSClientSocketOptionsPtr(
base::in_place, std::forward<Args>(args)...);
}
template <typename U>
static TLSClientSocketOptionsPtr From(const U& u) {
return mojo::TypeConverter<TLSClientSocketOptionsPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, TLSClientSocketOptions>::Convert(*this);
}
TLSClientSocketOptions();
TLSClientSocketOptions(
::network::mojom::SSLVersion version_min,
::network::mojom::SSLVersion version_max,
bool send_ssl_info,
bool unsafely_skip_cert_verification);
~TLSClientSocketOptions();
// 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 = TLSClientSocketOptionsPtr>
TLSClientSocketOptionsPtr 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, TLSClientSocketOptions::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
size_t Hash(size_t seed) const;
template <typename UserType>
static std::vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
TLSClientSocketOptions::DataView, std::vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
TLSClientSocketOptions::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::TLSClientSocketOptions_UnserializedMessageContext<
UserType, TLSClientSocketOptions::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<TLSClientSocketOptions::DataView>(
data, data_num_bytes, std::vector<mojo::ScopedHandle>(), output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return TLSClientSocketOptions::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::TLSClientSocketOptions_UnserializedMessageContext<
UserType, TLSClientSocketOptions::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<TLSClientSocketOptions::DataView>(
input.payload(), input.payload_num_bytes(),
std::move(*input.mutable_handles()), output, Validate);
}
// @generated_from: network.mojom.TLSClientSocketOptions.version_min
::network::mojom::SSLVersion version_min;
// @generated_from: network.mojom.TLSClientSocketOptions.version_max
::network::mojom::SSLVersion version_max;
// @generated_from: network.mojom.TLSClientSocketOptions.send_ssl_info
bool send_ssl_info;
// @generated_from: network.mojom.TLSClientSocketOptions.unsafely_skip_cert_verification
bool unsafely_skip_cert_verification;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
};
// 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, TLSClientSocketOptions::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, TLSClientSocketOptions::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, TLSClientSocketOptions::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, TLSClientSocketOptions::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
template <typename StructPtrType>
TLSClientSocketOptionsPtr TLSClientSocketOptions::Clone() const {
return New(
mojo::Clone(version_min),
mojo::Clone(version_max),
mojo::Clone(send_ssl_info),
mojo::Clone(unsafely_skip_cert_verification)
);
}
template <typename T, TLSClientSocketOptions::EnableIfSame<T>*>
bool TLSClientSocketOptions::Equals(const T& other_struct) const {
if (!mojo::Equals(this->version_min, other_struct.version_min))
return false;
if (!mojo::Equals(this->version_max, other_struct.version_max))
return false;
if (!mojo::Equals(this->send_ssl_info, other_struct.send_ssl_info))
return false;
if (!mojo::Equals(this->unsafely_skip_cert_verification, other_struct.unsafely_skip_cert_verification))
return false;
return true;
}
template <typename T, TLSClientSocketOptions::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.version_min < rhs.version_min)
return true;
if (rhs.version_min < lhs.version_min)
return false;
if (lhs.version_max < rhs.version_max)
return true;
if (rhs.version_max < lhs.version_max)
return false;
if (lhs.send_ssl_info < rhs.send_ssl_info)
return true;
if (rhs.send_ssl_info < lhs.send_ssl_info)
return false;
if (lhs.unsafely_skip_cert_verification < rhs.unsafely_skip_cert_verification)
return true;
if (rhs.unsafely_skip_cert_verification < lhs.unsafely_skip_cert_verification)
return false;
return false;
}
} // namespace mojom
} // namespace network
namespace mojo {
template <>
struct StructTraits<::network::mojom::TLSClientSocketOptions::DataView,
::network::mojom::TLSClientSocketOptionsPtr> {
static bool IsNull(const ::network::mojom::TLSClientSocketOptionsPtr& input) { return !input; }
static void SetToNull(::network::mojom::TLSClientSocketOptionsPtr* output) { output->reset(); }
static decltype(::network::mojom::TLSClientSocketOptions::version_min) version_min(
const ::network::mojom::TLSClientSocketOptionsPtr& input) {
return input->version_min;
}
static decltype(::network::mojom::TLSClientSocketOptions::version_max) version_max(
const ::network::mojom::TLSClientSocketOptionsPtr& input) {
return input->version_max;
}
static decltype(::network::mojom::TLSClientSocketOptions::send_ssl_info) send_ssl_info(
const ::network::mojom::TLSClientSocketOptionsPtr& input) {
return input->send_ssl_info;
}
static decltype(::network::mojom::TLSClientSocketOptions::unsafely_skip_cert_verification) unsafely_skip_cert_verification(
const ::network::mojom::TLSClientSocketOptionsPtr& input) {
return input->unsafely_skip_cert_verification;
}
static bool Read(::network::mojom::TLSClientSocketOptions::DataView input, ::network::mojom::TLSClientSocketOptionsPtr* output);
};
} // namespace mojo
#endif // SERVICES_NETWORK_PUBLIC_MOJOM_TLS_SOCKET_MOJOM_H_
/* Metadata comment
eyJtZXRhIjogW3siZW5kIjogMjE2NiwgImJlZ2luIjogMjE1MSwgImVkZ2UiOiAiJS9reXRoZS9l
ZGdlL2dlbmVyYXRlcyIsICJ0eXBlIjogImFuY2hvcl9kZWZpbmVzIiwgInZuYW1lIjogeyJjb3Jw
dXMiOiAiY2hyb21pdW0uZ29vZ2xlc291cmNlLmNvbS9jaHJvbWl1bS9zcmMiLCAibGFuZ3VhZ2Ui
OiAibW9qb20iLCAic2lnbmF0dXJlIjogIm5ldHdvcmsubW9qb20uVExTQ2xpZW50U29ja2V0In19
LCB7ImVuZCI6IDQ1MzcsICJiZWdpbiI6IDQ1MTUsICJlZGdlIjogIiUva3l0aGUvZWRnZS9nZW5l
cmF0ZXMiLCAidHlwZSI6ICJhbmNob3JfZGVmaW5lcyIsICJ2bmFtZSI6IHsiY29ycHVzIjogImNo
cm9taXVtLmdvb2dsZXNvdXJjZS5jb20vY2hyb21pdW0vc3JjIiwgImxhbmd1YWdlIjogIm1vam9t
IiwgInNpZ25hdHVyZSI6ICJuZXR3b3JrLm1vam9tLlRMU0NsaWVudFNvY2tldE9wdGlvbnMifX0s
IHsiZW5kIjogODQ0MiwgImJlZ2luIjogODQzMSwgImVkZ2UiOiAiJS9reXRoZS9lZGdlL2dlbmVy
YXRlcyIsICJ0eXBlIjogImFuY2hvcl9kZWZpbmVzIiwgInZuYW1lIjogeyJjb3JwdXMiOiAiY2hy
b21pdW0uZ29vZ2xlc291cmNlLmNvbS9jaHJvbWl1bS9zcmMiLCAibGFuZ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