blob: 59aa90a1251504fb0486b507e51e1eb8a6bd86bf [file] [log] [blame]
// iioservice/mojo/sensor.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 "iioservice/mojo/sensor.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 "iioservice/mojo/sensor.mojom-params-data.h"
#include "iioservice/mojo/sensor.mojom-shared-message-ids.h"
#include "iioservice/mojo/sensor.mojom-import-headers.h"
#include "iioservice/mojo/sensor.mojom-test-utils.h"
namespace cros::mojom {
const char kScale[] = "scale";
const char kSamplingFrequencyAvailable[] = "sampling_frequency_available";
const char kLocation[] = "location";
const char kLabel[] = "label";
const char kDeviceName[] = "name";
const char kSysPath[] = "syspath";
const char kDevlink[] = "devlink";
const char kLocationBase[] = "base";
const char kLocationLid[] = "lid";
const char kLocationCamera[] = "camera";
const char kLabelBase[] = "accel-base";
const char kLabelLid[] = "accel-display";
const char kAccelerometerChannel[] = "accel";
const char kGyroscopeChannel[] = "anglvel";
const char kMagnetometerChannel[] = "magn";
const char kGravityChannel[] = "gravity";
const char kLightChannel[] = "illuminance";
const char kPressureChannel[] = "pressure";
const char kTimestampChannel[] = "timestamp";
IioEvent::IioEvent()
: chan_type(),
event_type(),
direction(),
channel(),
timestamp() {}
IioEvent::IioEvent(
IioChanType chan_type_in,
IioEventType event_type_in,
IioEventDirection direction_in,
int16_t channel_in,
int64_t timestamp_in)
: chan_type(std::move(chan_type_in)),
event_type(std::move(event_type_in)),
direction(std::move(direction_in)),
channel(std::move(channel_in)),
timestamp(std::move(timestamp_in)) {}
IioEvent::~IioEvent() = default;
size_t IioEvent::Hash(size_t seed) const {
seed = mojo::internal::Hash(seed, this->chan_type);
seed = mojo::internal::Hash(seed, this->event_type);
seed = mojo::internal::Hash(seed, this->direction);
seed = mojo::internal::Hash(seed, this->channel);
seed = mojo::internal::Hash(seed, this->timestamp);
return seed;
}
void IioEvent::WriteIntoTrace(
perfetto::TracedValue traced_context) const {
[[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"chan_type"), this->chan_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type IioChanType>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"event_type"), this->event_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type IioEventType>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"direction"), this->direction,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type IioEventDirection>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"channel"), this->channel,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type int16_t>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"timestamp"), this->timestamp,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type int64_t>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
}
bool IioEvent::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
return Data_::Validate(data, validation_context);
}
const char SensorService::Name_[] = "cros.mojom.SensorService";
SensorService::IPCStableHashFunction SensorService::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
switch (static_cast<messages::SensorService>(message.name())) {
case messages::SensorService::kGetDeviceIds: {
return &SensorService::GetDeviceIds_Sym::IPCStableHash;
}
case messages::SensorService::kGetAllDeviceIds: {
return &SensorService::GetAllDeviceIds_Sym::IPCStableHash;
}
case messages::SensorService::kGetDevice: {
return &SensorService::GetDevice_Sym::IPCStableHash;
}
case messages::SensorService::kRegisterNewDevicesObserver: {
return &SensorService::RegisterNewDevicesObserver_Sym::IPCStableHash;
}
}
#endif // !BUILDFLAG(IS_FUCHSIA)
return nullptr;
}
const char* SensorService::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::SensorService>(message.name())) {
case messages::SensorService::kGetDeviceIds:
return "Receive cros::mojom::SensorService::GetDeviceIds";
case messages::SensorService::kGetAllDeviceIds:
return "Receive cros::mojom::SensorService::GetAllDeviceIds";
case messages::SensorService::kGetDevice:
return "Receive cros::mojom::SensorService::GetDevice";
case messages::SensorService::kRegisterNewDevicesObserver:
return "Receive cros::mojom::SensorService::RegisterNewDevicesObserver";
}
} else {
switch (static_cast<messages::SensorService>(message.name())) {
case messages::SensorService::kGetDeviceIds:
return "Receive reply cros::mojom::SensorService::GetDeviceIds";
case messages::SensorService::kGetAllDeviceIds:
return "Receive reply cros::mojom::SensorService::GetAllDeviceIds";
case messages::SensorService::kGetDevice:
return "Receive reply cros::mojom::SensorService::GetDevice";
case messages::SensorService::kRegisterNewDevicesObserver:
return "Receive reply cros::mojom::SensorService::RegisterNewDevicesObserver";
}
}
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 SensorService::GetDeviceIds_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::SensorService::GetDeviceIds");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorService::GetAllDeviceIds_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::SensorService::GetAllDeviceIds");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorService::GetDevice_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::SensorService::GetDevice");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorService::RegisterNewDevicesObserver_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::SensorService::RegisterNewDevicesObserver");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
class SensorService_GetDeviceIds_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorService_GetDeviceIds_ForwardToCallback(
SensorService::GetDeviceIdsCallback callback
) : callback_(std::move(callback)) {
}
SensorService_GetDeviceIds_ForwardToCallback(const SensorService_GetDeviceIds_ForwardToCallback&) = delete;
SensorService_GetDeviceIds_ForwardToCallback& operator=(const SensorService_GetDeviceIds_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorService::GetDeviceIdsCallback callback_;
};
class SensorService_GetAllDeviceIds_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorService_GetAllDeviceIds_ForwardToCallback(
SensorService::GetAllDeviceIdsCallback callback
) : callback_(std::move(callback)) {
}
SensorService_GetAllDeviceIds_ForwardToCallback(const SensorService_GetAllDeviceIds_ForwardToCallback&) = delete;
SensorService_GetAllDeviceIds_ForwardToCallback& operator=(const SensorService_GetAllDeviceIds_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorService::GetAllDeviceIdsCallback callback_;
};
SensorServiceProxy::SensorServiceProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void SensorServiceProxy::GetDeviceIds(
DeviceType in_type, GetDeviceIdsCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorService::GetDeviceIds", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("type"), in_type,
"<value of type DeviceType>");
});
#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::SensorService::kGetDeviceIds), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorService_GetDeviceIds_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<::cros::mojom::DeviceType>(
in_type, &params->type);
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorService::Name_);
message.set_method_name("GetDeviceIds");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorService_GetDeviceIds_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorServiceProxy::GetAllDeviceIds(
GetAllDeviceIdsCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT0("mojom", "Send cros::mojom::SensorService::GetAllDeviceIds");
#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::SensorService::kGetAllDeviceIds), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorService_GetAllDeviceIds_Params_Data> params(
message);
params.Allocate();
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorService::Name_);
message.set_method_name("GetAllDeviceIds");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorService_GetAllDeviceIds_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorServiceProxy::GetDevice(
int32_t in_iio_device_id, ::mojo::PendingReceiver<SensorDevice> in_device_request) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorService::GetDevice", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_device_id"), in_iio_device_id,
"<value of type int32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("device_request"), in_device_request,
"<value of type ::mojo::PendingReceiver<SensorDevice>>");
});
#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::SensorService::kGetDevice), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorService_GetDevice_Params_Data> params(
message);
params.Allocate();
params->iio_device_id = in_iio_device_id;
mojo::internal::Serialize<mojo::InterfaceRequestDataView<::cros::mojom::SensorDeviceInterfaceBase>>(
in_device_request, &params->device_request, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->device_request),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid device_request in SensorService.GetDevice request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorService::Name_);
message.set_method_name("GetDevice");
#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 SensorServiceProxy::RegisterNewDevicesObserver(
::mojo::PendingRemote<SensorServiceNewDevicesObserver> in_observer) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorService::RegisterNewDevicesObserver", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("observer"), in_observer,
"<value of type ::mojo::PendingRemote<SensorServiceNewDevicesObserver>>");
});
#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::SensorService::kRegisterNewDevicesObserver), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorService_RegisterNewDevicesObserver_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<mojo::InterfacePtrDataView<::cros::mojom::SensorServiceNewDevicesObserverInterfaceBase>>(
in_observer, &params->observer, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->observer),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid observer in SensorService.RegisterNewDevicesObserver request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorService::Name_);
message.set_method_name("RegisterNewDevicesObserver");
#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 SensorService_GetDeviceIds_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorService::GetDeviceIdsCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorService_GetDeviceIds_ProxyToResponder> proxy(
new SensorService_GetDeviceIds_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorService_GetDeviceIds_ProxyToResponder::Run,
std::move(proxy));
}
~SensorService_GetDeviceIds_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:
SensorService_GetDeviceIds_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)
<< "SensorService::GetDeviceIdsCallback 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(
const std::vector<int32_t>& in_iio_device_ids);
};
bool SensorService_GetDeviceIds_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorService_GetDeviceIds_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorService_GetDeviceIds_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorService.0
bool success = true;
std::vector<int32_t> p_iio_device_ids{};
SensorService_GetDeviceIds_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioDeviceIds(&p_iio_device_ids))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorService::Name_, 0, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_iio_device_ids));
return true;
}
void SensorService_GetDeviceIds_ProxyToResponder::Run(
const std::vector<int32_t>& in_iio_device_ids) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorService::GetDeviceIds", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_device_ids"), in_iio_device_ids,
"<value of type const std::vector<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::SensorService::kGetDeviceIds), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorService_GetDeviceIds_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_device_ids)::BaseType>
iio_device_ids_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_device_ids_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_iio_device_ids, iio_device_ids_fragment, &iio_device_ids_validate_params);
params->iio_device_ids.Set(
iio_device_ids_fragment.is_null() ? nullptr : iio_device_ids_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_device_ids.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_device_ids in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorService::Name_);
message.set_method_name("GetDeviceIds");
#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 SensorService_GetAllDeviceIds_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorService::GetAllDeviceIdsCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorService_GetAllDeviceIds_ProxyToResponder> proxy(
new SensorService_GetAllDeviceIds_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorService_GetAllDeviceIds_ProxyToResponder::Run,
std::move(proxy));
}
~SensorService_GetAllDeviceIds_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:
SensorService_GetAllDeviceIds_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)
<< "SensorService::GetAllDeviceIdsCallback 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(
const base::flat_map<int32_t, std::vector<DeviceType>>& in_iio_device_ids_types);
};
bool SensorService_GetAllDeviceIds_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorService_GetAllDeviceIds_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorService_GetAllDeviceIds_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorService.1
bool success = true;
base::flat_map<int32_t, std::vector<DeviceType>> p_iio_device_ids_types{};
SensorService_GetAllDeviceIds_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioDeviceIdsTypes(&p_iio_device_ids_types))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorService::Name_, 1, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_iio_device_ids_types));
return true;
}
void SensorService_GetAllDeviceIds_ProxyToResponder::Run(
const base::flat_map<int32_t, std::vector<DeviceType>>& in_iio_device_ids_types) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorService::GetAllDeviceIds", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_device_ids_types"), in_iio_device_ids_types,
"<value of type const base::flat_map<int32_t, std::vector<DeviceType>>&>");
});
#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::SensorService::kGetAllDeviceIds), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorService_GetAllDeviceIds_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_device_ids_types)::BaseType>
iio_device_ids_types_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_device_ids_types_validate_params =
mojo::internal::GetMapValidator<*&mojo::internal::GetArrayValidator<0, false, nullptr>(), *&mojo::internal::GetArrayValidator<0, false, &mojo::internal::GetArrayOfEnumsValidator<0, false, ::cros::mojom::internal::DeviceType_Data::Validate>()>()>();
mojo::internal::Serialize<mojo::MapDataView<int32_t, mojo::ArrayDataView<::cros::mojom::DeviceType>>>(
in_iio_device_ids_types, iio_device_ids_types_fragment, &iio_device_ids_types_validate_params);
params->iio_device_ids_types.Set(
iio_device_ids_types_fragment.is_null() ? nullptr : iio_device_ids_types_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_device_ids_types.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_device_ids_types in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorService::Name_);
message.set_method_name("GetAllDeviceIds");
#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 SensorServiceStubDispatch::Accept(
SensorService* impl,
mojo::Message* message) {
switch (static_cast<messages::SensorService>(message->header()->name)) {
case messages::SensorService::kGetDeviceIds: {
break;
}
case messages::SensorService::kGetAllDeviceIds: {
break;
}
case messages::SensorService::kGetDevice: {
DCHECK(message->is_serialized());
internal::SensorService_GetDevice_Params_Data* params =
reinterpret_cast<internal::SensorService_GetDevice_Params_Data*>(
message->mutable_payload());
// Validation for SensorService.2
bool success = true;
int32_t p_iio_device_id{};
::mojo::PendingReceiver<SensorDevice> p_device_request{};
SensorService_GetDevice_ParamsDataView input_data_view(params, message);
if (success)
p_iio_device_id = input_data_view.iio_device_id();
if (success) {
p_device_request =
input_data_view.TakeDeviceRequest<decltype(p_device_request)>();
}
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorService::Name_, 2, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetDevice(
std::move(p_iio_device_id),
std::move(p_device_request));
return true;
}
case messages::SensorService::kRegisterNewDevicesObserver: {
DCHECK(message->is_serialized());
internal::SensorService_RegisterNewDevicesObserver_Params_Data* params =
reinterpret_cast<internal::SensorService_RegisterNewDevicesObserver_Params_Data*>(
message->mutable_payload());
// Validation for SensorService.3
bool success = true;
::mojo::PendingRemote<SensorServiceNewDevicesObserver> p_observer{};
SensorService_RegisterNewDevicesObserver_ParamsDataView input_data_view(params, message);
if (success) {
p_observer =
input_data_view.TakeObserver<decltype(p_observer)>();
}
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorService::Name_, 3, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->RegisterNewDevicesObserver(
std::move(p_observer));
return true;
}
}
return false;
}
// static
bool SensorServiceStubDispatch::AcceptWithResponder(
SensorService* 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::SensorService>(message->header()->name)) {
case messages::SensorService::kGetDeviceIds: {
internal::SensorService_GetDeviceIds_Params_Data* params =
reinterpret_cast<
internal::SensorService_GetDeviceIds_Params_Data*>(
message->mutable_payload());
// Validation for SensorService.0
bool success = true;
DeviceType p_type{};
SensorService_GetDeviceIds_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadType(&p_type))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorService::Name_, 0, false);
return false;
}
SensorService::GetDeviceIdsCallback callback =
SensorService_GetDeviceIds_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetDeviceIds(
std::move(p_type), std::move(callback));
return true;
}
case messages::SensorService::kGetAllDeviceIds: {
internal::SensorService_GetAllDeviceIds_Params_Data* params =
reinterpret_cast<
internal::SensorService_GetAllDeviceIds_Params_Data*>(
message->mutable_payload());
// Validation for SensorService.1
bool success = true;
SensorService_GetAllDeviceIds_ParamsDataView input_data_view(params, message);
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorService::Name_, 1, false);
return false;
}
SensorService::GetAllDeviceIdsCallback callback =
SensorService_GetAllDeviceIds_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetAllDeviceIds(std::move(callback));
return true;
}
case messages::SensorService::kGetDevice: {
break;
}
case messages::SensorService::kRegisterNewDevicesObserver: {
break;
}
}
return false;
}
namespace {
} // namespace
static const mojo::internal::GenericValidationInfo kSensorServiceValidationInfo[] = {
{ &internal::SensorService_GetDeviceIds_Params_Data::Validate,
&internal::SensorService_GetDeviceIds_ResponseParams_Data::Validate},
{ &internal::SensorService_GetAllDeviceIds_Params_Data::Validate,
&internal::SensorService_GetAllDeviceIds_ResponseParams_Data::Validate},
{ &internal::SensorService_GetDevice_Params_Data::Validate,
nullptr /* no response */},
{ &internal::SensorService_RegisterNewDevicesObserver_Params_Data::Validate,
nullptr /* no response */},
};
bool SensorServiceRequestValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::SensorService::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kSensorServiceValidationInfo);
}
bool SensorServiceResponseValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::SensorService::Name_;
return mojo::internal::ValidateResponseGenericPacked(message, name, kSensorServiceValidationInfo);
}
const char SensorDevice::Name_[] = "cros.mojom.SensorDevice";
SensorDevice::IPCStableHashFunction SensorDevice::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
switch (static_cast<messages::SensorDevice>(message.name())) {
case messages::SensorDevice::kSetTimeout: {
return &SensorDevice::SetTimeout_Sym::IPCStableHash;
}
case messages::SensorDevice::kGetAttributes: {
return &SensorDevice::GetAttributes_Sym::IPCStableHash;
}
case messages::SensorDevice::kSetFrequency: {
return &SensorDevice::SetFrequency_Sym::IPCStableHash;
}
case messages::SensorDevice::kStartReadingSamples: {
return &SensorDevice::StartReadingSamples_Sym::IPCStableHash;
}
case messages::SensorDevice::kStopReadingSamples: {
return &SensorDevice::StopReadingSamples_Sym::IPCStableHash;
}
case messages::SensorDevice::kGetAllChannelIds: {
return &SensorDevice::GetAllChannelIds_Sym::IPCStableHash;
}
case messages::SensorDevice::kSetChannelsEnabled: {
return &SensorDevice::SetChannelsEnabled_Sym::IPCStableHash;
}
case messages::SensorDevice::kGetChannelsEnabled: {
return &SensorDevice::GetChannelsEnabled_Sym::IPCStableHash;
}
case messages::SensorDevice::kGetChannelsAttributes: {
return &SensorDevice::GetChannelsAttributes_Sym::IPCStableHash;
}
case messages::SensorDevice::kGetAllEvents: {
return &SensorDevice::GetAllEvents_Sym::IPCStableHash;
}
case messages::SensorDevice::kGetEventsAttributes: {
return &SensorDevice::GetEventsAttributes_Sym::IPCStableHash;
}
case messages::SensorDevice::kStartReadingEvents: {
return &SensorDevice::StartReadingEvents_Sym::IPCStableHash;
}
}
#endif // !BUILDFLAG(IS_FUCHSIA)
return nullptr;
}
const char* SensorDevice::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::SensorDevice>(message.name())) {
case messages::SensorDevice::kSetTimeout:
return "Receive cros::mojom::SensorDevice::SetTimeout";
case messages::SensorDevice::kGetAttributes:
return "Receive cros::mojom::SensorDevice::GetAttributes";
case messages::SensorDevice::kSetFrequency:
return "Receive cros::mojom::SensorDevice::SetFrequency";
case messages::SensorDevice::kStartReadingSamples:
return "Receive cros::mojom::SensorDevice::StartReadingSamples";
case messages::SensorDevice::kStopReadingSamples:
return "Receive cros::mojom::SensorDevice::StopReadingSamples";
case messages::SensorDevice::kGetAllChannelIds:
return "Receive cros::mojom::SensorDevice::GetAllChannelIds";
case messages::SensorDevice::kSetChannelsEnabled:
return "Receive cros::mojom::SensorDevice::SetChannelsEnabled";
case messages::SensorDevice::kGetChannelsEnabled:
return "Receive cros::mojom::SensorDevice::GetChannelsEnabled";
case messages::SensorDevice::kGetChannelsAttributes:
return "Receive cros::mojom::SensorDevice::GetChannelsAttributes";
case messages::SensorDevice::kGetAllEvents:
return "Receive cros::mojom::SensorDevice::GetAllEvents";
case messages::SensorDevice::kGetEventsAttributes:
return "Receive cros::mojom::SensorDevice::GetEventsAttributes";
case messages::SensorDevice::kStartReadingEvents:
return "Receive cros::mojom::SensorDevice::StartReadingEvents";
}
} else {
switch (static_cast<messages::SensorDevice>(message.name())) {
case messages::SensorDevice::kSetTimeout:
return "Receive reply cros::mojom::SensorDevice::SetTimeout";
case messages::SensorDevice::kGetAttributes:
return "Receive reply cros::mojom::SensorDevice::GetAttributes";
case messages::SensorDevice::kSetFrequency:
return "Receive reply cros::mojom::SensorDevice::SetFrequency";
case messages::SensorDevice::kStartReadingSamples:
return "Receive reply cros::mojom::SensorDevice::StartReadingSamples";
case messages::SensorDevice::kStopReadingSamples:
return "Receive reply cros::mojom::SensorDevice::StopReadingSamples";
case messages::SensorDevice::kGetAllChannelIds:
return "Receive reply cros::mojom::SensorDevice::GetAllChannelIds";
case messages::SensorDevice::kSetChannelsEnabled:
return "Receive reply cros::mojom::SensorDevice::SetChannelsEnabled";
case messages::SensorDevice::kGetChannelsEnabled:
return "Receive reply cros::mojom::SensorDevice::GetChannelsEnabled";
case messages::SensorDevice::kGetChannelsAttributes:
return "Receive reply cros::mojom::SensorDevice::GetChannelsAttributes";
case messages::SensorDevice::kGetAllEvents:
return "Receive reply cros::mojom::SensorDevice::GetAllEvents";
case messages::SensorDevice::kGetEventsAttributes:
return "Receive reply cros::mojom::SensorDevice::GetEventsAttributes";
case messages::SensorDevice::kStartReadingEvents:
return "Receive reply cros::mojom::SensorDevice::StartReadingEvents";
}
}
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 SensorDevice::SetTimeout_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::SensorDevice::SetTimeout");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::GetAttributes_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::SensorDevice::GetAttributes");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::SetFrequency_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::SensorDevice::SetFrequency");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::StartReadingSamples_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::SensorDevice::StartReadingSamples");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::StopReadingSamples_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::SensorDevice::StopReadingSamples");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::GetAllChannelIds_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::SensorDevice::GetAllChannelIds");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::SetChannelsEnabled_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::SensorDevice::SetChannelsEnabled");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::GetChannelsEnabled_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::SensorDevice::GetChannelsEnabled");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::GetChannelsAttributes_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::SensorDevice::GetChannelsAttributes");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::GetAllEvents_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::SensorDevice::GetAllEvents");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::GetEventsAttributes_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::SensorDevice::GetEventsAttributes");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDevice::StartReadingEvents_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::SensorDevice::StartReadingEvents");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
class SensorDevice_GetAttributes_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_GetAttributes_ForwardToCallback(
SensorDevice::GetAttributesCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_GetAttributes_ForwardToCallback(const SensorDevice_GetAttributes_ForwardToCallback&) = delete;
SensorDevice_GetAttributes_ForwardToCallback& operator=(const SensorDevice_GetAttributes_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::GetAttributesCallback callback_;
};
class SensorDevice_SetFrequency_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_SetFrequency_ForwardToCallback(
SensorDevice::SetFrequencyCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_SetFrequency_ForwardToCallback(const SensorDevice_SetFrequency_ForwardToCallback&) = delete;
SensorDevice_SetFrequency_ForwardToCallback& operator=(const SensorDevice_SetFrequency_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::SetFrequencyCallback callback_;
};
class SensorDevice_GetAllChannelIds_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_GetAllChannelIds_ForwardToCallback(
SensorDevice::GetAllChannelIdsCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_GetAllChannelIds_ForwardToCallback(const SensorDevice_GetAllChannelIds_ForwardToCallback&) = delete;
SensorDevice_GetAllChannelIds_ForwardToCallback& operator=(const SensorDevice_GetAllChannelIds_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::GetAllChannelIdsCallback callback_;
};
class SensorDevice_SetChannelsEnabled_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_SetChannelsEnabled_ForwardToCallback(
SensorDevice::SetChannelsEnabledCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_SetChannelsEnabled_ForwardToCallback(const SensorDevice_SetChannelsEnabled_ForwardToCallback&) = delete;
SensorDevice_SetChannelsEnabled_ForwardToCallback& operator=(const SensorDevice_SetChannelsEnabled_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::SetChannelsEnabledCallback callback_;
};
class SensorDevice_GetChannelsEnabled_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_GetChannelsEnabled_ForwardToCallback(
SensorDevice::GetChannelsEnabledCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_GetChannelsEnabled_ForwardToCallback(const SensorDevice_GetChannelsEnabled_ForwardToCallback&) = delete;
SensorDevice_GetChannelsEnabled_ForwardToCallback& operator=(const SensorDevice_GetChannelsEnabled_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::GetChannelsEnabledCallback callback_;
};
class SensorDevice_GetChannelsAttributes_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_GetChannelsAttributes_ForwardToCallback(
SensorDevice::GetChannelsAttributesCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_GetChannelsAttributes_ForwardToCallback(const SensorDevice_GetChannelsAttributes_ForwardToCallback&) = delete;
SensorDevice_GetChannelsAttributes_ForwardToCallback& operator=(const SensorDevice_GetChannelsAttributes_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::GetChannelsAttributesCallback callback_;
};
class SensorDevice_GetAllEvents_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_GetAllEvents_ForwardToCallback(
SensorDevice::GetAllEventsCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_GetAllEvents_ForwardToCallback(const SensorDevice_GetAllEvents_ForwardToCallback&) = delete;
SensorDevice_GetAllEvents_ForwardToCallback& operator=(const SensorDevice_GetAllEvents_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::GetAllEventsCallback callback_;
};
class SensorDevice_GetEventsAttributes_ForwardToCallback
: public mojo::MessageReceiver {
public:
SensorDevice_GetEventsAttributes_ForwardToCallback(
SensorDevice::GetEventsAttributesCallback callback
) : callback_(std::move(callback)) {
}
SensorDevice_GetEventsAttributes_ForwardToCallback(const SensorDevice_GetEventsAttributes_ForwardToCallback&) = delete;
SensorDevice_GetEventsAttributes_ForwardToCallback& operator=(const SensorDevice_GetEventsAttributes_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
SensorDevice::GetEventsAttributesCallback callback_;
};
SensorDeviceProxy::SensorDeviceProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void SensorDeviceProxy::SetTimeout(
uint32_t in_timeout) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::SetTimeout", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("timeout"), in_timeout,
"<value of type uint32_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::SensorDevice::kSetTimeout), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_SetTimeout_Params_Data> params(
message);
params.Allocate();
params->timeout = in_timeout;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("SetTimeout");
#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 SensorDeviceProxy::GetAttributes(
const std::vector<std::string>& in_attr_names, GetAttributesCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::GetAttributes", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("attr_names"), in_attr_names,
"<value of type const std::vector<std::string>&>");
});
#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::SensorDevice::kGetAttributes), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetAttributes_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->attr_names)::BaseType>
attr_names_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& attr_names_validate_params =
mojo::internal::GetArrayValidator<0, false, &mojo::internal::GetArrayValidator<0, false, nullptr>()>();
mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>(
in_attr_names, attr_names_fragment, &attr_names_validate_params);
params->attr_names.Set(
attr_names_fragment.is_null() ? nullptr : attr_names_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->attr_names.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null attr_names in SensorDevice.GetAttributes request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetAttributes");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_GetAttributes_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::SetFrequency(
double in_frequency, SetFrequencyCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::SetFrequency", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("frequency"), in_frequency,
"<value of type double>");
});
#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::SensorDevice::kSetFrequency), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_SetFrequency_Params_Data> params(
message);
params.Allocate();
params->frequency = in_frequency;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("SetFrequency");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_SetFrequency_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::StartReadingSamples(
::mojo::PendingRemote<SensorDeviceSamplesObserver> in_observer) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::StartReadingSamples", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("observer"), in_observer,
"<value of type ::mojo::PendingRemote<SensorDeviceSamplesObserver>>");
});
#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::SensorDevice::kStartReadingSamples), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_StartReadingSamples_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<mojo::InterfacePtrDataView<::cros::mojom::SensorDeviceSamplesObserverInterfaceBase>>(
in_observer, &params->observer, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->observer),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid observer in SensorDevice.StartReadingSamples request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("StartReadingSamples");
#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 SensorDeviceProxy::StopReadingSamples(
) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT0("mojom", "Send cros::mojom::SensorDevice::StopReadingSamples");
#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::SensorDevice::kStopReadingSamples), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_StopReadingSamples_Params_Data> params(
message);
params.Allocate();
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("StopReadingSamples");
#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 SensorDeviceProxy::GetAllChannelIds(
GetAllChannelIdsCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT0("mojom", "Send cros::mojom::SensorDevice::GetAllChannelIds");
#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::SensorDevice::kGetAllChannelIds), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetAllChannelIds_Params_Data> params(
message);
params.Allocate();
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetAllChannelIds");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_GetAllChannelIds_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::SetChannelsEnabled(
const std::vector<int32_t>& in_iio_chn_indices, bool in_en, SetChannelsEnabledCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::SetChannelsEnabled", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_chn_indices"), in_iio_chn_indices,
"<value of type const std::vector<int32_t>&>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("en"), in_en,
"<value of type bool>");
});
#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::SensorDevice::kSetChannelsEnabled), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_SetChannelsEnabled_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_chn_indices)::BaseType>
iio_chn_indices_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_chn_indices_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_iio_chn_indices, iio_chn_indices_fragment, &iio_chn_indices_validate_params);
params->iio_chn_indices.Set(
iio_chn_indices_fragment.is_null() ? nullptr : iio_chn_indices_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_chn_indices.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_chn_indices in SensorDevice.SetChannelsEnabled request");
params->en = in_en;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("SetChannelsEnabled");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_SetChannelsEnabled_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::GetChannelsEnabled(
const std::vector<int32_t>& in_iio_chn_indices, GetChannelsEnabledCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::GetChannelsEnabled", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_chn_indices"), in_iio_chn_indices,
"<value of type const std::vector<int32_t>&>");
});
#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::SensorDevice::kGetChannelsEnabled), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetChannelsEnabled_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_chn_indices)::BaseType>
iio_chn_indices_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_chn_indices_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_iio_chn_indices, iio_chn_indices_fragment, &iio_chn_indices_validate_params);
params->iio_chn_indices.Set(
iio_chn_indices_fragment.is_null() ? nullptr : iio_chn_indices_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_chn_indices.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_chn_indices in SensorDevice.GetChannelsEnabled request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetChannelsEnabled");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_GetChannelsEnabled_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::GetChannelsAttributes(
const std::vector<int32_t>& in_iio_chn_indices, const std::string& in_attr_name, GetChannelsAttributesCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::GetChannelsAttributes", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_chn_indices"), in_iio_chn_indices,
"<value of type const std::vector<int32_t>&>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("attr_name"), in_attr_name,
"<value of type const std::string&>");
});
#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::SensorDevice::kGetChannelsAttributes), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetChannelsAttributes_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_chn_indices)::BaseType>
iio_chn_indices_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_chn_indices_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_iio_chn_indices, iio_chn_indices_fragment, &iio_chn_indices_validate_params);
params->iio_chn_indices.Set(
iio_chn_indices_fragment.is_null() ? nullptr : iio_chn_indices_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_chn_indices.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_chn_indices in SensorDevice.GetChannelsAttributes request");
mojo::internal::MessageFragment<
typename decltype(params->attr_name)::BaseType> attr_name_fragment(
params.message());
mojo::internal::Serialize<mojo::StringDataView>(
in_attr_name, attr_name_fragment);
params->attr_name.Set(
attr_name_fragment.is_null() ? nullptr : attr_name_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->attr_name.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null attr_name in SensorDevice.GetChannelsAttributes request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetChannelsAttributes");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_GetChannelsAttributes_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::GetAllEvents(
GetAllEventsCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT0("mojom", "Send cros::mojom::SensorDevice::GetAllEvents");
#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::SensorDevice::kGetAllEvents), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetAllEvents_Params_Data> params(
message);
params.Allocate();
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetAllEvents");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_GetAllEvents_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::GetEventsAttributes(
const std::vector<int32_t>& in_iio_event_indices, const std::string& in_attr_name, GetEventsAttributesCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::GetEventsAttributes", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_event_indices"), in_iio_event_indices,
"<value of type const std::vector<int32_t>&>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("attr_name"), in_attr_name,
"<value of type const std::string&>");
});
#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::SensorDevice::kGetEventsAttributes), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetEventsAttributes_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_event_indices)::BaseType>
iio_event_indices_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_event_indices_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_iio_event_indices, iio_event_indices_fragment, &iio_event_indices_validate_params);
params->iio_event_indices.Set(
iio_event_indices_fragment.is_null() ? nullptr : iio_event_indices_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_event_indices.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_event_indices in SensorDevice.GetEventsAttributes request");
mojo::internal::MessageFragment<
typename decltype(params->attr_name)::BaseType> attr_name_fragment(
params.message());
mojo::internal::Serialize<mojo::StringDataView>(
in_attr_name, attr_name_fragment);
params->attr_name.Set(
attr_name_fragment.is_null() ? nullptr : attr_name_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->attr_name.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null attr_name in SensorDevice.GetEventsAttributes request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetEventsAttributes");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new SensorDevice_GetEventsAttributes_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder));
}
void SensorDeviceProxy::StartReadingEvents(
const std::vector<int32_t>& in_iio_event_indices, ::mojo::PendingRemote<SensorDeviceEventsObserver> in_observer) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDevice::StartReadingEvents", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_event_indices"), in_iio_event_indices,
"<value of type const std::vector<int32_t>&>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("observer"), in_observer,
"<value of type ::mojo::PendingRemote<SensorDeviceEventsObserver>>");
});
#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::SensorDevice::kStartReadingEvents), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_StartReadingEvents_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_event_indices)::BaseType>
iio_event_indices_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_event_indices_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_iio_event_indices, iio_event_indices_fragment, &iio_event_indices_validate_params);
params->iio_event_indices.Set(
iio_event_indices_fragment.is_null() ? nullptr : iio_event_indices_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_event_indices.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_event_indices in SensorDevice.StartReadingEvents request");
mojo::internal::Serialize<mojo::InterfacePtrDataView<::cros::mojom::SensorDeviceEventsObserverInterfaceBase>>(
in_observer, &params->observer, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->observer),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid observer in SensorDevice.StartReadingEvents request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("StartReadingEvents");
#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 SensorDevice_GetAttributes_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::GetAttributesCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_GetAttributes_ProxyToResponder> proxy(
new SensorDevice_GetAttributes_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_GetAttributes_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_GetAttributes_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:
SensorDevice_GetAttributes_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)
<< "SensorDevice::GetAttributesCallback 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(
const std::vector<std::optional<std::string>>& in_values);
};
bool SensorDevice_GetAttributes_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_GetAttributes_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_GetAttributes_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.1
bool success = true;
std::vector<std::optional<std::string>> p_values{};
SensorDevice_GetAttributes_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadValues(&p_values))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 1, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_values));
return true;
}
void SensorDevice_GetAttributes_ProxyToResponder::Run(
const std::vector<std::optional<std::string>>& in_values) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::GetAttributes", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("values"), in_values,
"<value of type const std::vector<std::optional<std::string>>&>");
});
#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::SensorDevice::kGetAttributes), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetAttributes_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->values)::BaseType>
values_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& values_validate_params =
mojo::internal::GetArrayValidator<0, true, &mojo::internal::GetArrayValidator<0, false, nullptr>()>();
mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>(
in_values, values_fragment, &values_validate_params);
params->values.Set(
values_fragment.is_null() ? nullptr : values_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->values.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null values in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetAttributes");
#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 SensorDevice_SetFrequency_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::SetFrequencyCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_SetFrequency_ProxyToResponder> proxy(
new SensorDevice_SetFrequency_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_SetFrequency_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_SetFrequency_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:
SensorDevice_SetFrequency_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)
<< "SensorDevice::SetFrequencyCallback 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(
double in_result_freq);
};
bool SensorDevice_SetFrequency_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_SetFrequency_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_SetFrequency_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.2
bool success = true;
double p_result_freq{};
SensorDevice_SetFrequency_ResponseParamsDataView input_data_view(params, message);
if (success)
p_result_freq = input_data_view.result_freq();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 2, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_result_freq));
return true;
}
void SensorDevice_SetFrequency_ProxyToResponder::Run(
double in_result_freq) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::SetFrequency", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("result_freq"), in_result_freq,
"<value of type double>");
});
#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::SensorDevice::kSetFrequency), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_SetFrequency_ResponseParams_Data> params(
message);
params.Allocate();
params->result_freq = in_result_freq;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("SetFrequency");
#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 SensorDevice_GetAllChannelIds_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::GetAllChannelIdsCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_GetAllChannelIds_ProxyToResponder> proxy(
new SensorDevice_GetAllChannelIds_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_GetAllChannelIds_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_GetAllChannelIds_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:
SensorDevice_GetAllChannelIds_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)
<< "SensorDevice::GetAllChannelIdsCallback 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(
const std::vector<std::string>& in_iio_chn_ids);
};
bool SensorDevice_GetAllChannelIds_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_GetAllChannelIds_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_GetAllChannelIds_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.5
bool success = true;
std::vector<std::string> p_iio_chn_ids{};
SensorDevice_GetAllChannelIds_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioChnIds(&p_iio_chn_ids))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 5, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_iio_chn_ids));
return true;
}
void SensorDevice_GetAllChannelIds_ProxyToResponder::Run(
const std::vector<std::string>& in_iio_chn_ids) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::GetAllChannelIds", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_chn_ids"), in_iio_chn_ids,
"<value of type const std::vector<std::string>&>");
});
#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::SensorDevice::kGetAllChannelIds), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetAllChannelIds_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_chn_ids)::BaseType>
iio_chn_ids_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_chn_ids_validate_params =
mojo::internal::GetArrayValidator<0, false, &mojo::internal::GetArrayValidator<0, false, nullptr>()>();
mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>(
in_iio_chn_ids, iio_chn_ids_fragment, &iio_chn_ids_validate_params);
params->iio_chn_ids.Set(
iio_chn_ids_fragment.is_null() ? nullptr : iio_chn_ids_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_chn_ids.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_chn_ids in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetAllChannelIds");
#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 SensorDevice_SetChannelsEnabled_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::SetChannelsEnabledCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_SetChannelsEnabled_ProxyToResponder> proxy(
new SensorDevice_SetChannelsEnabled_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_SetChannelsEnabled_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_SetChannelsEnabled_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:
SensorDevice_SetChannelsEnabled_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)
<< "SensorDevice::SetChannelsEnabledCallback 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(
const std::vector<int32_t>& in_failed_indices);
};
bool SensorDevice_SetChannelsEnabled_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_SetChannelsEnabled_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_SetChannelsEnabled_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.6
bool success = true;
std::vector<int32_t> p_failed_indices{};
SensorDevice_SetChannelsEnabled_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadFailedIndices(&p_failed_indices))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 6, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_failed_indices));
return true;
}
void SensorDevice_SetChannelsEnabled_ProxyToResponder::Run(
const std::vector<int32_t>& in_failed_indices) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::SetChannelsEnabled", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("failed_indices"), in_failed_indices,
"<value of type const std::vector<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::SensorDevice::kSetChannelsEnabled), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_SetChannelsEnabled_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->failed_indices)::BaseType>
failed_indices_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& failed_indices_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<int32_t>>(
in_failed_indices, failed_indices_fragment, &failed_indices_validate_params);
params->failed_indices.Set(
failed_indices_fragment.is_null() ? nullptr : failed_indices_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->failed_indices.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null failed_indices in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("SetChannelsEnabled");
#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 SensorDevice_GetChannelsEnabled_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::GetChannelsEnabledCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_GetChannelsEnabled_ProxyToResponder> proxy(
new SensorDevice_GetChannelsEnabled_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_GetChannelsEnabled_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_GetChannelsEnabled_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:
SensorDevice_GetChannelsEnabled_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)
<< "SensorDevice::GetChannelsEnabledCallback 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(
const std::vector<bool>& in_enabled);
};
bool SensorDevice_GetChannelsEnabled_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_GetChannelsEnabled_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_GetChannelsEnabled_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.7
bool success = true;
std::vector<bool> p_enabled{};
SensorDevice_GetChannelsEnabled_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadEnabled(&p_enabled))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 7, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_enabled));
return true;
}
void SensorDevice_GetChannelsEnabled_ProxyToResponder::Run(
const std::vector<bool>& in_enabled) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::GetChannelsEnabled", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("enabled"), in_enabled,
"<value of type const std::vector<bool>&>");
});
#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::SensorDevice::kGetChannelsEnabled), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetChannelsEnabled_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->enabled)::BaseType>
enabled_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& enabled_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<bool>>(
in_enabled, enabled_fragment, &enabled_validate_params);
params->enabled.Set(
enabled_fragment.is_null() ? nullptr : enabled_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->enabled.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null enabled in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetChannelsEnabled");
#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 SensorDevice_GetChannelsAttributes_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::GetChannelsAttributesCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_GetChannelsAttributes_ProxyToResponder> proxy(
new SensorDevice_GetChannelsAttributes_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_GetChannelsAttributes_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_GetChannelsAttributes_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:
SensorDevice_GetChannelsAttributes_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)
<< "SensorDevice::GetChannelsAttributesCallback 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(
const std::vector<std::optional<std::string>>& in_values);
};
bool SensorDevice_GetChannelsAttributes_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_GetChannelsAttributes_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_GetChannelsAttributes_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.8
bool success = true;
std::vector<std::optional<std::string>> p_values{};
SensorDevice_GetChannelsAttributes_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadValues(&p_values))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 8, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_values));
return true;
}
void SensorDevice_GetChannelsAttributes_ProxyToResponder::Run(
const std::vector<std::optional<std::string>>& in_values) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::GetChannelsAttributes", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("values"), in_values,
"<value of type const std::vector<std::optional<std::string>>&>");
});
#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::SensorDevice::kGetChannelsAttributes), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetChannelsAttributes_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->values)::BaseType>
values_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& values_validate_params =
mojo::internal::GetArrayValidator<0, true, &mojo::internal::GetArrayValidator<0, false, nullptr>()>();
mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>(
in_values, values_fragment, &values_validate_params);
params->values.Set(
values_fragment.is_null() ? nullptr : values_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->values.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null values in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetChannelsAttributes");
#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 SensorDevice_GetAllEvents_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::GetAllEventsCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_GetAllEvents_ProxyToResponder> proxy(
new SensorDevice_GetAllEvents_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_GetAllEvents_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_GetAllEvents_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:
SensorDevice_GetAllEvents_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)
<< "SensorDevice::GetAllEventsCallback 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(
std::vector<IioEventPtr> in_iio_events);
};
bool SensorDevice_GetAllEvents_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_GetAllEvents_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_GetAllEvents_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.9
bool success = true;
std::vector<IioEventPtr> p_iio_events{};
SensorDevice_GetAllEvents_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioEvents(&p_iio_events))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 9, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_iio_events));
return true;
}
void SensorDevice_GetAllEvents_ProxyToResponder::Run(
std::vector<IioEventPtr> in_iio_events) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::GetAllEvents", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_events"), in_iio_events,
"<value of type std::vector<IioEventPtr>>");
});
#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::SensorDevice::kGetAllEvents), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetAllEvents_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_events)::BaseType>
iio_events_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& iio_events_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<::cros::mojom::IioEventDataView>>(
in_iio_events, iio_events_fragment, &iio_events_validate_params);
params->iio_events.Set(
iio_events_fragment.is_null() ? nullptr : iio_events_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_events.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_events in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetAllEvents");
#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 SensorDevice_GetEventsAttributes_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static SensorDevice::GetEventsAttributesCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<SensorDevice_GetEventsAttributes_ProxyToResponder> proxy(
new SensorDevice_GetEventsAttributes_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&SensorDevice_GetEventsAttributes_ProxyToResponder::Run,
std::move(proxy));
}
~SensorDevice_GetEventsAttributes_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:
SensorDevice_GetEventsAttributes_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)
<< "SensorDevice::GetEventsAttributesCallback 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(
const std::vector<std::optional<std::string>>& in_values);
};
bool SensorDevice_GetEventsAttributes_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::SensorDevice_GetEventsAttributes_ResponseParams_Data* params =
reinterpret_cast<
internal::SensorDevice_GetEventsAttributes_ResponseParams_Data*>(
message->mutable_payload());
// Validation for SensorDevice.12
bool success = true;
std::vector<std::optional<std::string>> p_values{};
SensorDevice_GetEventsAttributes_ResponseParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadValues(&p_values))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 12, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_values));
return true;
}
void SensorDevice_GetEventsAttributes_ProxyToResponder::Run(
const std::vector<std::optional<std::string>>& in_values) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply cros::mojom::SensorDevice::GetEventsAttributes", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("values"), in_values,
"<value of type const std::vector<std::optional<std::string>>&>");
});
#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::SensorDevice::kGetEventsAttributes), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDevice_GetEventsAttributes_ResponseParams_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->values)::BaseType>
values_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& values_validate_params =
mojo::internal::GetArrayValidator<0, true, &mojo::internal::GetArrayValidator<0, false, nullptr>()>();
mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>(
in_values, values_fragment, &values_validate_params);
params->values.Set(
values_fragment.is_null() ? nullptr : values_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->values.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null values in ");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDevice::Name_);
message.set_method_name("GetEventsAttributes");
#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 SensorDeviceStubDispatch::Accept(
SensorDevice* impl,
mojo::Message* message) {
switch (static_cast<messages::SensorDevice>(message->header()->name)) {
case messages::SensorDevice::kSetTimeout: {
DCHECK(message->is_serialized());
internal::SensorDevice_SetTimeout_Params_Data* params =
reinterpret_cast<internal::SensorDevice_SetTimeout_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.0
bool success = true;
uint32_t p_timeout{};
SensorDevice_SetTimeout_ParamsDataView input_data_view(params, message);
if (success)
p_timeout = input_data_view.timeout();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->SetTimeout(
std::move(p_timeout));
return true;
}
case messages::SensorDevice::kGetAttributes: {
break;
}
case messages::SensorDevice::kSetFrequency: {
break;
}
case messages::SensorDevice::kStartReadingSamples: {
DCHECK(message->is_serialized());
internal::SensorDevice_StartReadingSamples_Params_Data* params =
reinterpret_cast<internal::SensorDevice_StartReadingSamples_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.3
bool success = true;
::mojo::PendingRemote<SensorDeviceSamplesObserver> p_observer{};
SensorDevice_StartReadingSamples_ParamsDataView input_data_view(params, message);
if (success) {
p_observer =
input_data_view.TakeObserver<decltype(p_observer)>();
}
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 3, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->StartReadingSamples(
std::move(p_observer));
return true;
}
case messages::SensorDevice::kStopReadingSamples: {
DCHECK(message->is_serialized());
internal::SensorDevice_StopReadingSamples_Params_Data* params =
reinterpret_cast<internal::SensorDevice_StopReadingSamples_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.4
bool success = true;
SensorDevice_StopReadingSamples_ParamsDataView input_data_view(params, message);
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 4, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->StopReadingSamples( );
return true;
}
case messages::SensorDevice::kGetAllChannelIds: {
break;
}
case messages::SensorDevice::kSetChannelsEnabled: {
break;
}
case messages::SensorDevice::kGetChannelsEnabled: {
break;
}
case messages::SensorDevice::kGetChannelsAttributes: {
break;
}
case messages::SensorDevice::kGetAllEvents: {
break;
}
case messages::SensorDevice::kGetEventsAttributes: {
break;
}
case messages::SensorDevice::kStartReadingEvents: {
DCHECK(message->is_serialized());
internal::SensorDevice_StartReadingEvents_Params_Data* params =
reinterpret_cast<internal::SensorDevice_StartReadingEvents_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.15
bool success = true;
std::vector<int32_t> p_iio_event_indices{};
::mojo::PendingRemote<SensorDeviceEventsObserver> p_observer{};
SensorDevice_StartReadingEvents_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioEventIndices(&p_iio_event_indices))
success = false;
if (success) {
p_observer =
input_data_view.TakeObserver<decltype(p_observer)>();
}
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 15, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->StartReadingEvents(
std::move(p_iio_event_indices),
std::move(p_observer));
return true;
}
}
return false;
}
// static
bool SensorDeviceStubDispatch::AcceptWithResponder(
SensorDevice* 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::SensorDevice>(message->header()->name)) {
case messages::SensorDevice::kSetTimeout: {
break;
}
case messages::SensorDevice::kGetAttributes: {
internal::SensorDevice_GetAttributes_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_GetAttributes_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.1
bool success = true;
std::vector<std::string> p_attr_names{};
SensorDevice_GetAttributes_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadAttrNames(&p_attr_names))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 1, false);
return false;
}
SensorDevice::GetAttributesCallback callback =
SensorDevice_GetAttributes_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetAttributes(
std::move(p_attr_names), std::move(callback));
return true;
}
case messages::SensorDevice::kSetFrequency: {
internal::SensorDevice_SetFrequency_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_SetFrequency_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.2
bool success = true;
double p_frequency{};
SensorDevice_SetFrequency_ParamsDataView input_data_view(params, message);
if (success)
p_frequency = input_data_view.frequency();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 2, false);
return false;
}
SensorDevice::SetFrequencyCallback callback =
SensorDevice_SetFrequency_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->SetFrequency(
std::move(p_frequency), std::move(callback));
return true;
}
case messages::SensorDevice::kStartReadingSamples: {
break;
}
case messages::SensorDevice::kStopReadingSamples: {
break;
}
case messages::SensorDevice::kGetAllChannelIds: {
internal::SensorDevice_GetAllChannelIds_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_GetAllChannelIds_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.5
bool success = true;
SensorDevice_GetAllChannelIds_ParamsDataView input_data_view(params, message);
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 5, false);
return false;
}
SensorDevice::GetAllChannelIdsCallback callback =
SensorDevice_GetAllChannelIds_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetAllChannelIds(std::move(callback));
return true;
}
case messages::SensorDevice::kSetChannelsEnabled: {
internal::SensorDevice_SetChannelsEnabled_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_SetChannelsEnabled_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.6
bool success = true;
std::vector<int32_t> p_iio_chn_indices{};
bool p_en{};
SensorDevice_SetChannelsEnabled_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioChnIndices(&p_iio_chn_indices))
success = false;
if (success)
p_en = input_data_view.en();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 6, false);
return false;
}
SensorDevice::SetChannelsEnabledCallback callback =
SensorDevice_SetChannelsEnabled_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->SetChannelsEnabled(
std::move(p_iio_chn_indices),
std::move(p_en), std::move(callback));
return true;
}
case messages::SensorDevice::kGetChannelsEnabled: {
internal::SensorDevice_GetChannelsEnabled_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_GetChannelsEnabled_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.7
bool success = true;
std::vector<int32_t> p_iio_chn_indices{};
SensorDevice_GetChannelsEnabled_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioChnIndices(&p_iio_chn_indices))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 7, false);
return false;
}
SensorDevice::GetChannelsEnabledCallback callback =
SensorDevice_GetChannelsEnabled_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetChannelsEnabled(
std::move(p_iio_chn_indices), std::move(callback));
return true;
}
case messages::SensorDevice::kGetChannelsAttributes: {
internal::SensorDevice_GetChannelsAttributes_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_GetChannelsAttributes_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.8
bool success = true;
std::vector<int32_t> p_iio_chn_indices{};
std::string p_attr_name{};
SensorDevice_GetChannelsAttributes_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioChnIndices(&p_iio_chn_indices))
success = false;
if (success && !input_data_view.ReadAttrName(&p_attr_name))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 8, false);
return false;
}
SensorDevice::GetChannelsAttributesCallback callback =
SensorDevice_GetChannelsAttributes_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetChannelsAttributes(
std::move(p_iio_chn_indices),
std::move(p_attr_name), std::move(callback));
return true;
}
case messages::SensorDevice::kGetAllEvents: {
internal::SensorDevice_GetAllEvents_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_GetAllEvents_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.9
bool success = true;
SensorDevice_GetAllEvents_ParamsDataView input_data_view(params, message);
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 9, false);
return false;
}
SensorDevice::GetAllEventsCallback callback =
SensorDevice_GetAllEvents_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetAllEvents(std::move(callback));
return true;
}
case messages::SensorDevice::kGetEventsAttributes: {
internal::SensorDevice_GetEventsAttributes_Params_Data* params =
reinterpret_cast<
internal::SensorDevice_GetEventsAttributes_Params_Data*>(
message->mutable_payload());
// Validation for SensorDevice.12
bool success = true;
std::vector<int32_t> p_iio_event_indices{};
std::string p_attr_name{};
SensorDevice_GetEventsAttributes_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioEventIndices(&p_iio_event_indices))
success = false;
if (success && !input_data_view.ReadAttrName(&p_attr_name))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDevice::Name_, 12, false);
return false;
}
SensorDevice::GetEventsAttributesCallback callback =
SensorDevice_GetEventsAttributes_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->GetEventsAttributes(
std::move(p_iio_event_indices),
std::move(p_attr_name), std::move(callback));
return true;
}
case messages::SensorDevice::kStartReadingEvents: {
break;
}
}
return false;
}
namespace {
} // namespace
static const mojo::internal::GenericValidationInfo kSensorDeviceValidationInfo[] = {
{ &internal::SensorDevice_SetTimeout_Params_Data::Validate,
nullptr /* no response */},
{ &internal::SensorDevice_GetAttributes_Params_Data::Validate,
&internal::SensorDevice_GetAttributes_ResponseParams_Data::Validate},
{ &internal::SensorDevice_SetFrequency_Params_Data::Validate,
&internal::SensorDevice_SetFrequency_ResponseParams_Data::Validate},
{ &internal::SensorDevice_StartReadingSamples_Params_Data::Validate,
nullptr /* no response */},
{ &internal::SensorDevice_StopReadingSamples_Params_Data::Validate,
nullptr /* no response */},
{ &internal::SensorDevice_GetAllChannelIds_Params_Data::Validate,
&internal::SensorDevice_GetAllChannelIds_ResponseParams_Data::Validate},
{ &internal::SensorDevice_SetChannelsEnabled_Params_Data::Validate,
&internal::SensorDevice_SetChannelsEnabled_ResponseParams_Data::Validate},
{ &internal::SensorDevice_GetChannelsEnabled_Params_Data::Validate,
&internal::SensorDevice_GetChannelsEnabled_ResponseParams_Data::Validate},
{ &internal::SensorDevice_GetChannelsAttributes_Params_Data::Validate,
&internal::SensorDevice_GetChannelsAttributes_ResponseParams_Data::Validate},
{ &internal::SensorDevice_GetAllEvents_Params_Data::Validate,
&internal::SensorDevice_GetAllEvents_ResponseParams_Data::Validate},
{nullptr, nullptr}, // nonexistent
{nullptr, nullptr}, // nonexistent
{ &internal::SensorDevice_GetEventsAttributes_Params_Data::Validate,
&internal::SensorDevice_GetEventsAttributes_ResponseParams_Data::Validate},
{nullptr, nullptr}, // nonexistent
{nullptr, nullptr}, // nonexistent
{ &internal::SensorDevice_StartReadingEvents_Params_Data::Validate,
nullptr /* no response */},
};
bool SensorDeviceRequestValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::SensorDevice::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kSensorDeviceValidationInfo);
}
bool SensorDeviceResponseValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::SensorDevice::Name_;
return mojo::internal::ValidateResponseGenericPacked(message, name, kSensorDeviceValidationInfo);
}
const char SensorDeviceSamplesObserver::Name_[] = "cros.mojom.SensorDeviceSamplesObserver";
SensorDeviceSamplesObserver::IPCStableHashFunction SensorDeviceSamplesObserver::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
switch (static_cast<messages::SensorDeviceSamplesObserver>(message.name())) {
case messages::SensorDeviceSamplesObserver::kOnSampleUpdated: {
return &SensorDeviceSamplesObserver::OnSampleUpdated_Sym::IPCStableHash;
}
case messages::SensorDeviceSamplesObserver::kOnErrorOccurred: {
return &SensorDeviceSamplesObserver::OnErrorOccurred_Sym::IPCStableHash;
}
}
#endif // !BUILDFLAG(IS_FUCHSIA)
return nullptr;
}
const char* SensorDeviceSamplesObserver::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::SensorDeviceSamplesObserver>(message.name())) {
case messages::SensorDeviceSamplesObserver::kOnSampleUpdated:
return "Receive cros::mojom::SensorDeviceSamplesObserver::OnSampleUpdated";
case messages::SensorDeviceSamplesObserver::kOnErrorOccurred:
return "Receive cros::mojom::SensorDeviceSamplesObserver::OnErrorOccurred";
}
} else {
switch (static_cast<messages::SensorDeviceSamplesObserver>(message.name())) {
case messages::SensorDeviceSamplesObserver::kOnSampleUpdated:
return "Receive reply cros::mojom::SensorDeviceSamplesObserver::OnSampleUpdated";
case messages::SensorDeviceSamplesObserver::kOnErrorOccurred:
return "Receive reply cros::mojom::SensorDeviceSamplesObserver::OnErrorOccurred";
}
}
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 SensorDeviceSamplesObserver::OnSampleUpdated_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::SensorDeviceSamplesObserver::OnSampleUpdated");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDeviceSamplesObserver::OnErrorOccurred_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::SensorDeviceSamplesObserver::OnErrorOccurred");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
SensorDeviceSamplesObserverProxy::SensorDeviceSamplesObserverProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void SensorDeviceSamplesObserverProxy::OnSampleUpdated(
const base::flat_map<int32_t, int64_t>& in_sample) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDeviceSamplesObserver::OnSampleUpdated", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("sample"), in_sample,
"<value of type const base::flat_map<int32_t, int64_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::SensorDeviceSamplesObserver::kOnSampleUpdated), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDeviceSamplesObserver_OnSampleUpdated_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->sample)::BaseType>
sample_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& sample_validate_params =
mojo::internal::GetMapValidator<*&mojo::internal::GetArrayValidator<0, false, nullptr>(), *&mojo::internal::GetArrayValidator<0, false, nullptr>()>();
mojo::internal::Serialize<mojo::MapDataView<int32_t, int64_t>>(
in_sample, sample_fragment, &sample_validate_params);
params->sample.Set(
sample_fragment.is_null() ? nullptr : sample_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->sample.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null sample in SensorDeviceSamplesObserver.OnSampleUpdated request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDeviceSamplesObserver::Name_);
message.set_method_name("OnSampleUpdated");
#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 SensorDeviceSamplesObserverProxy::OnErrorOccurred(
ObserverErrorType in_type) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDeviceSamplesObserver::OnErrorOccurred", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("type"), in_type,
"<value of type ObserverErrorType>");
});
#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::SensorDeviceSamplesObserver::kOnErrorOccurred), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDeviceSamplesObserver_OnErrorOccurred_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<::cros::mojom::ObserverErrorType>(
in_type, &params->type);
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDeviceSamplesObserver::Name_);
message.set_method_name("OnErrorOccurred");
#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 SensorDeviceSamplesObserverStubDispatch::Accept(
SensorDeviceSamplesObserver* impl,
mojo::Message* message) {
switch (static_cast<messages::SensorDeviceSamplesObserver>(message->header()->name)) {
case messages::SensorDeviceSamplesObserver::kOnSampleUpdated: {
DCHECK(message->is_serialized());
internal::SensorDeviceSamplesObserver_OnSampleUpdated_Params_Data* params =
reinterpret_cast<internal::SensorDeviceSamplesObserver_OnSampleUpdated_Params_Data*>(
message->mutable_payload());
// Validation for SensorDeviceSamplesObserver.0
bool success = true;
base::flat_map<int32_t, int64_t> p_sample{};
SensorDeviceSamplesObserver_OnSampleUpdated_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadSample(&p_sample))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDeviceSamplesObserver::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->OnSampleUpdated(
std::move(p_sample));
return true;
}
case messages::SensorDeviceSamplesObserver::kOnErrorOccurred: {
DCHECK(message->is_serialized());
internal::SensorDeviceSamplesObserver_OnErrorOccurred_Params_Data* params =
reinterpret_cast<internal::SensorDeviceSamplesObserver_OnErrorOccurred_Params_Data*>(
message->mutable_payload());
// Validation for SensorDeviceSamplesObserver.1
bool success = true;
ObserverErrorType p_type{};
SensorDeviceSamplesObserver_OnErrorOccurred_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadType(&p_type))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDeviceSamplesObserver::Name_, 1, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->OnErrorOccurred(
std::move(p_type));
return true;
}
}
return false;
}
// static
bool SensorDeviceSamplesObserverStubDispatch::AcceptWithResponder(
SensorDeviceSamplesObserver* 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::SensorDeviceSamplesObserver>(message->header()->name)) {
case messages::SensorDeviceSamplesObserver::kOnSampleUpdated: {
break;
}
case messages::SensorDeviceSamplesObserver::kOnErrorOccurred: {
break;
}
}
return false;
}
namespace {
} // namespace
static const mojo::internal::GenericValidationInfo kSensorDeviceSamplesObserverValidationInfo[] = {
{ &internal::SensorDeviceSamplesObserver_OnSampleUpdated_Params_Data::Validate,
nullptr /* no response */},
{ &internal::SensorDeviceSamplesObserver_OnErrorOccurred_Params_Data::Validate,
nullptr /* no response */},
};
bool SensorDeviceSamplesObserverRequestValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::SensorDeviceSamplesObserver::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kSensorDeviceSamplesObserverValidationInfo);
}
const char SensorServiceNewDevicesObserver::Name_[] = "cros.mojom.SensorServiceNewDevicesObserver";
SensorServiceNewDevicesObserver::IPCStableHashFunction SensorServiceNewDevicesObserver::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
switch (static_cast<messages::SensorServiceNewDevicesObserver>(message.name())) {
case messages::SensorServiceNewDevicesObserver::kOnNewDeviceAdded: {
return &SensorServiceNewDevicesObserver::OnNewDeviceAdded_Sym::IPCStableHash;
}
case messages::SensorServiceNewDevicesObserver::kOnDeviceRemoved: {
return &SensorServiceNewDevicesObserver::OnDeviceRemoved_Sym::IPCStableHash;
}
}
#endif // !BUILDFLAG(IS_FUCHSIA)
return nullptr;
}
const char* SensorServiceNewDevicesObserver::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::SensorServiceNewDevicesObserver>(message.name())) {
case messages::SensorServiceNewDevicesObserver::kOnNewDeviceAdded:
return "Receive cros::mojom::SensorServiceNewDevicesObserver::OnNewDeviceAdded";
case messages::SensorServiceNewDevicesObserver::kOnDeviceRemoved:
return "Receive cros::mojom::SensorServiceNewDevicesObserver::OnDeviceRemoved";
}
} else {
switch (static_cast<messages::SensorServiceNewDevicesObserver>(message.name())) {
case messages::SensorServiceNewDevicesObserver::kOnNewDeviceAdded:
return "Receive reply cros::mojom::SensorServiceNewDevicesObserver::OnNewDeviceAdded";
case messages::SensorServiceNewDevicesObserver::kOnDeviceRemoved:
return "Receive reply cros::mojom::SensorServiceNewDevicesObserver::OnDeviceRemoved";
}
}
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 SensorServiceNewDevicesObserver::OnNewDeviceAdded_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::SensorServiceNewDevicesObserver::OnNewDeviceAdded");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorServiceNewDevicesObserver::OnDeviceRemoved_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::SensorServiceNewDevicesObserver::OnDeviceRemoved");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
SensorServiceNewDevicesObserverProxy::SensorServiceNewDevicesObserverProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void SensorServiceNewDevicesObserverProxy::OnNewDeviceAdded(
int32_t in_iio_device_id, const std::vector<DeviceType>& in_types) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorServiceNewDevicesObserver::OnNewDeviceAdded", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_device_id"), in_iio_device_id,
"<value of type int32_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("types"), in_types,
"<value of type const std::vector<DeviceType>&>");
});
#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::SensorServiceNewDevicesObserver::kOnNewDeviceAdded), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorServiceNewDevicesObserver_OnNewDeviceAdded_Params_Data> params(
message);
params.Allocate();
params->iio_device_id = in_iio_device_id;
mojo::internal::MessageFragment<
typename decltype(params->types)::BaseType>
types_fragment(params.message());
constexpr const mojo::internal::ContainerValidateParams& types_validate_params =
mojo::internal::GetArrayOfEnumsValidator<0, false, ::cros::mojom::internal::DeviceType_Data::Validate>();
mojo::internal::Serialize<mojo::ArrayDataView<::cros::mojom::DeviceType>>(
in_types, types_fragment, &types_validate_params);
params->types.Set(
types_fragment.is_null() ? nullptr : types_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->types.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null types in SensorServiceNewDevicesObserver.OnNewDeviceAdded request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorServiceNewDevicesObserver::Name_);
message.set_method_name("OnNewDeviceAdded");
#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 SensorServiceNewDevicesObserverProxy::OnDeviceRemoved(
int32_t in_iio_device_id) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorServiceNewDevicesObserver::OnDeviceRemoved", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_device_id"), in_iio_device_id,
"<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::SensorServiceNewDevicesObserver::kOnDeviceRemoved), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorServiceNewDevicesObserver_OnDeviceRemoved_Params_Data> params(
message);
params.Allocate();
params->iio_device_id = in_iio_device_id;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorServiceNewDevicesObserver::Name_);
message.set_method_name("OnDeviceRemoved");
#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 SensorServiceNewDevicesObserverStubDispatch::Accept(
SensorServiceNewDevicesObserver* impl,
mojo::Message* message) {
switch (static_cast<messages::SensorServiceNewDevicesObserver>(message->header()->name)) {
case messages::SensorServiceNewDevicesObserver::kOnNewDeviceAdded: {
DCHECK(message->is_serialized());
internal::SensorServiceNewDevicesObserver_OnNewDeviceAdded_Params_Data* params =
reinterpret_cast<internal::SensorServiceNewDevicesObserver_OnNewDeviceAdded_Params_Data*>(
message->mutable_payload());
// Validation for SensorServiceNewDevicesObserver.0
bool success = true;
int32_t p_iio_device_id{};
std::vector<DeviceType> p_types{};
SensorServiceNewDevicesObserver_OnNewDeviceAdded_ParamsDataView input_data_view(params, message);
if (success)
p_iio_device_id = input_data_view.iio_device_id();
if (success && !input_data_view.ReadTypes(&p_types))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorServiceNewDevicesObserver::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->OnNewDeviceAdded(
std::move(p_iio_device_id),
std::move(p_types));
return true;
}
case messages::SensorServiceNewDevicesObserver::kOnDeviceRemoved: {
DCHECK(message->is_serialized());
internal::SensorServiceNewDevicesObserver_OnDeviceRemoved_Params_Data* params =
reinterpret_cast<internal::SensorServiceNewDevicesObserver_OnDeviceRemoved_Params_Data*>(
message->mutable_payload());
// Validation for SensorServiceNewDevicesObserver.1
bool success = true;
int32_t p_iio_device_id{};
SensorServiceNewDevicesObserver_OnDeviceRemoved_ParamsDataView input_data_view(params, message);
if (success)
p_iio_device_id = input_data_view.iio_device_id();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorServiceNewDevicesObserver::Name_, 1, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->OnDeviceRemoved(
std::move(p_iio_device_id));
return true;
}
}
return false;
}
// static
bool SensorServiceNewDevicesObserverStubDispatch::AcceptWithResponder(
SensorServiceNewDevicesObserver* 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::SensorServiceNewDevicesObserver>(message->header()->name)) {
case messages::SensorServiceNewDevicesObserver::kOnNewDeviceAdded: {
break;
}
case messages::SensorServiceNewDevicesObserver::kOnDeviceRemoved: {
break;
}
}
return false;
}
namespace {
} // namespace
static const mojo::internal::GenericValidationInfo kSensorServiceNewDevicesObserverValidationInfo[] = {
{ &internal::SensorServiceNewDevicesObserver_OnNewDeviceAdded_Params_Data::Validate,
nullptr /* no response */},
{ &internal::SensorServiceNewDevicesObserver_OnDeviceRemoved_Params_Data::Validate,
nullptr /* no response */},
};
bool SensorServiceNewDevicesObserverRequestValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::SensorServiceNewDevicesObserver::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kSensorServiceNewDevicesObserverValidationInfo);
}
const char SensorDeviceEventsObserver::Name_[] = "cros.mojom.SensorDeviceEventsObserver";
SensorDeviceEventsObserver::IPCStableHashFunction SensorDeviceEventsObserver::MessageToMethodInfo_(mojo::Message& message) {
#if !BUILDFLAG(IS_FUCHSIA)
switch (static_cast<messages::SensorDeviceEventsObserver>(message.name())) {
case messages::SensorDeviceEventsObserver::kOnEventUpdated: {
return &SensorDeviceEventsObserver::OnEventUpdated_Sym::IPCStableHash;
}
case messages::SensorDeviceEventsObserver::kOnErrorOccurred: {
return &SensorDeviceEventsObserver::OnErrorOccurred_Sym::IPCStableHash;
}
}
#endif // !BUILDFLAG(IS_FUCHSIA)
return nullptr;
}
const char* SensorDeviceEventsObserver::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::SensorDeviceEventsObserver>(message.name())) {
case messages::SensorDeviceEventsObserver::kOnEventUpdated:
return "Receive cros::mojom::SensorDeviceEventsObserver::OnEventUpdated";
case messages::SensorDeviceEventsObserver::kOnErrorOccurred:
return "Receive cros::mojom::SensorDeviceEventsObserver::OnErrorOccurred";
}
} else {
switch (static_cast<messages::SensorDeviceEventsObserver>(message.name())) {
case messages::SensorDeviceEventsObserver::kOnEventUpdated:
return "Receive reply cros::mojom::SensorDeviceEventsObserver::OnEventUpdated";
case messages::SensorDeviceEventsObserver::kOnErrorOccurred:
return "Receive reply cros::mojom::SensorDeviceEventsObserver::OnErrorOccurred";
}
}
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 SensorDeviceEventsObserver::OnEventUpdated_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::SensorDeviceEventsObserver::OnEventUpdated");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
uint32_t SensorDeviceEventsObserver::OnErrorOccurred_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::SensorDeviceEventsObserver::OnErrorOccurred");
const uint32_t hash = kHash;
base::debug::Alias(&hash);
return hash;
}
# endif // !BUILDFLAG(IS_FUCHSIA)
SensorDeviceEventsObserverProxy::SensorDeviceEventsObserverProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void SensorDeviceEventsObserverProxy::OnEventUpdated(
IioEventPtr in_iio_event) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDeviceEventsObserver::OnEventUpdated", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("iio_event"), in_iio_event,
"<value of type IioEventPtr>");
});
#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::SensorDeviceEventsObserver::kOnEventUpdated), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDeviceEventsObserver_OnEventUpdated_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->iio_event)::BaseType> iio_event_fragment(
params.message());
mojo::internal::Serialize<::cros::mojom::IioEventDataView>(
in_iio_event, iio_event_fragment);
params->iio_event.Set(
iio_event_fragment.is_null() ? nullptr : iio_event_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->iio_event.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null iio_event in SensorDeviceEventsObserver.OnEventUpdated request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDeviceEventsObserver::Name_);
message.set_method_name("OnEventUpdated");
#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 SensorDeviceEventsObserverProxy::OnErrorOccurred(
ObserverErrorType in_type) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send cros::mojom::SensorDeviceEventsObserver::OnErrorOccurred", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("type"), in_type,
"<value of type ObserverErrorType>");
});
#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::SensorDeviceEventsObserver::kOnErrorOccurred), kFlags, estimated_payload_size);
mojo::internal::MessageFragment<
::cros::mojom::internal::SensorDeviceEventsObserver_OnErrorOccurred_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<::cros::mojom::ObserverErrorType>(
in_type, &params->type);
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(SensorDeviceEventsObserver::Name_);
message.set_method_name("OnErrorOccurred");
#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 SensorDeviceEventsObserverStubDispatch::Accept(
SensorDeviceEventsObserver* impl,
mojo::Message* message) {
switch (static_cast<messages::SensorDeviceEventsObserver>(message->header()->name)) {
case messages::SensorDeviceEventsObserver::kOnEventUpdated: {
DCHECK(message->is_serialized());
internal::SensorDeviceEventsObserver_OnEventUpdated_Params_Data* params =
reinterpret_cast<internal::SensorDeviceEventsObserver_OnEventUpdated_Params_Data*>(
message->mutable_payload());
// Validation for SensorDeviceEventsObserver.0
bool success = true;
IioEventPtr p_iio_event{};
SensorDeviceEventsObserver_OnEventUpdated_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadIioEvent(&p_iio_event))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDeviceEventsObserver::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->OnEventUpdated(
std::move(p_iio_event));
return true;
}
case messages::SensorDeviceEventsObserver::kOnErrorOccurred: {
DCHECK(message->is_serialized());
internal::SensorDeviceEventsObserver_OnErrorOccurred_Params_Data* params =
reinterpret_cast<internal::SensorDeviceEventsObserver_OnErrorOccurred_Params_Data*>(
message->mutable_payload());
// Validation for SensorDeviceEventsObserver.1
bool success = true;
ObserverErrorType p_type{};
SensorDeviceEventsObserver_OnErrorOccurred_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadType(&p_type))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
SensorDeviceEventsObserver::Name_, 1, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->OnErrorOccurred(
std::move(p_type));
return true;
}
}
return false;
}
// static
bool SensorDeviceEventsObserverStubDispatch::AcceptWithResponder(
SensorDeviceEventsObserver* 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::SensorDeviceEventsObserver>(message->header()->name)) {
case messages::SensorDeviceEventsObserver::kOnEventUpdated: {
break;
}
case messages::SensorDeviceEventsObserver::kOnErrorOccurred: {
break;
}
}
return false;
}
namespace {
} // namespace
static const mojo::internal::GenericValidationInfo kSensorDeviceEventsObserverValidationInfo[] = {
{ &internal::SensorDeviceEventsObserver_OnEventUpdated_Params_Data::Validate,
nullptr /* no response */},
{ &internal::SensorDeviceEventsObserver_OnErrorOccurred_Params_Data::Validate,
nullptr /* no response */},
};
bool SensorDeviceEventsObserverRequestValidator::Accept(mojo::Message* message) {
const char* name = ::cros::mojom::SensorDeviceEventsObserver::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kSensorDeviceEventsObserverValidationInfo);
}
} // cros::mojom
namespace mojo {
// static
bool StructTraits<::cros::mojom::IioEvent::DataView, ::cros::mojom::IioEventPtr>::Read(
::cros::mojom::IioEvent::DataView input,
::cros::mojom::IioEventPtr* output) {
bool success = true;
::cros::mojom::IioEventPtr result(::cros::mojom::IioEvent::New());
if (success && !input.ReadChanType(&result->chan_type))
success = false;
if (success && !input.ReadEventType(&result->event_type))
success = false;
if (success && !input.ReadDirection(&result->direction))
success = false;
if (success)
result->channel = input.channel();
if (success)
result->timestamp = input.timestamp();
*output = std::move(result);
return success;
}
} // 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 SensorServiceInterceptorForTesting::GetDeviceIds(DeviceType type, GetDeviceIdsCallback callback) {
GetForwardingInterface()->GetDeviceIds(std::move(type), std::move(callback));
}
void SensorServiceInterceptorForTesting::GetAllDeviceIds(GetAllDeviceIdsCallback callback) {
GetForwardingInterface()->GetAllDeviceIds(std::move(callback));
}
void SensorServiceInterceptorForTesting::GetDevice(int32_t iio_device_id, ::mojo::PendingReceiver<SensorDevice> device_request) {
GetForwardingInterface()->GetDevice(std::move(iio_device_id), std::move(device_request));
}
void SensorServiceInterceptorForTesting::RegisterNewDevicesObserver(::mojo::PendingRemote<SensorServiceNewDevicesObserver> observer) {
GetForwardingInterface()->RegisterNewDevicesObserver(std::move(observer));
}
SensorServiceAsyncWaiter::SensorServiceAsyncWaiter(
SensorService* proxy) : proxy_(proxy) {}
SensorServiceAsyncWaiter::~SensorServiceAsyncWaiter() = default;
void SensorServiceAsyncWaiter::GetDeviceIds(
DeviceType type, std::vector<int32_t>* out_iio_device_ids) {
base::RunLoop loop;
proxy_->GetDeviceIds(std::move(type),
base::BindOnce(
[](base::RunLoop* loop,
std::vector<int32_t>* out_iio_device_ids
,
const std::vector<int32_t>& iio_device_ids) {*out_iio_device_ids = std::move(iio_device_ids);
loop->Quit();
},
&loop,
out_iio_device_ids));
loop.Run();
}
std::vector<int32_t> SensorServiceAsyncWaiter::GetDeviceIds(
DeviceType type) {
std::vector<int32_t> async_wait_result;
GetDeviceIds(std::move(type),&async_wait_result);
return async_wait_result;
}
void SensorServiceAsyncWaiter::GetAllDeviceIds(
base::flat_map<int32_t, std::vector<DeviceType>>* out_iio_device_ids_types) {
base::RunLoop loop;
proxy_->GetAllDeviceIds(
base::BindOnce(
[](base::RunLoop* loop,
base::flat_map<int32_t, std::vector<DeviceType>>* out_iio_device_ids_types
,
const base::flat_map<int32_t, std::vector<DeviceType>>& iio_device_ids_types) {*out_iio_device_ids_types = std::move(iio_device_ids_types);
loop->Quit();
},
&loop,
out_iio_device_ids_types));
loop.Run();
}
base::flat_map<int32_t, std::vector<DeviceType>> SensorServiceAsyncWaiter::GetAllDeviceIds(
) {
base::flat_map<int32_t, std::vector<DeviceType>> async_wait_result;
GetAllDeviceIds(&async_wait_result);
return async_wait_result;
}
void SensorDeviceInterceptorForTesting::SetTimeout(uint32_t timeout) {
GetForwardingInterface()->SetTimeout(std::move(timeout));
}
void SensorDeviceInterceptorForTesting::GetAttributes(const std::vector<std::string>& attr_names, GetAttributesCallback callback) {
GetForwardingInterface()->GetAttributes(std::move(attr_names), std::move(callback));
}
void SensorDeviceInterceptorForTesting::SetFrequency(double frequency, SetFrequencyCallback callback) {
GetForwardingInterface()->SetFrequency(std::move(frequency), std::move(callback));
}
void SensorDeviceInterceptorForTesting::StartReadingSamples(::mojo::PendingRemote<SensorDeviceSamplesObserver> observer) {
GetForwardingInterface()->StartReadingSamples(std::move(observer));
}
void SensorDeviceInterceptorForTesting::StopReadingSamples() {
GetForwardingInterface()->StopReadingSamples();
}
void SensorDeviceInterceptorForTesting::GetAllChannelIds(GetAllChannelIdsCallback callback) {
GetForwardingInterface()->GetAllChannelIds(std::move(callback));
}
void SensorDeviceInterceptorForTesting::SetChannelsEnabled(const std::vector<int32_t>& iio_chn_indices, bool en, SetChannelsEnabledCallback callback) {
GetForwardingInterface()->SetChannelsEnabled(std::move(iio_chn_indices), std::move(en), std::move(callback));
}
void SensorDeviceInterceptorForTesting::GetChannelsEnabled(const std::vector<int32_t>& iio_chn_indices, GetChannelsEnabledCallback callback) {
GetForwardingInterface()->GetChannelsEnabled(std::move(iio_chn_indices), std::move(callback));
}
void SensorDeviceInterceptorForTesting::GetChannelsAttributes(const std::vector<int32_t>& iio_chn_indices, const std::string& attr_name, GetChannelsAttributesCallback callback) {
GetForwardingInterface()->GetChannelsAttributes(std::move(iio_chn_indices), std::move(attr_name), std::move(callback));
}
void SensorDeviceInterceptorForTesting::GetAllEvents(GetAllEventsCallback callback) {
GetForwardingInterface()->GetAllEvents(std::move(callback));
}
void SensorDeviceInterceptorForTesting::GetEventsAttributes(const std::vector<int32_t>& iio_event_indices, const std::string& attr_name, GetEventsAttributesCallback callback) {
GetForwardingInterface()->GetEventsAttributes(std::move(iio_event_indices), std::move(attr_name), std::move(callback));
}
void SensorDeviceInterceptorForTesting::StartReadingEvents(const std::vector<int32_t>& iio_event_indices, ::mojo::PendingRemote<SensorDeviceEventsObserver> observer) {
GetForwardingInterface()->StartReadingEvents(std::move(iio_event_indices), std::move(observer));
}
SensorDeviceAsyncWaiter::SensorDeviceAsyncWaiter(
SensorDevice* proxy) : proxy_(proxy) {}
SensorDeviceAsyncWaiter::~SensorDeviceAsyncWaiter() = default;
void SensorDeviceAsyncWaiter::GetAttributes(
const std::vector<std::string>& attr_names, std::vector<std::optional<std::string>>* out_values) {
base::RunLoop loop;
proxy_->GetAttributes(std::move(attr_names),
base::BindOnce(
[](base::RunLoop* loop,
std::vector<std::optional<std::string>>* out_values
,
const std::vector<std::optional<std::string>>& values) {*out_values = std::move(values);
loop->Quit();
},
&loop,
out_values));
loop.Run();
}
std::vector<std::optional<std::string>> SensorDeviceAsyncWaiter::GetAttributes(
const std::vector<std::string>& attr_names) {
std::vector<std::optional<std::string>> async_wait_result;
GetAttributes(std::move(attr_names),&async_wait_result);
return async_wait_result;
}
void SensorDeviceAsyncWaiter::SetFrequency(
double frequency, double* out_result_freq) {
base::RunLoop loop;
proxy_->SetFrequency(std::move(frequency),
base::BindOnce(
[](base::RunLoop* loop,
double* out_result_freq
,
double result_freq) {*out_result_freq = std::move(result_freq);
loop->Quit();
},
&loop,
out_result_freq));
loop.Run();
}
double SensorDeviceAsyncWaiter::SetFrequency(
double frequency) {
double async_wait_result;
SetFrequency(std::move(frequency),&async_wait_result);
return async_wait_result;
}
void SensorDeviceAsyncWaiter::GetAllChannelIds(
std::vector<std::string>* out_iio_chn_ids) {
base::RunLoop loop;
proxy_->GetAllChannelIds(
base::BindOnce(
[](base::RunLoop* loop,
std::vector<std::string>* out_iio_chn_ids
,
const std::vector<std::string>& iio_chn_ids) {*out_iio_chn_ids = std::move(iio_chn_ids);
loop->Quit();
},
&loop,
out_iio_chn_ids));
loop.Run();
}
std::vector<std::string> SensorDeviceAsyncWaiter::GetAllChannelIds(
) {
std::vector<std::string> async_wait_result;
GetAllChannelIds(&async_wait_result);
return async_wait_result;
}
void SensorDeviceAsyncWaiter::SetChannelsEnabled(
const std::vector<int32_t>& iio_chn_indices, bool en, std::vector<int32_t>* out_failed_indices) {
base::RunLoop loop;
proxy_->SetChannelsEnabled(std::move(iio_chn_indices),std::move(en),
base::BindOnce(
[](base::RunLoop* loop,
std::vector<int32_t>* out_failed_indices
,
const std::vector<int32_t>& failed_indices) {*out_failed_indices = std::move(failed_indices);
loop->Quit();
},
&loop,
out_failed_indices));
loop.Run();
}
std::vector<int32_t> SensorDeviceAsyncWaiter::SetChannelsEnabled(
const std::vector<int32_t>& iio_chn_indices, bool en) {
std::vector<int32_t> async_wait_result;
SetChannelsEnabled(std::move(iio_chn_indices),std::move(en),&async_wait_result);
return async_wait_result;
}
void SensorDeviceAsyncWaiter::GetChannelsEnabled(
const std::vector<int32_t>& iio_chn_indices, std::vector<bool>* out_enabled) {
base::RunLoop loop;
proxy_->GetChannelsEnabled(std::move(iio_chn_indices),
base::BindOnce(
[](base::RunLoop* loop,
std::vector<bool>* out_enabled
,
const std::vector<bool>& enabled) {*out_enabled = std::move(enabled);
loop->Quit();
},
&loop,
out_enabled));
loop.Run();
}
std::vector<bool> SensorDeviceAsyncWaiter::GetChannelsEnabled(
const std::vector<int32_t>& iio_chn_indices) {
std::vector<bool> async_wait_result;
GetChannelsEnabled(std::move(iio_chn_indices),&async_wait_result);
return async_wait_result;
}
void SensorDeviceAsyncWaiter::GetChannelsAttributes(
const std::vector<int32_t>& iio_chn_indices, const std::string& attr_name, std::vector<std::optional<std::string>>* out_values) {
base::RunLoop loop;
proxy_->GetChannelsAttributes(std::move(iio_chn_indices),std::move(attr_name),
base::BindOnce(
[](base::RunLoop* loop,
std::vector<std::optional<std::string>>* out_values
,
const std::vector<std::optional<std::string>>& values) {*out_values = std::move(values);
loop->Quit();
},
&loop,
out_values));
loop.Run();
}
std::vector<std::optional<std::string>> SensorDeviceAsyncWaiter::GetChannelsAttributes(
const std::vector<int32_t>& iio_chn_indices, const std::string& attr_name) {
std::vector<std::optional<std::string>> async_wait_result;
GetChannelsAttributes(std::move(iio_chn_indices),std::move(attr_name),&async_wait_result);
return async_wait_result;
}
void SensorDeviceAsyncWaiter::GetAllEvents(
std::vector<IioEventPtr>* out_iio_events) {
base::RunLoop loop;
proxy_->GetAllEvents(
base::BindOnce(
[](base::RunLoop* loop,
std::vector<IioEventPtr>* out_iio_events
,
std::vector<IioEventPtr> iio_events) {*out_iio_events = std::move(iio_events);
loop->Quit();
},
&loop,
out_iio_events));
loop.Run();
}
std::vector<IioEventPtr> SensorDeviceAsyncWaiter::GetAllEvents(
) {
std::vector<IioEventPtr> async_wait_result;
GetAllEvents(&async_wait_result);
return async_wait_result;
}
void SensorDeviceAsyncWaiter::GetEventsAttributes(
const std::vector<int32_t>& iio_event_indices, const std::string& attr_name, std::vector<std::optional<std::string>>* out_values) {
base::RunLoop loop;
proxy_->GetEventsAttributes(std::move(iio_event_indices),std::move(attr_name),
base::BindOnce(
[](base::RunLoop* loop,
std::vector<std::optional<std::string>>* out_values
,
const std::vector<std::optional<std::string>>& values) {*out_values = std::move(values);
loop->Quit();
},
&loop,
out_values));
loop.Run();
}
std::vector<std::optional<std::string>> SensorDeviceAsyncWaiter::GetEventsAttributes(
const std::vector<int32_t>& iio_event_indices, const std::string& attr_name) {
std::vector<std::optional<std::string>> async_wait_result;
GetEventsAttributes(std::move(iio_event_indices),std::move(attr_name),&async_wait_result);
return async_wait_result;
}
void SensorDeviceSamplesObserverInterceptorForTesting::OnSampleUpdated(const base::flat_map<int32_t, int64_t>& sample) {
GetForwardingInterface()->OnSampleUpdated(std::move(sample));
}
void SensorDeviceSamplesObserverInterceptorForTesting::OnErrorOccurred(ObserverErrorType type) {
GetForwardingInterface()->OnErrorOccurred(std::move(type));
}
SensorDeviceSamplesObserverAsyncWaiter::SensorDeviceSamplesObserverAsyncWaiter(
SensorDeviceSamplesObserver* proxy) : proxy_(proxy) {}
SensorDeviceSamplesObserverAsyncWaiter::~SensorDeviceSamplesObserverAsyncWaiter() = default;
void SensorServiceNewDevicesObserverInterceptorForTesting::OnNewDeviceAdded(int32_t iio_device_id, const std::vector<DeviceType>& types) {
GetForwardingInterface()->OnNewDeviceAdded(std::move(iio_device_id), std::move(types));
}
void SensorServiceNewDevicesObserverInterceptorForTesting::OnDeviceRemoved(int32_t iio_device_id) {
GetForwardingInterface()->OnDeviceRemoved(std::move(iio_device_id));
}
SensorServiceNewDevicesObserverAsyncWaiter::SensorServiceNewDevicesObserverAsyncWaiter(
SensorServiceNewDevicesObserver* proxy) : proxy_(proxy) {}
SensorServiceNewDevicesObserverAsyncWaiter::~SensorServiceNewDevicesObserverAsyncWaiter() = default;
void SensorDeviceEventsObserverInterceptorForTesting::OnEventUpdated(IioEventPtr iio_event) {
GetForwardingInterface()->OnEventUpdated(std::move(iio_event));
}
void SensorDeviceEventsObserverInterceptorForTesting::OnErrorOccurred(ObserverErrorType type) {
GetForwardingInterface()->OnErrorOccurred(std::move(type));
}
SensorDeviceEventsObserverAsyncWaiter::SensorDeviceEventsObserverAsyncWaiter(
SensorDeviceEventsObserver* proxy) : proxy_(proxy) {}
SensorDeviceEventsObserverAsyncWaiter::~SensorDeviceEventsObserverAsyncWaiter() = default;
} // cros::mojom
#if defined(__clang__)
#pragma clang diagnostic pop
#endif