blob: 2443338a8fb0caffd114545aa7c9cbf1fe418488 [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 COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_STREAM_MOJOM_BLINK_H_
#define COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_STREAM_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 "components/download/public/common/download_stream.mojom-shared.h"
#include "components/download/public/common/download_stream.mojom-blink-forward.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 WTF {
struct download_mojom_internal_NetworkRequestStatus_DataHashFn {
static unsigned GetHash(const ::download::mojom::NetworkRequestStatus& value) {
using utype = std::underlying_type<::download::mojom::NetworkRequestStatus>::type;
return DefaultHash<utype>::Hash().GetHash(static_cast<utype>(value));
}
static bool Equal(const ::download::mojom::NetworkRequestStatus& left, const ::download::mojom::NetworkRequestStatus& right) {
return left == right;
}
static const bool safe_to_compare_to_empty_or_deleted = true;
};
template <>
struct HashTraits<::download::mojom::NetworkRequestStatus>
: public GenericHashTraits<::download::mojom::NetworkRequestStatus> {
static_assert(true,
"-1000000 is a reserved enum value");
static_assert(true,
"-1000001 is a reserved enum value");
static const bool hasIsEmptyValueFunction = true;
static bool IsEmptyValue(const ::download::mojom::NetworkRequestStatus& value) {
return value == static_cast<::download::mojom::NetworkRequestStatus>(-1000000);
}
static void ConstructDeletedValue(::download::mojom::NetworkRequestStatus& slot, bool) {
slot = static_cast<::download::mojom::NetworkRequestStatus>(-1000001);
}
static bool IsDeletedValue(const ::download::mojom::NetworkRequestStatus& value) {
return value == static_cast<::download::mojom::NetworkRequestStatus>(-1000001);
}
};
} // namespace WTF
namespace download {
namespace mojom {
namespace blink {
class DownloadStreamClientProxy;
template <typename ImplRefTraits>
class DownloadStreamClientStub;
class DownloadStreamClientRequestValidator;
// @generated_from: download.mojom.DownloadStreamClient
class DownloadStreamClient
: public DownloadStreamClientInterfaceBase {
public:
static const char Name_[];
static constexpr uint32_t Version_ = 0;
static constexpr bool PassesAssociatedKinds_ = false;
static constexpr bool HasSyncMethods_ = false;
using Base_ = DownloadStreamClientInterfaceBase;
using Proxy_ = DownloadStreamClientProxy;
template <typename ImplRefTraits>
using Stub_ = DownloadStreamClientStub<ImplRefTraits>;
using RequestValidator_ = DownloadStreamClientRequestValidator;
using ResponseValidator_ = mojo::PassThroughFilter;
enum MethodMinVersions : uint32_t {
kOnStreamCompletedMinVersion = 0,
};
virtual ~DownloadStreamClient() {}
// @generated_from: download.mojom.DownloadStreamClient.OnStreamCompleted
virtual void OnStreamCompleted(NetworkRequestStatus status) = 0;
};
class DownloadStreamClientProxy
: public DownloadStreamClient {
public:
using InterfaceType = DownloadStreamClient;
explicit DownloadStreamClientProxy(mojo::MessageReceiverWithResponder* receiver);
void OnStreamCompleted(NetworkRequestStatus status) final;
private:
mojo::MessageReceiverWithResponder* receiver_;
};
class DownloadStreamClientStubDispatch {
public:
static bool Accept(DownloadStreamClient* impl, mojo::Message* message);
static bool AcceptWithResponder(
DownloadStreamClient* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};
template <typename ImplRefTraits =
mojo::RawPtrImplRefTraits<DownloadStreamClient>>
class DownloadStreamClientStub
: public mojo::MessageReceiverWithResponderStatus {
public:
using ImplPointerType = typename ImplRefTraits::PointerType;
DownloadStreamClientStub() {}
~DownloadStreamClientStub() 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 DownloadStreamClientStubDispatch::Accept(
ImplRefTraits::GetRawPointer(&sink_), message);
}
bool AcceptWithResponder(
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return DownloadStreamClientStubDispatch::AcceptWithResponder(
ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
}
private:
ImplPointerType sink_;
};
class DownloadStreamClientRequestValidator : public mojo::MessageReceiver {
public:
bool Accept(mojo::Message* message) override;
};
// @generated_from: download.mojom.DownloadStreamHandle
class DownloadStreamHandle {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<DownloadStreamHandle, T>::value>;
using DataView = DownloadStreamHandleDataView;
using Data_ = internal::DownloadStreamHandle_Data;
template <typename... Args>
static DownloadStreamHandlePtr New(Args&&... args) {
return DownloadStreamHandlePtr(
base::in_place, std::forward<Args>(args)...);
}
template <typename U>
static DownloadStreamHandlePtr From(const U& u) {
return mojo::TypeConverter<DownloadStreamHandlePtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, DownloadStreamHandle>::Convert(*this);
}
DownloadStreamHandle();
DownloadStreamHandle(
mojo::ScopedDataPipeConsumerHandle stream,
DownloadStreamClientRequest client_request);
~DownloadStreamHandle();
// 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 = DownloadStreamHandlePtr>
DownloadStreamHandlePtr 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, DownloadStreamHandle::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename UserType>
static WTF::Vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
DownloadStreamHandle::DataView, WTF::Vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
DownloadStreamHandle::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::DownloadStreamHandle_UnserializedMessageContext<
UserType, DownloadStreamHandle::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<DownloadStreamHandle::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 DownloadStreamHandle::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::DownloadStreamHandle_UnserializedMessageContext<
UserType, DownloadStreamHandle::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<DownloadStreamHandle::DataView>(
input.payload(), input.payload_num_bytes(),
std::move(*input.mutable_handles()), output, Validate);
}
// @generated_from: download.mojom.DownloadStreamHandle.stream
mojo::ScopedDataPipeConsumerHandle stream;
// @generated_from: download.mojom.DownloadStreamHandle.client_request
DownloadStreamClientRequest client_request;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
DISALLOW_COPY_AND_ASSIGN(DownloadStreamHandle);
};
// 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, DownloadStreamHandle::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, DownloadStreamHandle::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, DownloadStreamHandle::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, DownloadStreamHandle::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
template <typename StructPtrType>
DownloadStreamHandlePtr DownloadStreamHandle::Clone() const {
return New(
mojo::Clone(stream),
mojo::Clone(client_request)
);
}
template <typename T, DownloadStreamHandle::EnableIfSame<T>*>
bool DownloadStreamHandle::Equals(const T& other_struct) const {
if (!mojo::Equals(this->stream, other_struct.stream))
return false;
if (!mojo::Equals(this->client_request, other_struct.client_request))
return false;
return true;
}
template <typename T, DownloadStreamHandle::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.stream < rhs.stream)
return true;
if (rhs.stream < lhs.stream)
return false;
if (lhs.client_request < rhs.client_request)
return true;
if (rhs.client_request < lhs.client_request)
return false;
return false;
}
} // namespace blink
} // namespace mojom
} // namespace download
namespace mojo {
template <>
struct StructTraits<::download::mojom::blink::DownloadStreamHandle::DataView,
::download::mojom::blink::DownloadStreamHandlePtr> {
static bool IsNull(const ::download::mojom::blink::DownloadStreamHandlePtr& input) { return !input; }
static void SetToNull(::download::mojom::blink::DownloadStreamHandlePtr* output) { output->reset(); }
static decltype(::download::mojom::blink::DownloadStreamHandle::stream)& stream(
::download::mojom::blink::DownloadStreamHandlePtr& input) {
return input->stream;
}
static decltype(::download::mojom::blink::DownloadStreamHandle::client_request)& client_request(
::download::mojom::blink::DownloadStreamHandlePtr& input) {
return input->client_request;
}
static bool Read(::download::mojom::blink::DownloadStreamHandle::DataView input, ::download::mojom::blink::DownloadStreamHandlePtr* output);
};
} // namespace mojo
#endif // COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_STREAM_MOJOM_BLINK_H_
/* Metadata comment
eyJtZXRhIjogW3siZW5kIjogMzc5MywgImJlZ2luIjogMzc3MywgImVkZ2UiOiAiJS9reXRoZS9l
ZGdlL2dlbmVyYXRlcyIsICJ0eXBlIjogImFuY2hvcl9kZWZpbmVzIiwgInZuYW1lIjogeyJjb3Jw
dXMiOiAiY2hyb21pdW0uZ29vZ2xlc291cmNlLmNvbS9jaHJvbWl1bS9zcmMiLCAibGFuZ3VhZ2Ui
OiAibW9qb20iLCAic2lnbmF0dXJlIjogImRvd25sb2FkLm1vam9tLkRvd25sb2FkU3RyZWFtQ2xp
ZW50In19LCB7ImVuZCI6IDQ1NjcsICJiZWdpbiI6IDQ1NTAsICJlZGdlIjogIiUva3l0aGUvZWRn
ZS9nZW5lcmF0ZXMiLCAidHlwZSI6ICJhbmNob3JfZGVmaW5lcyIsICJ2bmFtZSI6IHsiY29ycHVz
IjogImNocm9taXVtLmdvb2dsZXNvdXJjZS5jb20vY2hyb21pdW0vc3JjIiwgImxhbmd1YWdlIjog
Im1vam9tIiwgInNpZ25hdHVyZSI6ICJkb3dubG9hZC5tb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