blob: e52b21447a1adba5869141bd867a2e62e2a0cb07 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_DEVICE_PUBLIC_INTERFACES_SENSOR_PROVIDER_MOJOM_SHARED_INTERNAL_H_
#define SERVICES_DEVICE_PUBLIC_INTERFACES_SENSOR_PROVIDER_MOJOM_SHARED_INTERNAL_H_
#include "mojo/public/cpp/bindings/lib/array_internal.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/map_data_internal.h"
#include "mojo/public/cpp/bindings/lib/buffer.h"
#include "services/device/public/interfaces/sensor.mojom-shared-internal.h"
#include "mojo/public/cpp/bindings/lib/native_enum_data.h"
#include "mojo/public/interfaces/bindings/native_struct.mojom-shared-internal.h"
namespace mojo {
namespace internal {
class ValidationContext;
}
}
namespace device {
namespace mojom {
namespace internal {
class SensorInitParams_Data;
struct SensorCreationResult_Data {
public:
static bool constexpr kIsExtensible = false;
static bool IsKnownValue(int32_t value) {
switch (value) {
case 0:
case 1:
case 2:
return true;
}
return false;
}
static bool Validate(int32_t value,
mojo::internal::ValidationContext* validation_context) {
if (kIsExtensible || IsKnownValue(value))
return true;
ReportValidationError(validation_context,
mojo::internal::VALIDATION_ERROR_UNKNOWN_ENUM_VALUE);
return false;
}
};
#pragma pack(push, 1)
class SensorInitParams_Data {
public:
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(SensorInitParams_Data));
new (data()) SensorInitParams_Data();
}
bool is_null() const { return !serialization_buffer_; }
SensorInitParams_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<SensorInitParams_Data>(index_);
}
SensorInitParams_Data* operator->() { return data(); }
private:
mojo::internal::Buffer* serialization_buffer_ = nullptr;
size_t index_ = 0;
DISALLOW_COPY_AND_ASSIGN(BufferWriter);
};
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
mojo::internal::StructHeader header_;
mojo::internal::Interface_Data sensor;
mojo::internal::Handle_Data client_request;
mojo::internal::Handle_Data memory;
uint64_t buffer_offset;
int32_t mode;
uint8_t pad4_[4];
mojo::internal::Pointer<::device::mojom::internal::SensorConfiguration_Data> default_configuration;
double maximum_frequency;
double minimum_frequency;
private:
SensorInitParams_Data();
~SensorInitParams_Data() = delete;
};
static_assert(sizeof(SensorInitParams_Data) == 64,
"Bad sizeof(SensorInitParams_Data)");
// Used by SensorInitParams::WrapAsMessage to lazily serialize the struct.
template <typename UserType, typename DataView>
struct SensorInitParams_UnserializedMessageContext
: public mojo::internal::UnserializedMessageContext {
public:
static const mojo::internal::UnserializedMessageContext::Tag kMessageTag;
SensorInitParams_UnserializedMessageContext(
uint32_t message_name,
uint32_t message_flags,
UserType input)
: mojo::internal::UnserializedMessageContext(&kMessageTag, message_name, message_flags)
, user_data_(std::move(input)) {}
~SensorInitParams_UnserializedMessageContext() override = default;
UserType TakeData() {
return std::move(user_data_);
}
private:
// mojo::internal::UnserializedMessageContext:
void Serialize(mojo::internal::SerializationContext* context,
mojo::internal::Buffer* buffer) override {
SensorInitParams_Data::BufferWriter writer;
mojo::internal::Serialize<DataView>(user_data_, buffer, &writer, context);
}
UserType user_data_;
};
template <typename UserType, typename DataView>
const mojo::internal::UnserializedMessageContext::Tag
SensorInitParams_UnserializedMessageContext<UserType, DataView>::kMessageTag = {};
class SensorProvider_GetSensor_Params_Data {
public:
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(SensorProvider_GetSensor_Params_Data));
new (data()) SensorProvider_GetSensor_Params_Data();
}
bool is_null() const { return !serialization_buffer_; }
SensorProvider_GetSensor_Params_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<SensorProvider_GetSensor_Params_Data>(index_);
}
SensorProvider_GetSensor_Params_Data* operator->() { return data(); }
private:
mojo::internal::Buffer* serialization_buffer_ = nullptr;
size_t index_ = 0;
DISALLOW_COPY_AND_ASSIGN(BufferWriter);
};
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
mojo::internal::StructHeader header_;
int32_t type;
uint8_t padfinal_[4];
private:
SensorProvider_GetSensor_Params_Data();
~SensorProvider_GetSensor_Params_Data() = delete;
};
static_assert(sizeof(SensorProvider_GetSensor_Params_Data) == 16,
"Bad sizeof(SensorProvider_GetSensor_Params_Data)");
class SensorProvider_GetSensor_ResponseParams_Data {
public:
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(SensorProvider_GetSensor_ResponseParams_Data));
new (data()) SensorProvider_GetSensor_ResponseParams_Data();
}
bool is_null() const { return !serialization_buffer_; }
SensorProvider_GetSensor_ResponseParams_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<SensorProvider_GetSensor_ResponseParams_Data>(index_);
}
SensorProvider_GetSensor_ResponseParams_Data* operator->() { return data(); }
private:
mojo::internal::Buffer* serialization_buffer_ = nullptr;
size_t index_ = 0;
DISALLOW_COPY_AND_ASSIGN(BufferWriter);
};
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
mojo::internal::StructHeader header_;
int32_t result;
uint8_t pad0_[4];
mojo::internal::Pointer<internal::SensorInitParams_Data> init_params;
private:
SensorProvider_GetSensor_ResponseParams_Data();
~SensorProvider_GetSensor_ResponseParams_Data() = delete;
};
static_assert(sizeof(SensorProvider_GetSensor_ResponseParams_Data) == 24,
"Bad sizeof(SensorProvider_GetSensor_ResponseParams_Data)");
#pragma pack(pop)
} // namespace internal
} // namespace mojom
} // namespace device
#endif // SERVICES_DEVICE_PUBLIC_INTERFACES_SENSOR_PROVIDER_MOJOM_SHARED_INTERNAL_H_