blob: 8c8e9c6165ae572553be67cadba347c4f3942bfe [file] [log] [blame]
// camera/mojo/algorithm/camera_algorithm.mojom.cc is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif
#include "camera/mojo/algorithm/camera_algorithm.mojom.h"
#include <math.h>
#include <stdint.h>
#include <utility>
#include "base/debug/alias.h"
#include "base/hash/md5_constexpr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "mojo/public/cpp/bindings/features.h"
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/proxy_to_responder.h"
#include "mojo/public/cpp/bindings/lib/send_message_helper.h"
#include "mojo/public/cpp/bindings/lib/serialization_util.h"
#include "mojo/public/cpp/bindings/lib/unserialized_message_context.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "mojo/public/cpp/bindings/urgent_message_scope.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
#include "camera/mojo/algorithm/camera_algorithm.mojom-params-data.h"
#include "camera/mojo/algorithm/camera_algorithm.mojom-shared-message-ids.h"
#include "camera/mojo/algorithm/camera_algorithm.mojom-import-headers.h"
#include "camera/mojo/algorithm/camera_algorithm.mojom-test-utils.h"
namespace cros::mojom {
const char CameraAlgorithmOps::Name_[] = "cros.mojom.CameraAlgorithmOps";
CameraAlgorithmOps::IPCStableHashFunction CameraAlgorithmOps::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
switch (static_cast<messages::CameraAlgorithmOps>(message.name())) {
case messages::CameraAlgorithmOps::kInitialize: {
return &CameraAlgorithmOps::Initialize_Sym::IPCStableHash;
}
case messages::CameraAlgorithmOps::kRegisterBuffer: {
return &CameraAlgorithmOps::RegisterBuffer_Sym::IPCStableHash;
}
case messages::CameraAlgorithmOps::kRequest: {
return &CameraAlgorithmOps::Request_Sym::IPCStableHash;
}
case messages::CameraAlgorithmOps::kDeregisterBuffers: {
return &CameraAlgorithmOps::DeregisterBuffers_Sym::IPCStableHash;
}
case messages::CameraAlgorithmOps::kUpdateReturn: {
return &CameraAlgorithmOps::UpdateReturn_Sym::IPCStableHash;
}
case messages::CameraAlgorithmOps::kDeinitialize: {
return &CameraAlgorithmOps::Deinitialize_Sym::IPCStableHash;
}
}
#endif // !BUILDFLAG(IS_FUCHSIA)
return nullptr;
}
const char* CameraAlgorithmOps::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (!is_response) {
switch (static_cast<messages::CameraAlgorithmOps>(message.name())) {
case messages::CameraAlgorithmOps::kInitialize:
return "Receive cros::mojom::CameraAlgorithmOps::Initialize";
case messages::CameraAlgorithmOps::kRegisterBuffer:
return "Receive cros::mojom::CameraAlgorithmOps::RegisterBuffer";
case messages::CameraAlgorithmOps::kRequest:
return "Receive cros::mojom::CameraAlgorithmOps::Request";
case messages::CameraAlgorithmOps::kDeregisterBuffers:
return "Receive cros::mojom::CameraAlgorithmOps::DeregisterBuffers";
case messages::CameraAlgorithmOps::kUpdateReturn:
return "Receive cros::mojom::CameraAlgorithmOps::UpdateReturn";
case messages::CameraAlgorithmOps::kDeinitialize:
return "Receive cros::mojom::CameraAlgorithmOps::Deinitialize";
}
} else {
switch (static_cast<messages::CameraAlgorithmOps>(message.name())) {
case messages::CameraAlgorithmOps::kInitialize:
return "Receive reply cros::mojom::CameraAlgorithmOps::Initialize";
case messages::CameraAlgorithmOps::kRegisterBuffer:
return "Receive reply cros::mojom::CameraAlgorithmOps::RegisterBuffer";
case messages::CameraAlgorithmOps::kRequest:
return "Receive reply cros::mojom::CameraAlgorithmOps::Request";
case messages::CameraAlgorithmOps::kDeregisterBuffers:
return "Receive reply cros::mojom::CameraAlgorithmOps::DeregisterBuffers";
case messages::CameraAlgorithmOps::kUpdateReturn:
return "Receive reply cros::mojom::CameraAlgorithmOps::UpdateReturn";
case messages::CameraAlgorithmOps::kDeinitialize:
return "Receive reply cros::mojom::CameraAlgorithmOps::Deinitialize";
}
}
return "Receive unknown mojo message";
#else
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (is_response) {
return "Receive mojo reply";
} else {
return "Receive mojo message";
}
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}
#if !BUILDFLAG(IS_FUCHSIA)
uint32_t CameraAlgorithmOps::Initialize_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmOps::Initialize");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t CameraAlgorithmOps::RegisterBuffer_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmOps::RegisterBuffer");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t CameraAlgorithmOps::Request_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmOps::Request");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t CameraAlgorithmOps::DeregisterBuffers_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmOps::DeregisterBuffers");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t CameraAlgorithmOps::UpdateReturn_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmOps::UpdateReturn");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t CameraAlgorithmOps::Deinitialize_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmOps::Deinitialize");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
class CameraAlgorithmOps_Initialize_ForwardToCallback
: public mojo::MessageReceiver {
public:
CameraAlgorithmOps_Initialize_ForwardToCallback(
CameraAlgorithmOps::InitializeCallback callback
) : callback_(std::move(callback)) {
}
CameraAlgorithmOps_Initialize_ForwardToCallback(const CameraAlgorithmOps_Initialize_ForwardToCallback&) = delete;
CameraAlgorithmOps_Initialize_ForwardToCallback& operator=(const CameraAlgorithmOps_Initialize_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
CameraAlgorithmOps::InitializeCallback callback_;
};
class CameraAlgorithmOps_RegisterBuffer_ForwardToCallback
: public mojo::MessageReceiver {
public:
CameraAlgorithmOps_RegisterBuffer_ForwardToCallback(
CameraAlgorithmOps::RegisterBufferCallback callback
) : callback_(std::move(callback)) {
}
CameraAlgorithmOps_RegisterBuffer_ForwardToCallback(const CameraAlgorithmOps_RegisterBuffer_ForwardToCallback&) = delete;
CameraAlgorithmOps_RegisterBuffer_ForwardToCallback& operator=(const CameraAlgorithmOps_RegisterBuffer_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
CameraAlgorithmOps::RegisterBufferCallback callback_;
};
CameraAlgorithmOpsProxy::CameraAlgorithmOpsProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void CameraAlgorithmOpsProxy::Initialize(
::mojo::PendingRemote<CameraAlgorithmCallbackOps> in_callbacks, InitializeCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::CameraAlgorithmOps::Initialize", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("callbacks"), in_callbacks,
"<value of type ::mojo::PendingRemote<CameraAlgorithmCallbackOps>>");
});
#endif
const bool kExpectsResponse = true;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kInitialize), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_Initialize_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<mojo::InterfacePtrDataView<::cros::mojom::CameraAlgorithmCallbackOpsInterfaceBase>>(
in_callbacks, &params->callbacks, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->callbacks),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid callbacks in CameraAlgorithmOps.Initialize request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("Initialize");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new CameraAlgorithmOps_Initialize_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void CameraAlgorithmOpsProxy::RegisterBuffer(
::mojo::ScopedHandle in_buffer_fd, RegisterBufferCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::CameraAlgorithmOps::RegisterBuffer", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("buffer_fd"), in_buffer_fd,
"<value of type ::mojo::ScopedHandle>");
});
#endif
const bool kExpectsResponse = true;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kRegisterBuffer), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_RegisterBuffer_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<mojo::ScopedHandle>(
in_buffer_fd, &params->buffer_fd, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->buffer_fd),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid buffer_fd in CameraAlgorithmOps.RegisterBuffer request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("RegisterBuffer");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new CameraAlgorithmOps_RegisterBuffer_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void CameraAlgorithmOpsProxy::Request(
uint32_t in_req_id, const std::vector<uint8_t>& in_req_header, int32_t in_buffer_handle) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::CameraAlgorithmOps::Request", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("req_id"), in_req_id,
"<value of type uint32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("req_header"), in_req_header,
"<value of type const std::vector<uint8_t>&>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("buffer_handle"), in_buffer_handle,
"<value of type int32_t>");
});
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kRequest), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_Request_Params_Data> params(
message);
params.Allocate();
params->req_id = in_req_id;
mojo::internal::MessageFragment<
typename decltype(params->req_header)::BaseType>
req_header_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& req_header_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<uint8_t>>(
in_req_header, req_header_fragment, &req_header_validate_params);
params->req_header.Set(
req_header_fragment.is_null() ? nullptr : req_header_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->req_header.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null req_header in CameraAlgorithmOps.Request request");
params->buffer_handle = in_buffer_handle;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("Request");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMojoMessage(*receiver_, message);
}
void CameraAlgorithmOpsProxy::DeregisterBuffers(
const std::vector<int32_t>& in_buffer_handles) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::CameraAlgorithmOps::DeregisterBuffers", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("buffer_handles"), in_buffer_handles,
"<value of type const std::vector<int32_t>&>");
});
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kDeregisterBuffers), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_DeregisterBuffers_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->buffer_handles)::BaseType>
buffer_handles_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& buffer_handles_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_buffer_handles, buffer_handles_fragment, &buffer_handles_validate_params);
params->buffer_handles.Set(
buffer_handles_fragment.is_null() ? nullptr : buffer_handles_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->buffer_handles.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null buffer_handles in CameraAlgorithmOps.DeregisterBuffers request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("DeregisterBuffers");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMojoMessage(*receiver_, message);
}
void CameraAlgorithmOpsProxy::UpdateReturn(
uint32_t in_upd_id, uint32_t in_status, ::mojo::ScopedHandle in_buffer_fd) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::CameraAlgorithmOps::UpdateReturn", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("upd_id"), in_upd_id,
"<value of type uint32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("status"), in_status,
"<value of type uint32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("buffer_fd"), in_buffer_fd,
"<value of type ::mojo::ScopedHandle>");
});
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kUpdateReturn), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_UpdateReturn_Params_Data> params(
message);
params.Allocate();
params->upd_id = in_upd_id;
params->status = in_status;
mojo::internal::Serialize<mojo::ScopedHandle>(
in_buffer_fd, &params->buffer_fd, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->buffer_fd),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid buffer_fd in CameraAlgorithmOps.UpdateReturn request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("UpdateReturn");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMojoMessage(*receiver_, message);
}
void CameraAlgorithmOpsProxy::Deinitialize(
) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT0("mojom", "Send cros::mojom::CameraAlgorithmOps::Deinitialize");
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kDeinitialize), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_Deinitialize_Params_Data> params(
message);
params.Allocate();
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("Deinitialize");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMojoMessage(*receiver_, message);
}
class CameraAlgorithmOps_Initialize_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static CameraAlgorithmOps::InitializeCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<CameraAlgorithmOps_Initialize_ProxyToResponder> proxy(
new CameraAlgorithmOps_Initialize_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&CameraAlgorithmOps_Initialize_ProxyToResponder::Run,
std::move(proxy));
}
~CameraAlgorithmOps_Initialize_ProxyToResponder() {
#if DCHECK_IS_ON()
if (responder_) {
// If we're being destroyed without being run, we want to ensure the
// binding endpoint has been closed. This checks for that asynchronously.
// We pass a bound generated callback to handle the response so that any
// resulting DCHECK stack will have useful interface type information.
// Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to
// fizzle if this happens after shutdown and the endpoint is bound to a
// BLOCK_SHUTDOWN sequence.
base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler;
responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete));
}
#endif
}
private:
CameraAlgorithmOps_Initialize_ProxyToResponder(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder)
: ::mojo::internal::ProxyToResponder(message, std::move(responder)) {
}
#if DCHECK_IS_ON()
static void OnIsConnectedComplete(bool connected) {
DCHECK(!connected)
<< "CameraAlgorithmOps::InitializeCallback was destroyed without "
<< "first either being run or its corresponding binding being closed. "
<< "It is an error to drop response callbacks which still correspond "
<< "to an open interface pipe.";
}
#endif
void Run(
int32_t in_result);
};
bool CameraAlgorithmOps_Initialize_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::CameraAlgorithmOps_Initialize_ResponseParams_Data* params =
reinterpret_cast<
internal::CameraAlgorithmOps_Initialize_ResponseParams_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.0
bool success = true;
int32_t p_result{};
CameraAlgorithmOps_Initialize_ResponseParamsDataView input_data_view(params, message);
if (success)
p_result = input_data_view.result();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 0, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_result));
return true;
}
void CameraAlgorithmOps_Initialize_ProxyToResponder::Run(
int32_t in_result) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::CameraAlgorithmOps::Initialize", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("result"), in_result,
"<value of type int32_t>");
});
#endif
const uint32_t kFlags = mojo::Message::kFlagIsResponse |
((is_sync_) ? mojo::Message::kFlagIsSync : 0) |
((true) ? 0 : mojo::Message::kFlagNoInterrupt) |
((false) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kInitialize), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_Initialize_ResponseParams_Data> params(
message);
params.Allocate();
params->result = in_result;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("Initialize");
#endif
message.set_request_id(request_id_);
message.set_trace_nonce(trace_nonce_);
::mojo::internal::SendMojoMessage(*responder_, message);
// SendMojoMessage() fails silently if the responder connection is closed,
// or if the message is malformed.
//
// TODO(darin): If Accept() returns false due to a malformed message, that
// may be good reason to close the connection. However, we don't have a
// way to do that from here. We should add a way.
responder_ = nullptr;
}
class CameraAlgorithmOps_RegisterBuffer_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static CameraAlgorithmOps::RegisterBufferCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<CameraAlgorithmOps_RegisterBuffer_ProxyToResponder> proxy(
new CameraAlgorithmOps_RegisterBuffer_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&CameraAlgorithmOps_RegisterBuffer_ProxyToResponder::Run,
std::move(proxy));
}
~CameraAlgorithmOps_RegisterBuffer_ProxyToResponder() {
#if DCHECK_IS_ON()
if (responder_) {
// If we're being destroyed without being run, we want to ensure the
// binding endpoint has been closed. This checks for that asynchronously.
// We pass a bound generated callback to handle the response so that any
// resulting DCHECK stack will have useful interface type information.
// Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to
// fizzle if this happens after shutdown and the endpoint is bound to a
// BLOCK_SHUTDOWN sequence.
base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler;
responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete));
}
#endif
}
private:
CameraAlgorithmOps_RegisterBuffer_ProxyToResponder(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder)
: ::mojo::internal::ProxyToResponder(message, std::move(responder)) {
}
#if DCHECK_IS_ON()
static void OnIsConnectedComplete(bool connected) {
DCHECK(!connected)
<< "CameraAlgorithmOps::RegisterBufferCallback was destroyed without "
<< "first either being run or its corresponding binding being closed. "
<< "It is an error to drop response callbacks which still correspond "
<< "to an open interface pipe.";
}
#endif
void Run(
int32_t in_result);
};
bool CameraAlgorithmOps_RegisterBuffer_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::CameraAlgorithmOps_RegisterBuffer_ResponseParams_Data* params =
reinterpret_cast<
internal::CameraAlgorithmOps_RegisterBuffer_ResponseParams_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.1
bool success = true;
int32_t p_result{};
CameraAlgorithmOps_RegisterBuffer_ResponseParamsDataView input_data_view(params, message);
if (success)
p_result = input_data_view.result();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 1, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_result));
return true;
}
void CameraAlgorithmOps_RegisterBuffer_ProxyToResponder::Run(
int32_t in_result) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::CameraAlgorithmOps::RegisterBuffer", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("result"), in_result,
"<value of type int32_t>");
});
#endif
const uint32_t kFlags = mojo::Message::kFlagIsResponse |
((is_sync_) ? mojo::Message::kFlagIsSync : 0) |
((true) ? 0 : mojo::Message::kFlagNoInterrupt) |
((false) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmOps::kRegisterBuffer), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmOps_RegisterBuffer_ResponseParams_Data> params(
message);
params.Allocate();
params->result = in_result;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmOps::Name_);
message.set_method_name("RegisterBuffer");
#endif
message.set_request_id(request_id_);
message.set_trace_nonce(trace_nonce_);
::mojo::internal::SendMojoMessage(*responder_, message);
// SendMojoMessage() fails silently if the responder connection is closed,
// or if the message is malformed.
//
// TODO(darin): If Accept() returns false due to a malformed message, that
// may be good reason to close the connection. However, we don't have a
// way to do that from here. We should add a way.
responder_ = nullptr;
}
// static
bool CameraAlgorithmOpsStubDispatch::Accept(
CameraAlgorithmOps* impl,
mojo::Message* message) {
switch (static_cast<messages::CameraAlgorithmOps>(message->header()->name)) {
case messages::CameraAlgorithmOps::kInitialize: {
break;
}
case messages::CameraAlgorithmOps::kRegisterBuffer: {
break;
}
case messages::CameraAlgorithmOps::kRequest: {
DCHECK(message->is_serialized());
internal::CameraAlgorithmOps_Request_Params_Data* params =
reinterpret_cast<internal::CameraAlgorithmOps_Request_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.2
bool success = true;
uint32_t p_req_id{};
std::vector<uint8_t> p_req_header{};
int32_t p_buffer_handle{};
CameraAlgorithmOps_Request_ParamsDataView input_data_view(params, message);
if (success)
p_req_id = input_data_view.req_id();
if (success && !input_data_view.ReadReqHeader(&p_req_header))
success = false;
if (success)
p_buffer_handle = input_data_view.buffer_handle();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 2, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->Request(
std::move(p_req_id),
std::move(p_req_header),
std::move(p_buffer_handle));
return true;
}
case messages::CameraAlgorithmOps::kDeregisterBuffers: {
DCHECK(message->is_serialized());
internal::CameraAlgorithmOps_DeregisterBuffers_Params_Data* params =
reinterpret_cast<internal::CameraAlgorithmOps_DeregisterBuffers_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.3
bool success = true;
std::vector<int32_t> p_buffer_handles{};
CameraAlgorithmOps_DeregisterBuffers_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadBufferHandles(&p_buffer_handles))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 3, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->DeregisterBuffers(
std::move(p_buffer_handles));
return true;
}
case messages::CameraAlgorithmOps::kUpdateReturn: {
DCHECK(message->is_serialized());
internal::CameraAlgorithmOps_UpdateReturn_Params_Data* params =
reinterpret_cast<internal::CameraAlgorithmOps_UpdateReturn_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.4
bool success = true;
uint32_t p_upd_id{};
uint32_t p_status{};
::mojo::ScopedHandle p_buffer_fd{};
CameraAlgorithmOps_UpdateReturn_ParamsDataView input_data_view(params, message);
if (success)
p_upd_id = input_data_view.upd_id();
if (success)
p_status = input_data_view.status();
if (success)
p_buffer_fd = input_data_view.TakeBufferFd();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 4, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->UpdateReturn(
std::move(p_upd_id),
std::move(p_status),
std::move(p_buffer_fd));
return true;
}
case messages::CameraAlgorithmOps::kDeinitialize: {
DCHECK(message->is_serialized());
internal::CameraAlgorithmOps_Deinitialize_Params_Data* params =
reinterpret_cast<internal::CameraAlgorithmOps_Deinitialize_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.5
bool success = true;
CameraAlgorithmOps_Deinitialize_ParamsDataView input_data_view(params, message);
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 5, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->Deinitialize( );
return true;
}
}
return false;
}
// static
bool CameraAlgorithmOpsStubDispatch::AcceptWithResponder(
CameraAlgorithmOps* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
[[maybe_unused]] const bool message_is_sync =
message->has_flag(mojo::Message::kFlagIsSync);
[[maybe_unused]] const uint64_t request_id = message->request_id();
switch (static_cast<messages::CameraAlgorithmOps>(message->header()->name)) {
case messages::CameraAlgorithmOps::kInitialize: {
internal::CameraAlgorithmOps_Initialize_Params_Data* params =
reinterpret_cast<
internal::CameraAlgorithmOps_Initialize_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.0
bool success = true;
::mojo::PendingRemote<CameraAlgorithmCallbackOps> p_callbacks{};
CameraAlgorithmOps_Initialize_ParamsDataView input_data_view(params, message);
if (success) {
p_callbacks =
input_data_view.TakeCallbacks<decltype(p_callbacks)>();
}
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 0, false);
return false;
}
CameraAlgorithmOps::InitializeCallback callback =
CameraAlgorithmOps_Initialize_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->Initialize(
std::move(p_callbacks), std::move(callback));
return true;
}
case messages::CameraAlgorithmOps::kRegisterBuffer: {
internal::CameraAlgorithmOps_RegisterBuffer_Params_Data* params =
reinterpret_cast<
internal::CameraAlgorithmOps_RegisterBuffer_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmOps.1
bool success = true;
::mojo::ScopedHandle p_buffer_fd{};
CameraAlgorithmOps_RegisterBuffer_ParamsDataView input_data_view(params, message);
if (success)
p_buffer_fd = input_data_view.TakeBufferFd();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmOps::Name_, 1, false);
return false;
}
CameraAlgorithmOps::RegisterBufferCallback callback =
CameraAlgorithmOps_RegisterBuffer_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->RegisterBuffer(
std::move(p_buffer_fd), std::move(callback));
return true;
}
case messages::CameraAlgorithmOps::kRequest: {
break;
}
case messages::CameraAlgorithmOps::kDeregisterBuffers: {
break;
}
case messages::CameraAlgorithmOps::kUpdateReturn: {
break;
}
case messages::CameraAlgorithmOps::kDeinitialize: {
break;
}
}
return false;
}
namespace {
} // namespace
static const mojo::internal::GenericValidationInfo kCameraAlgorithmOpsValidationInfo[] = {
{ &internal::CameraAlgorithmOps_Initialize_Params_Data::Validate,
&internal::CameraAlgorithmOps_Initialize_ResponseParams_Data::Validate},
{ &internal::CameraAlgorithmOps_RegisterBuffer_Params_Data::Validate,
&internal::CameraAlgorithmOps_RegisterBuffer_ResponseParams_Data::Validate},
{ &internal::CameraAlgorithmOps_Request_Params_Data::Validate,
nullptr /* no response */},
{ &internal::CameraAlgorithmOps_DeregisterBuffers_Params_Data::Validate,
nullptr /* no response */},
{ &internal::CameraAlgorithmOps_UpdateReturn_Params_Data::Validate,
nullptr /* no response */},
{ &internal::CameraAlgorithmOps_Deinitialize_Params_Data::Validate,
nullptr /* no response */},
};
bool CameraAlgorithmOpsRequestValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::CameraAlgorithmOps::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kCameraAlgorithmOpsValidationInfo);
}
bool CameraAlgorithmOpsResponseValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::CameraAlgorithmOps::Name_;
return mojo::internal::ValidateResponseGenericPacked(message, name, kCameraAlgorithmOpsValidationInfo);
}
const char CameraAlgorithmCallbackOps::Name_[] = "cros.mojom.CameraAlgorithmCallbackOps";
CameraAlgorithmCallbackOps::IPCStableHashFunction CameraAlgorithmCallbackOps::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
switch (static_cast<messages::CameraAlgorithmCallbackOps>(message.name())) {
case messages::CameraAlgorithmCallbackOps::kReturn: {
return &CameraAlgorithmCallbackOps::Return_Sym::IPCStableHash;
}
case messages::CameraAlgorithmCallbackOps::kUpdate: {
return &CameraAlgorithmCallbackOps::Update_Sym::IPCStableHash;
}
}
#endif // !BUILDFLAG(IS_FUCHSIA)
return nullptr;
}
const char* CameraAlgorithmCallbackOps::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (!is_response) {
switch (static_cast<messages::CameraAlgorithmCallbackOps>(message.name())) {
case messages::CameraAlgorithmCallbackOps::kReturn:
return "Receive cros::mojom::CameraAlgorithmCallbackOps::Return";
case messages::CameraAlgorithmCallbackOps::kUpdate:
return "Receive cros::mojom::CameraAlgorithmCallbackOps::Update";
}
} else {
switch (static_cast<messages::CameraAlgorithmCallbackOps>(message.name())) {
case messages::CameraAlgorithmCallbackOps::kReturn:
return "Receive reply cros::mojom::CameraAlgorithmCallbackOps::Return";
case messages::CameraAlgorithmCallbackOps::kUpdate:
return "Receive reply cros::mojom::CameraAlgorithmCallbackOps::Update";
}
}
return "Receive unknown mojo message";
#else
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (is_response) {
return "Receive mojo reply";
} else {
return "Receive mojo message";
}
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}
#if !BUILDFLAG(IS_FUCHSIA)
uint32_t CameraAlgorithmCallbackOps::Return_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmCallbackOps::Return");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t CameraAlgorithmCallbackOps::Update_Sym::IPCStableHash() {
// This method's address is used for indetifiying the mojo method name after
// symbolization. So each IPCStableHash should have a unique address.
// We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of
// __LINE__ value, which is not unique accross different mojo modules.
// The code below is very similar to NO_CODE_FOLDING, but it uses a unique
// hash instead of __LINE__.
constexpr uint32_t kHash = base::MD5Hash32Constexpr(
"(Impl)cros::mojom::CameraAlgorithmCallbackOps::Update");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
CameraAlgorithmCallbackOpsProxy::CameraAlgorithmCallbackOpsProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void CameraAlgorithmCallbackOpsProxy::Return(
uint32_t in_req_id, uint32_t in_status, int32_t in_buffer_handle) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::CameraAlgorithmCallbackOps::Return", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("req_id"), in_req_id,
"<value of type uint32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("status"), in_status,
"<value of type uint32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("buffer_handle"), in_buffer_handle,
"<value of type int32_t>");
});
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmCallbackOps::kReturn), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmCallbackOps_Return_Params_Data> params(
message);
params.Allocate();
params->req_id = in_req_id;
params->status = in_status;
params->buffer_handle = in_buffer_handle;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmCallbackOps::Name_);
message.set_method_name("Return");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMojoMessage(*receiver_, message);
}
void CameraAlgorithmCallbackOpsProxy::Update(
uint32_t in_upd_id, const std::vector<uint8_t>& in_upd_header, ::mojo::ScopedHandle in_buffer_fd) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::CameraAlgorithmCallbackOps::Update", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("upd_id"), in_upd_id,
"<value of type uint32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("upd_header"), in_upd_header,
"<value of type const std::vector<uint8_t>&>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("buffer_fd"), in_buffer_fd,
"<value of type ::mojo::ScopedHandle>");
});
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const bool is_urgent = false;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) |
((is_urgent) ? mojo::Message::kFlagIsUrgent : 0);
const size_t estimated_payload_size =
0;
mojo::Message message(
base::to_underlying(messages::CameraAlgorithmCallbackOps::kUpdate), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::CameraAlgorithmCallbackOps_Update_Params_Data> params(
message);
params.Allocate();
params->upd_id = in_upd_id;
mojo::internal::MessageFragment<
typename decltype(params->upd_header)::BaseType>
upd_header_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& upd_header_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<uint8_t>>(
in_upd_header, upd_header_fragment, &upd_header_validate_params);
params->upd_header.Set(
upd_header_fragment.is_null() ? nullptr : upd_header_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->upd_header.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null upd_header in CameraAlgorithmCallbackOps.Update request");
mojo::internal::Serialize<mojo::ScopedHandle>(
in_buffer_fd, &params->buffer_fd, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->buffer_fd),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid buffer_fd in CameraAlgorithmCallbackOps.Update request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(CameraAlgorithmCallbackOps::Name_);
message.set_method_name("Update");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMojoMessage(*receiver_, message);
}
// static
bool CameraAlgorithmCallbackOpsStubDispatch::Accept(
CameraAlgorithmCallbackOps* impl,
mojo::Message* message) {
switch (static_cast<messages::CameraAlgorithmCallbackOps>(message->header()->name)) {
case messages::CameraAlgorithmCallbackOps::kReturn: {
DCHECK(message->is_serialized());
internal::CameraAlgorithmCallbackOps_Return_Params_Data* params =
reinterpret_cast<internal::CameraAlgorithmCallbackOps_Return_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmCallbackOps.0
bool success = true;
uint32_t p_req_id{};
uint32_t p_status{};
int32_t p_buffer_handle{};
CameraAlgorithmCallbackOps_Return_ParamsDataView input_data_view(params, message);
if (success)
p_req_id = input_data_view.req_id();
if (success)
p_status = input_data_view.status();
if (success)
p_buffer_handle = input_data_view.buffer_handle();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmCallbackOps::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->Return(
std::move(p_req_id),
std::move(p_status),
std::move(p_buffer_handle));
return true;
}
case messages::CameraAlgorithmCallbackOps::kUpdate: {
DCHECK(message->is_serialized());
internal::CameraAlgorithmCallbackOps_Update_Params_Data* params =
reinterpret_cast<internal::CameraAlgorithmCallbackOps_Update_Params_Data*>(
message->mutable_payload());
// Validation for CameraAlgorithmCallbackOps.1
bool success = true;
uint32_t p_upd_id{};
std::vector<uint8_t> p_upd_header{};
::mojo::ScopedHandle p_buffer_fd{};
CameraAlgorithmCallbackOps_Update_ParamsDataView input_data_view(params, message);
if (success)
p_upd_id = input_data_view.upd_id();
if (success && !input_data_view.ReadUpdHeader(&p_upd_header))
success = false;
if (success)
p_buffer_fd = input_data_view.TakeBufferFd();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
CameraAlgorithmCallbackOps::Name_, 1, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->Update(
std::move(p_upd_id),
std::move(p_upd_header),
std::move(p_buffer_fd));
return true;
}
}
return false;
}
// static
bool CameraAlgorithmCallbackOpsStubDispatch::AcceptWithResponder(
CameraAlgorithmCallbackOps* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
[[maybe_unused]] const bool message_is_sync =
message->has_flag(mojo::Message::kFlagIsSync);
[[maybe_unused]] const uint64_t request_id = message->request_id();
switch (static_cast<messages::CameraAlgorithmCallbackOps>(message->header()->name)) {
case messages::CameraAlgorithmCallbackOps::kReturn: {
break;
}
case messages::CameraAlgorithmCallbackOps::kUpdate: {
break;
}
}
return false;
}
namespace {
} // namespace
static const mojo::internal::GenericValidationInfo kCameraAlgorithmCallbackOpsValidationInfo[] = {
{ &internal::CameraAlgorithmCallbackOps_Return_Params_Data::Validate,
nullptr /* no response */},
{ &internal::CameraAlgorithmCallbackOps_Update_Params_Data::Validate,
nullptr /* no response */},
};
bool CameraAlgorithmCallbackOpsRequestValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::CameraAlgorithmCallbackOps::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kCameraAlgorithmCallbackOpsValidationInfo);
}
} // cros::mojom
namespace mojo {
} // namespace mojo
// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.
namespace cros::mojom {
void CameraAlgorithmOpsInterceptorForTesting::Initialize(::mojo::PendingRemote<CameraAlgorithmCallbackOps> callbacks, InitializeCallback callback) {
GetForwardingInterface()->Initialize(std::move(callbacks), std::move(callback));
}
void CameraAlgorithmOpsInterceptorForTesting::RegisterBuffer(::mojo::ScopedHandle buffer_fd, RegisterBufferCallback callback) {
GetForwardingInterface()->RegisterBuffer(std::move(buffer_fd), std::move(callback));
}
void CameraAlgorithmOpsInterceptorForTesting::Request(uint32_t req_id, const std::vector<uint8_t>& req_header, int32_t buffer_handle) {
GetForwardingInterface()->Request(std::move(req_id), std::move(req_header), std::move(buffer_handle));
}
void CameraAlgorithmOpsInterceptorForTesting::DeregisterBuffers(const std::vector<int32_t>& buffer_handles) {
GetForwardingInterface()->DeregisterBuffers(std::move(buffer_handles));
}
void CameraAlgorithmOpsInterceptorForTesting::UpdateReturn(uint32_t upd_id, uint32_t status, ::mojo::ScopedHandle buffer_fd) {
GetForwardingInterface()->UpdateReturn(std::move(upd_id), std::move(status), std::move(buffer_fd));
}
void CameraAlgorithmOpsInterceptorForTesting::Deinitialize() {
GetForwardingInterface()->Deinitialize();
}
CameraAlgorithmOpsAsyncWaiter::CameraAlgorithmOpsAsyncWaiter(
CameraAlgorithmOps* proxy) : proxy_(proxy) {}
CameraAlgorithmOpsAsyncWaiter::~CameraAlgorithmOpsAsyncWaiter() = default;
void CameraAlgorithmOpsAsyncWaiter::Initialize(
::mojo::PendingRemote<CameraAlgorithmCallbackOps> callbacks, int32_t* out_result) {
base::RunLoop loop;
proxy_->Initialize(std::move(callbacks),
base::BindOnce(
[](base::RunLoop* loop,
int32_t* out_result
,
int32_t result) {*out_result = std::move(result);
loop->Quit();
},
&loop,
out_result));
loop.Run();
}
int32_t CameraAlgorithmOpsAsyncWaiter::Initialize(
::mojo::PendingRemote<CameraAlgorithmCallbackOps> callbacks) {
int32_t async_wait_result;
Initialize(std::move(callbacks),&async_wait_result);
return async_wait_result;
}
void CameraAlgorithmOpsAsyncWaiter::RegisterBuffer(
::mojo::ScopedHandle buffer_fd, int32_t* out_result) {
base::RunLoop loop;
proxy_->RegisterBuffer(std::move(buffer_fd),
base::BindOnce(
[](base::RunLoop* loop,
int32_t* out_result
,
int32_t result) {*out_result = std::move(result);
loop->Quit();
},
&loop,
out_result));
loop.Run();
}
int32_t CameraAlgorithmOpsAsyncWaiter::RegisterBuffer(
::mojo::ScopedHandle buffer_fd) {
int32_t async_wait_result;
RegisterBuffer(std::move(buffer_fd),&async_wait_result);
return async_wait_result;
}
void CameraAlgorithmCallbackOpsInterceptorForTesting::Return(uint32_t req_id, uint32_t status, int32_t buffer_handle) {
GetForwardingInterface()->Return(std::move(req_id), std::move(status), std::move(buffer_handle));
}
void CameraAlgorithmCallbackOpsInterceptorForTesting::Update(uint32_t upd_id, const std::vector<uint8_t>& upd_header, ::mojo::ScopedHandle buffer_fd) {
GetForwardingInterface()->Update(std::move(upd_id), std::move(upd_header), std::move(buffer_fd));
}
CameraAlgorithmCallbackOpsAsyncWaiter::CameraAlgorithmCallbackOpsAsyncWaiter(
CameraAlgorithmCallbackOps* proxy) : proxy_(proxy) {}
CameraAlgorithmCallbackOpsAsyncWaiter::~CameraAlgorithmCallbackOpsAsyncWaiter() = default;
} // cros::mojom
#if defined(__clang__)
#pragma clang diagnostic pop
#endif