blob: 8a46d36dd6e5cba1edd239b1bb42d0b16dd069b9 [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_MOJOM_BLUETOOTH_SYSTEM_MOJOM_SHARED_INTERNAL_H_
#define SERVICES_DEVICE_PUBLIC_MOJOM_BLUETOOTH_SYSTEM_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 "mojo/public/cpp/bindings/lib/native_enum_data.h"
#include "mojo/public/interfaces/bindings/native_struct.mojom-shared-internal.h"
#ifdef KYTHE_IS_RUNNING
#pragma kythe_inline_metadata "Metadata comment"
#endif
namespace mojo {
namespace internal {
class ValidationContext;
}
}
namespace device {
namespace mojom {
namespace internal {
class BluetoothAddress_Data;
class BluetoothDeviceBatteryInfo_Data;
class BluetoothDeviceInfo_Data;
struct BluetoothDeviceInfo_ConnectionState_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;
}
};
struct BluetoothDeviceInfo_DeviceType_Data {
public:
static bool constexpr kIsExtensible = false;
static bool IsKnownValue(int32_t value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
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;
}
};
struct BluetoothSystem_State_Data {
public:
static bool constexpr kIsExtensible = false;
static bool IsKnownValue(int32_t value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
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;
}
};
struct BluetoothSystem_SetPoweredResult_Data {
public:
static bool constexpr kIsExtensible = false;
static bool IsKnownValue(int32_t value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
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;
}
};
struct BluetoothSystem_ScanState_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;
}
};
struct BluetoothSystem_StartScanResult_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;
}
};
struct BluetoothSystem_StopScanResult_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 BluetoothAddress_Data {
public:
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(BluetoothAddress_Data));
new (data()) BluetoothAddress_Data();
}
bool is_null() const { return !serialization_buffer_; }
BluetoothAddress_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<BluetoothAddress_Data>(index_);
}
BluetoothAddress_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::Pointer<mojo::internal::Array_Data<uint8_t>> address;
private:
BluetoothAddress_Data();
~BluetoothAddress_Data() = delete;
};
static_assert(sizeof(BluetoothAddress_Data) == 16,
"Bad sizeof(BluetoothAddress_Data)");
// Used by BluetoothAddress::WrapAsMessage to lazily serialize the struct.
template <typename UserType, typename DataView>
struct BluetoothAddress_UnserializedMessageContext
: public mojo::internal::UnserializedMessageContext {
public:
static const mojo::internal::UnserializedMessageContext::Tag kMessageTag;
BluetoothAddress_UnserializedMessageContext(
uint32_t message_name,
uint32_t message_flags,
UserType input)
: mojo::internal::UnserializedMessageContext(&kMessageTag, message_name, message_flags)
, user_data_(std::move(input)) {}
~BluetoothAddress_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 {
BluetoothAddress_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
BluetoothAddress_UnserializedMessageContext<UserType, DataView>::kMessageTag = {};
class BluetoothDeviceBatteryInfo_Data {
public:
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(BluetoothDeviceBatteryInfo_Data));
new (data()) BluetoothDeviceBatteryInfo_Data();
}
bool is_null() const { return !serialization_buffer_; }
BluetoothDeviceBatteryInfo_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<BluetoothDeviceBatteryInfo_Data>(index_);
}
BluetoothDeviceBatteryInfo_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_;
uint8_t battery_percentage;
uint8_t padfinal_[7];
private:
BluetoothDeviceBatteryInfo_Data();
~BluetoothDeviceBatteryInfo_Data() = delete;
};
static_assert(sizeof(BluetoothDeviceBatteryInfo_Data) == 16,
"Bad sizeof(BluetoothDeviceBatteryInfo_Data)");
// Used by BluetoothDeviceBatteryInfo::WrapAsMessage to lazily serialize the struct.
template <typename UserType, typename DataView>
struct BluetoothDeviceBatteryInfo_UnserializedMessageContext
: public mojo::internal::UnserializedMessageContext {
public:
static const mojo::internal::UnserializedMessageContext::Tag kMessageTag;
BluetoothDeviceBatteryInfo_UnserializedMessageContext(
uint32_t message_name,
uint32_t message_flags,
UserType input)
: mojo::internal::UnserializedMessageContext(&kMessageTag, message_name, message_flags)
, user_data_(std::move(input)) {}
~BluetoothDeviceBatteryInfo_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 {
BluetoothDeviceBatteryInfo_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
BluetoothDeviceBatteryInfo_UnserializedMessageContext<UserType, DataView>::kMessageTag = {};
class BluetoothDeviceInfo_Data {
public:
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(BluetoothDeviceInfo_Data));
new (data()) BluetoothDeviceInfo_Data();
}
bool is_null() const { return !serialization_buffer_; }
BluetoothDeviceInfo_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<BluetoothDeviceInfo_Data>(index_);
}
BluetoothDeviceInfo_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::Pointer<internal::BluetoothAddress_Data> address;
mojo::internal::Pointer<mojo::internal::String_Data> name;
int32_t connection_state;
uint8_t is_paired : 1;
uint8_t pad3_[3];
int32_t device_type;
uint8_t pad4_[4];
mojo::internal::Pointer<internal::BluetoothDeviceBatteryInfo_Data> battery_info;
private:
BluetoothDeviceInfo_Data();
~BluetoothDeviceInfo_Data() = delete;
};
static_assert(sizeof(BluetoothDeviceInfo_Data) == 48,
"Bad sizeof(BluetoothDeviceInfo_Data)");
// Used by BluetoothDeviceInfo::WrapAsMessage to lazily serialize the struct.
template <typename UserType, typename DataView>
struct BluetoothDeviceInfo_UnserializedMessageContext
: public mojo::internal::UnserializedMessageContext {
public:
static const mojo::internal::UnserializedMessageContext::Tag kMessageTag;
BluetoothDeviceInfo_UnserializedMessageContext(
uint32_t message_name,
uint32_t message_flags,
UserType input)
: mojo::internal::UnserializedMessageContext(&kMessageTag, message_name, message_flags)
, user_data_(std::move(input)) {}
~BluetoothDeviceInfo_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 {
BluetoothDeviceInfo_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
BluetoothDeviceInfo_UnserializedMessageContext<UserType, DataView>::kMessageTag = {};
#pragma pack(pop)
} // namespace internal
} // namespace mojom
} // namespace device
#endif // SERVICES_DEVICE_PUBLIC_MOJOM_BLUETOOTH_SYSTEM_MOJOM_SHARED_INTERNAL_H_
/* Metadata comment
eyJtZXRhIjogW10sICJ0eXBlIjogImt5dGhlMCJ9
*/