This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhuyujia-webhopper/collector/adg-linux/gen/gpu/ipc/common/mailbox.mojom.h
little_stone bd2d50cf35 code update
2022-05-05 20:41:28 +08:00

200 lines
6.0 KiB
C++
Executable File

// 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 GPU_IPC_COMMON_MAILBOX_MOJOM_H_
#define GPU_IPC_COMMON_MAILBOX_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 "gpu/ipc/common/mailbox.mojom-shared.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"
#include "gpu/command_buffer/common/mailbox.h"
namespace gpu {
namespace mojom {
class Mailbox;
using MailboxPtr = mojo::StructPtr<Mailbox>;
class Mailbox {
public:
using DataView = MailboxDataView;
using Data_ = internal::Mailbox_Data;
template <typename... Args>
static MailboxPtr New(Args&&... args) {
return MailboxPtr(
base::in_place, std::forward<Args>(args)...);
}
template <typename U>
static MailboxPtr From(const U& u) {
return mojo::TypeConverter<MailboxPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, Mailbox>::Convert(*this);
}
Mailbox();
explicit Mailbox(
const std::vector<int8_t>& name);
~Mailbox();
// 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 = MailboxPtr>
MailboxPtr 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,
typename std::enable_if<std::is_same<
T, Mailbox>::value>::type* = nullptr>
bool Equals(const T& other) const;
template <typename UserType>
static std::vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
Mailbox::DataView, std::vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
Mailbox::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::Mailbox_UnserializedMessageContext<
UserType, Mailbox::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<Mailbox::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 Mailbox::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::Mailbox_UnserializedMessageContext<
UserType, Mailbox::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<Mailbox::DataView>(
input.payload(), input.payload_num_bytes(),
std::move(*input.mutable_handles()), output, Validate);
}
std::vector<int8_t> name;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
};
template <typename StructPtrType>
MailboxPtr Mailbox::Clone() const {
return New(
mojo::Clone(name)
);
}
template <typename T,
typename std::enable_if<std::is_same<
T, Mailbox>::value>::type*>
bool Mailbox::Equals(const T& other_struct) const {
if (!mojo::Equals(this->name, other_struct.name))
return false;
return true;
}
} // namespace mojom
} // namespace gpu
namespace mojo {
template <>
struct StructTraits<::gpu::mojom::Mailbox::DataView,
::gpu::mojom::MailboxPtr> {
static bool IsNull(const ::gpu::mojom::MailboxPtr& input) { return !input; }
static void SetToNull(::gpu::mojom::MailboxPtr* output) { output->reset(); }
static const decltype(::gpu::mojom::Mailbox::name)& name(
const ::gpu::mojom::MailboxPtr& input) {
return input->name;
}
static bool Read(::gpu::mojom::Mailbox::DataView input, ::gpu::mojom::MailboxPtr* output);
};
} // namespace mojo
#endif // GPU_IPC_COMMON_MAILBOX_MOJOM_H_