Don't use nested enum definition in SerializedHandle
This type is an internal dependency of Mojo bindings and nested enum definitions are currently broken in JS lite bindings. Work around that by pulling this enum out of SerializedHandle. Bug: 939078 Change-Id: I9be1737a6271201d9b56a1cb69d6018e26514b26 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506767 Commit-Queue: Ken Rockot <rockot@google.com> Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org> Cr-Commit-Position: refs/heads/master@{#638354}
This commit is contained in:
ipc
mojo/public
@ -287,7 +287,7 @@ MojoResult ChannelMojo::ReadFromMessageAttachmentSet(
|
|||||||
auto serialized_handle = mojo::native::SerializedHandle::New();
|
auto serialized_handle = mojo::native::SerializedHandle::New();
|
||||||
serialized_handle->the_handle = attachment->TakeMojoHandle();
|
serialized_handle->the_handle = attachment->TakeMojoHandle();
|
||||||
serialized_handle->type =
|
serialized_handle->type =
|
||||||
mojo::ConvertTo<mojo::native::SerializedHandle::Type>(
|
mojo::ConvertTo<mojo::native::SerializedHandleType>(
|
||||||
attachment->GetType());
|
attachment->GetType());
|
||||||
output_handles.emplace_back(std::move(serialized_handle));
|
output_handles.emplace_back(std::move(serialized_handle));
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,19 @@
|
|||||||
namespace mojo {
|
namespace mojo {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
IPC::MessageAttachment::Type
|
IPC::MessageAttachment::Type TypeConverter<
|
||||||
TypeConverter<IPC::MessageAttachment::Type, native::SerializedHandle_Type>::
|
IPC::MessageAttachment::Type,
|
||||||
Convert(native::SerializedHandle_Type type) {
|
native::SerializedHandleType>::Convert(native::SerializedHandleType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case native::SerializedHandle_Type::MOJO_HANDLE:
|
case native::SerializedHandleType::MOJO_HANDLE:
|
||||||
return IPC::MessageAttachment::Type::MOJO_HANDLE;
|
return IPC::MessageAttachment::Type::MOJO_HANDLE;
|
||||||
case native::SerializedHandle_Type::PLATFORM_FILE:
|
case native::SerializedHandleType::PLATFORM_FILE:
|
||||||
return IPC::MessageAttachment::Type::PLATFORM_FILE;
|
return IPC::MessageAttachment::Type::PLATFORM_FILE;
|
||||||
case native::SerializedHandle_Type::WIN_HANDLE:
|
case native::SerializedHandleType::WIN_HANDLE:
|
||||||
return IPC::MessageAttachment::Type::WIN_HANDLE;
|
return IPC::MessageAttachment::Type::WIN_HANDLE;
|
||||||
case native::SerializedHandle_Type::MACH_PORT:
|
case native::SerializedHandleType::MACH_PORT:
|
||||||
return IPC::MessageAttachment::Type::MACH_PORT;
|
return IPC::MessageAttachment::Type::MACH_PORT;
|
||||||
case native::SerializedHandle_Type::FUCHSIA_HANDLE:
|
case native::SerializedHandleType::FUCHSIA_HANDLE:
|
||||||
return IPC::MessageAttachment::Type::FUCHSIA_HANDLE;
|
return IPC::MessageAttachment::Type::FUCHSIA_HANDLE;
|
||||||
}
|
}
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
@ -27,23 +27,23 @@ TypeConverter<IPC::MessageAttachment::Type, native::SerializedHandle_Type>::
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
native::SerializedHandle_Type TypeConverter<
|
native::SerializedHandleType TypeConverter<
|
||||||
native::SerializedHandle_Type,
|
native::SerializedHandleType,
|
||||||
IPC::MessageAttachment::Type>::Convert(IPC::MessageAttachment::Type type) {
|
IPC::MessageAttachment::Type>::Convert(IPC::MessageAttachment::Type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case IPC::MessageAttachment::Type::MOJO_HANDLE:
|
case IPC::MessageAttachment::Type::MOJO_HANDLE:
|
||||||
return native::SerializedHandle_Type::MOJO_HANDLE;
|
return native::SerializedHandleType::MOJO_HANDLE;
|
||||||
case IPC::MessageAttachment::Type::PLATFORM_FILE:
|
case IPC::MessageAttachment::Type::PLATFORM_FILE:
|
||||||
return native::SerializedHandle_Type::PLATFORM_FILE;
|
return native::SerializedHandleType::PLATFORM_FILE;
|
||||||
case IPC::MessageAttachment::Type::WIN_HANDLE:
|
case IPC::MessageAttachment::Type::WIN_HANDLE:
|
||||||
return native::SerializedHandle_Type::WIN_HANDLE;
|
return native::SerializedHandleType::WIN_HANDLE;
|
||||||
case IPC::MessageAttachment::Type::MACH_PORT:
|
case IPC::MessageAttachment::Type::MACH_PORT:
|
||||||
return native::SerializedHandle_Type::MACH_PORT;
|
return native::SerializedHandleType::MACH_PORT;
|
||||||
case IPC::MessageAttachment::Type::FUCHSIA_HANDLE:
|
case IPC::MessageAttachment::Type::FUCHSIA_HANDLE:
|
||||||
return native::SerializedHandle_Type::FUCHSIA_HANDLE;
|
return native::SerializedHandleType::FUCHSIA_HANDLE;
|
||||||
}
|
}
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
return native::SerializedHandle_Type::MOJO_HANDLE;
|
return native::SerializedHandleType::MOJO_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mojo
|
} // namespace mojo
|
||||||
|
@ -13,15 +13,15 @@ namespace mojo {
|
|||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct TypeConverter<IPC::MessageAttachment::Type,
|
struct TypeConverter<IPC::MessageAttachment::Type,
|
||||||
native::SerializedHandle_Type> {
|
native::SerializedHandleType> {
|
||||||
static IPC::MessageAttachment::Type Convert(
|
static IPC::MessageAttachment::Type Convert(
|
||||||
native::SerializedHandle_Type type);
|
native::SerializedHandleType type);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct TypeConverter<native::SerializedHandle_Type,
|
struct TypeConverter<native::SerializedHandleType,
|
||||||
IPC::MessageAttachment::Type> {
|
IPC::MessageAttachment::Type> {
|
||||||
static native::SerializedHandle_Type Convert(
|
static native::SerializedHandleType Convert(
|
||||||
IPC::MessageAttachment::Type type);
|
IPC::MessageAttachment::Type type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ void UnmappedNativeStructSerializerImpl::SerializeMessageContents(
|
|||||||
internal::Serializer<ScopedHandle, ScopedHandle>::Serialize(
|
internal::Serializer<ScopedHandle, ScopedHandle>::Serialize(
|
||||||
handle, &handle_writer->the_handle, context);
|
handle, &handle_writer->the_handle, context);
|
||||||
handle_writer->type = static_cast<int32_t>(
|
handle_writer->type = static_cast<int32_t>(
|
||||||
mojo::ConvertTo<native::SerializedHandle::Type>(attachment->GetType()));
|
mojo::ConvertTo<native::SerializedHandleType>(attachment->GetType()));
|
||||||
handles_writer.data()->at(i).Set(handle_writer.data());
|
handles_writer.data()->at(i).Set(handle_writer.data());
|
||||||
}
|
}
|
||||||
writer->data()->handles.Set(handles_writer.data());
|
writer->data()->handles.Set(handles_writer.data());
|
||||||
@ -115,7 +115,7 @@ bool UnmappedNativeStructSerializerImpl::DeserializeMessageAttachments(
|
|||||||
auto attachment = IPC::MessageAttachment::CreateFromMojoHandle(
|
auto attachment = IPC::MessageAttachment::CreateFromMojoHandle(
|
||||||
std::move(handle),
|
std::move(handle),
|
||||||
mojo::ConvertTo<IPC::MessageAttachment::Type>(
|
mojo::ConvertTo<IPC::MessageAttachment::Type>(
|
||||||
static_cast<native::SerializedHandle::Type>(handle_data->type)));
|
static_cast<native::SerializedHandleType>(handle_data->type)));
|
||||||
message->attachment_set()->AddAttachment(std::move(attachment));
|
message->attachment_set()->AddAttachment(std::move(attachment));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,18 +5,17 @@
|
|||||||
[JavaPackage="org.chromium.mojo.native_types"]
|
[JavaPackage="org.chromium.mojo.native_types"]
|
||||||
module mojo.native;
|
module mojo.native;
|
||||||
|
|
||||||
|
enum SerializedHandleType {
|
||||||
|
MOJO_HANDLE,
|
||||||
|
PLATFORM_FILE,
|
||||||
|
WIN_HANDLE,
|
||||||
|
MACH_PORT,
|
||||||
|
FUCHSIA_HANDLE,
|
||||||
|
};
|
||||||
|
|
||||||
struct SerializedHandle {
|
struct SerializedHandle {
|
||||||
handle the_handle;
|
handle the_handle;
|
||||||
|
SerializedHandleType type;
|
||||||
enum Type {
|
|
||||||
MOJO_HANDLE,
|
|
||||||
PLATFORM_FILE,
|
|
||||||
WIN_HANDLE,
|
|
||||||
MACH_PORT,
|
|
||||||
FUCHSIA_HANDLE,
|
|
||||||
};
|
|
||||||
|
|
||||||
Type type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[CustomSerializer]
|
[CustomSerializer]
|
||||||
|
Reference in New Issue
Block a user