Mojo C++ bindings: change the first template parameter of StructTraits and UnionTraits.
Previously the type is the auto-generated struct/union type. This CL changes it to the corresponding DataView type. The reason of doing this? The DataView type is shared by the chromium and blink variants of generated bindings, while the generated struct/union type is not. By changing StructTraits/UnionTraits to be specialized by the DataView type, users will be able to use the same StructTraits specialization in both variants. BUG=632061 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel Review-Url: https://codereview.chromium.org/2253293002 Cr-Commit-Position: refs/heads/master@{#413931}
This commit is contained in:
cc/ipc
begin_frame_args_struct_traits.hcompositor_frame_metadata_struct_traits.cccompositor_frame_metadata_struct_traits.hcompositor_frame_struct_traits.cccompositor_frame_struct_traits.hfilter_operation_struct_traits.hfilter_operations_struct_traits.hquads_struct_traits.ccquads_struct_traits.hrender_pass_id_struct_traits.hrender_pass_struct_traits.ccrender_pass_struct_traits.hreturned_resource_struct_traits.hselection_struct_traits.hshared_quad_state_struct_traits.hsurface_id_struct_traits.hsurface_sequence_struct_traits.htransferable_resource_struct_traits.cctransferable_resource_struct_traits.h
chrome/browser/media/router/mojo
components
arc
autofill
content
metrics
public
password_manager
translate
content
content/common/bluetooth
device
bluetooth
public
interfaces
generic_sensor
public
gpu/ipc/common
dx_diag_node_struct_traits.ccdx_diag_node_struct_traits.hgpu_info_struct_traits.ccgpu_info_struct_traits.hmailbox_holder_struct_traits.hmailbox_struct_traits.ccmailbox_struct_traits.hsync_token_struct_traits.h
media/mojo/common
mojo
common
public
cpp
bindings
tools
services
shell
ui
public
interfaces
skia/public/interfaces
bitmap_array_struct_traits.hbitmap_skbitmap_struct_traits.ccbitmap_skbitmap_struct_traits.himage_filter_struct_traits.h
third_party/WebKit/Source/platform/mojo
ui
url/mojo
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::BeginFrameArgs, cc::BeginFrameArgs> {
|
||||
struct StructTraits<cc::mojom::BeginFrameArgsDataView, cc::BeginFrameArgs> {
|
||||
static base::TimeTicks frame_time(const cc::BeginFrameArgs& args) {
|
||||
return args.frame_time;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::CompositorFrameMetadata,
|
||||
bool StructTraits<cc::mojom::CompositorFrameMetadataDataView,
|
||||
cc::CompositorFrameMetadata>::
|
||||
Read(cc::mojom::CompositorFrameMetadataDataView data,
|
||||
cc::CompositorFrameMetadata* out) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::CompositorFrameMetadata,
|
||||
struct StructTraits<cc::mojom::CompositorFrameMetadataDataView,
|
||||
cc::CompositorFrameMetadata> {
|
||||
static float device_scale_factor(
|
||||
const cc::CompositorFrameMetadata& metadata) {
|
||||
|
@ -10,9 +10,10 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::CompositorFrame, cc::CompositorFrame>::Read(
|
||||
cc::mojom::CompositorFrameDataView data,
|
||||
cc::CompositorFrame* out) {
|
||||
bool StructTraits<cc::mojom::CompositorFrameDataView,
|
||||
cc::CompositorFrame>::Read(cc::mojom::CompositorFrameDataView
|
||||
data,
|
||||
cc::CompositorFrame* out) {
|
||||
if (!data.ReadMetadata(&out->metadata))
|
||||
return false;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::CompositorFrame, cc::CompositorFrame> {
|
||||
struct StructTraits<cc::mojom::CompositorFrameDataView, cc::CompositorFrame> {
|
||||
static const cc::CompositorFrameMetadata& metadata(
|
||||
const cc::CompositorFrame& input) {
|
||||
return input.metadata;
|
||||
|
@ -95,7 +95,7 @@ cc::FilterOperation::FilterType MojoFilterTypeToCC(
|
||||
using FilterOperationMatrix = CArray<float>;
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::FilterOperation, cc::FilterOperation> {
|
||||
struct StructTraits<cc::mojom::FilterOperationDataView, cc::FilterOperation> {
|
||||
static cc::mojom::FilterType type(const cc::FilterOperation& op) {
|
||||
return CCFilterTypeToMojo(op.type());
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::FilterOperations, cc::FilterOperations> {
|
||||
struct StructTraits<cc::mojom::FilterOperationsDataView, cc::FilterOperations> {
|
||||
static const std::vector<cc::FilterOperation>& operations(
|
||||
const cc::FilterOperations& operations) {
|
||||
return operations.operations();
|
||||
|
@ -50,7 +50,7 @@ cc::DrawQuad* AllocateAndConstruct(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::DebugBorderQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::DebugBorderQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::DebugBorderQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::DebugBorderDrawQuad* quad = static_cast<cc::DebugBorderDrawQuad*>(out);
|
||||
@ -60,7 +60,7 @@ bool StructTraits<cc::mojom::DebugBorderQuadState, cc::DrawQuad>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::RenderPassQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::RenderPassQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::RenderPassQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::RenderPassDrawQuad* quad = static_cast<cc::RenderPassDrawQuad*>(out);
|
||||
@ -76,7 +76,7 @@ bool StructTraits<cc::mojom::RenderPassQuadState, cc::DrawQuad>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::SolidColorQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::SolidColorQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::SolidColorQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::SolidColorDrawQuad* quad = static_cast<cc::SolidColorDrawQuad*>(out);
|
||||
@ -86,7 +86,7 @@ bool StructTraits<cc::mojom::SolidColorQuadState, cc::DrawQuad>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::StreamVideoQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::StreamVideoQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::StreamVideoQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::StreamVideoDrawQuad* quad = static_cast<cc::StreamVideoDrawQuad*>(out);
|
||||
@ -100,7 +100,7 @@ bool StructTraits<cc::mojom::StreamVideoQuadState, cc::DrawQuad>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::SurfaceQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::SurfaceQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::SurfaceQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::SurfaceDrawQuad* quad = static_cast<cc::SurfaceDrawQuad*>(out);
|
||||
@ -108,7 +108,7 @@ bool StructTraits<cc::mojom::SurfaceQuadState, cc::DrawQuad>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::TextureQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::TextureQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::TextureQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::TextureDrawQuad* quad = static_cast<cc::TextureDrawQuad*>(out);
|
||||
@ -132,7 +132,7 @@ bool StructTraits<cc::mojom::TextureQuadState, cc::DrawQuad>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::TileQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::TileQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::TileQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::TileDrawQuad* quad = static_cast<cc::TileDrawQuad*>(out);
|
||||
@ -182,7 +182,7 @@ bool EnumTraits<cc::mojom::YUVColorSpace, cc::YUVVideoDrawQuad::ColorSpace>::
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::YUVVideoQuadState, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::YUVVideoQuadStateDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::YUVVideoQuadStateDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
cc::YUVVideoDrawQuad* quad = static_cast<cc::YUVVideoDrawQuad*>(out);
|
||||
@ -218,7 +218,7 @@ bool StructTraits<cc::mojom::YUVVideoQuadState, cc::DrawQuad>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::DrawQuad, cc::DrawQuad>::Read(
|
||||
bool StructTraits<cc::mojom::DrawQuadDataView, cc::DrawQuad>::Read(
|
||||
cc::mojom::DrawQuadDataView data,
|
||||
cc::DrawQuad* out) {
|
||||
if (!data.ReadRect(&out->rect) || !data.ReadOpaqueRect(&out->opaque_rect) ||
|
||||
|
@ -29,7 +29,7 @@ cc::DrawQuad* AllocateAndConstruct(
|
||||
cc::QuadList* list);
|
||||
|
||||
template <>
|
||||
struct UnionTraits<cc::mojom::DrawQuadState, cc::DrawQuad> {
|
||||
struct UnionTraits<cc::mojom::DrawQuadStateDataView, cc::DrawQuad> {
|
||||
static cc::mojom::DrawQuadState::DataView::Tag GetTag(
|
||||
const cc::DrawQuad& quad) {
|
||||
switch (quad.material) {
|
||||
@ -115,7 +115,7 @@ struct UnionTraits<cc::mojom::DrawQuadState, cc::DrawQuad> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::DebugBorderQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::DebugBorderQuadStateDataView, cc::DrawQuad> {
|
||||
static uint32_t color(const cc::DrawQuad& input) {
|
||||
const cc::DebugBorderDrawQuad* quad =
|
||||
cc::DebugBorderDrawQuad::MaterialCast(&input);
|
||||
@ -133,7 +133,7 @@ struct StructTraits<cc::mojom::DebugBorderQuadState, cc::DrawQuad> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::RenderPassQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::RenderPassQuadStateDataView, cc::DrawQuad> {
|
||||
static const cc::RenderPassId& render_pass_id(const cc::DrawQuad& input) {
|
||||
const cc::RenderPassDrawQuad* quad =
|
||||
cc::RenderPassDrawQuad::MaterialCast(&input);
|
||||
@ -182,7 +182,7 @@ struct StructTraits<cc::mojom::RenderPassQuadState, cc::DrawQuad> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::SolidColorQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::SolidColorQuadStateDataView, cc::DrawQuad> {
|
||||
static uint32_t color(const cc::DrawQuad& input) {
|
||||
const cc::SolidColorDrawQuad* quad =
|
||||
cc::SolidColorDrawQuad::MaterialCast(&input);
|
||||
@ -200,7 +200,7 @@ struct StructTraits<cc::mojom::SolidColorQuadState, cc::DrawQuad> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::StreamVideoQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::StreamVideoQuadStateDataView, cc::DrawQuad> {
|
||||
static uint32_t resource_id(const cc::DrawQuad& input) {
|
||||
const cc::StreamVideoDrawQuad* quad =
|
||||
cc::StreamVideoDrawQuad::MaterialCast(&input);
|
||||
@ -225,7 +225,7 @@ struct StructTraits<cc::mojom::StreamVideoQuadState, cc::DrawQuad> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::SurfaceQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::SurfaceQuadStateDataView, cc::DrawQuad> {
|
||||
static const cc::SurfaceId& surface(const cc::DrawQuad& input) {
|
||||
const cc::SurfaceDrawQuad* quad = cc::SurfaceDrawQuad::MaterialCast(&input);
|
||||
return quad->surface_id;
|
||||
@ -235,7 +235,7 @@ struct StructTraits<cc::mojom::SurfaceQuadState, cc::DrawQuad> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::TextureQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::TextureQuadStateDataView, cc::DrawQuad> {
|
||||
static uint32_t resource_id(const cc::DrawQuad& input) {
|
||||
const cc::TextureDrawQuad* quad = cc::TextureDrawQuad::MaterialCast(&input);
|
||||
return quad->resource_id();
|
||||
@ -285,7 +285,7 @@ struct StructTraits<cc::mojom::TextureQuadState, cc::DrawQuad> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::TileQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::TileQuadStateDataView, cc::DrawQuad> {
|
||||
static const gfx::RectF& tex_coord_rect(const cc::DrawQuad& input) {
|
||||
const cc::TileDrawQuad* quad = cc::TileDrawQuad::MaterialCast(&input);
|
||||
return quad->tex_coord_rect;
|
||||
@ -323,7 +323,7 @@ struct EnumTraits<cc::mojom::YUVColorSpace, cc::YUVVideoDrawQuad::ColorSpace> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::YUVVideoQuadState, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::YUVVideoQuadStateDataView, cc::DrawQuad> {
|
||||
static const gfx::RectF& ya_tex_coord_rect(const cc::DrawQuad& input) {
|
||||
const cc::YUVVideoDrawQuad* quad =
|
||||
cc::YUVVideoDrawQuad::MaterialCast(&input);
|
||||
@ -407,7 +407,7 @@ struct DrawQuadWithSharedQuadState {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::DrawQuad, DrawQuadWithSharedQuadState> {
|
||||
struct StructTraits<cc::mojom::DrawQuadDataView, DrawQuadWithSharedQuadState> {
|
||||
static const gfx::Rect& rect(const DrawQuadWithSharedQuadState& input) {
|
||||
return input.quad->rect;
|
||||
}
|
||||
@ -438,7 +438,7 @@ struct StructTraits<cc::mojom::DrawQuad, DrawQuadWithSharedQuadState> {
|
||||
|
||||
// This StructTraits is only used for deserialization within RenderPasses.
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::DrawQuad, cc::DrawQuad> {
|
||||
struct StructTraits<cc::mojom::DrawQuadDataView, cc::DrawQuad> {
|
||||
static bool Read(cc::mojom::DrawQuadDataView data, cc::DrawQuad* out);
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::RenderPassId, cc::RenderPassId> {
|
||||
struct StructTraits<cc::mojom::RenderPassIdDataView, cc::RenderPassId> {
|
||||
static int layer_id(const cc::RenderPassId& id) { return id.layer_id; }
|
||||
|
||||
static uint32_t index(const cc::RenderPassId& id) { return id.index; }
|
||||
|
@ -10,9 +10,10 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>::Read(
|
||||
cc::mojom::RenderPassDataView data,
|
||||
std::unique_ptr<cc::RenderPass>* out) {
|
||||
bool StructTraits<cc::mojom::RenderPassDataView,
|
||||
std::unique_ptr<cc::RenderPass>>::
|
||||
Read(cc::mojom::RenderPassDataView data,
|
||||
std::unique_ptr<cc::RenderPass>* out) {
|
||||
*out = cc::RenderPass::Create();
|
||||
if (!data.ReadId(&(*out)->id) || !data.ReadOutputRect(&(*out)->output_rect) ||
|
||||
!data.ReadDamageRect(&(*out)->damage_rect) ||
|
||||
|
@ -14,7 +14,8 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>> {
|
||||
struct StructTraits<cc::mojom::RenderPassDataView,
|
||||
std::unique_ptr<cc::RenderPass>> {
|
||||
static const cc::RenderPassId& id(
|
||||
const std::unique_ptr<cc::RenderPass>& input) {
|
||||
return input->id;
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::ReturnedResource, cc::ReturnedResource> {
|
||||
struct StructTraits<cc::mojom::ReturnedResourceDataView, cc::ReturnedResource> {
|
||||
static uint32_t id(const cc::ReturnedResource& resource) {
|
||||
return resource.id;
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::Selection, cc::Selection<gfx::SelectionBound>> {
|
||||
struct StructTraits<cc::mojom::SelectionDataView,
|
||||
cc::Selection<gfx::SelectionBound>> {
|
||||
static const gfx::SelectionBound& start(
|
||||
const cc::Selection<gfx::SelectionBound>& selection) {
|
||||
return selection.start;
|
||||
|
@ -15,7 +15,7 @@ struct OptSharedQuadState {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::SharedQuadState, OptSharedQuadState> {
|
||||
struct StructTraits<cc::mojom::SharedQuadStateDataView, OptSharedQuadState> {
|
||||
static bool IsNull(const OptSharedQuadState& input) { return !input.sqs; }
|
||||
|
||||
static void SetToNull(OptSharedQuadState* output) { output->sqs = nullptr; }
|
||||
@ -56,7 +56,7 @@ struct StructTraits<cc::mojom::SharedQuadState, OptSharedQuadState> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::SharedQuadState, cc::SharedQuadState> {
|
||||
struct StructTraits<cc::mojom::SharedQuadStateDataView, cc::SharedQuadState> {
|
||||
static const gfx::Transform& quad_to_target_transform(
|
||||
const cc::SharedQuadState& sqs) {
|
||||
return sqs.quad_to_target_transform;
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
namespace mojo {
|
||||
|
||||
// This template is fully specialized as cc::mojom::SurfaceId and
|
||||
// as cc::mojom::blink::SurfaceId, in generated .mojom.h and .mojom-blink.h
|
||||
// respectively.
|
||||
// This template is fully specialized as cc::mojom::SurfaceIdDataView and
|
||||
// as cc::mojom::blink::SurfaceIdDataView, in generated .mojom.h and
|
||||
// .mojom-blink.h respectively.
|
||||
template <typename T>
|
||||
struct StructTraits<T, cc::SurfaceId> {
|
||||
static uint32_t client_id(const cc::SurfaceId& id) { return id.client_id(); }
|
||||
@ -20,7 +20,7 @@ struct StructTraits<T, cc::SurfaceId> {
|
||||
|
||||
static uint64_t nonce(const cc::SurfaceId& id) { return id.nonce(); }
|
||||
|
||||
static bool Read(typename T::DataView data, cc::SurfaceId* out) {
|
||||
static bool Read(T data, cc::SurfaceId* out) {
|
||||
*out = cc::SurfaceId(data.client_id(), data.local_id(), data.nonce());
|
||||
return true;
|
||||
}
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
namespace mojo {
|
||||
|
||||
// This template is fully specialized as cc::mojom::SurfaceSequence and
|
||||
// as cc::mojom::blink::SurfaceSequence, in generated .mojom.h and
|
||||
// This template is fully specialized as cc::mojom::SurfaceSequenceDataView and
|
||||
// as cc::mojom::blink::SurfaceSequenceDataView, in generated .mojom.h and
|
||||
// .mojom-blink.h respectively.
|
||||
template <typename T>
|
||||
struct StructTraits<T, cc::SurfaceSequence> {
|
||||
@ -22,7 +22,7 @@ struct StructTraits<T, cc::SurfaceSequence> {
|
||||
return id.sequence;
|
||||
}
|
||||
|
||||
static bool Read(typename T::DataView data, cc::SurfaceSequence* out) {
|
||||
static bool Read(T data, cc::SurfaceSequence* out) {
|
||||
*out = cc::SurfaceSequence(data.client_id(), data.sequence());
|
||||
return true;
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
bool StructTraits<cc::mojom::TransferableResource, cc::TransferableResource>::
|
||||
bool StructTraits<cc::mojom::TransferableResourceDataView,
|
||||
cc::TransferableResource>::
|
||||
Read(cc::mojom::TransferableResourceDataView data,
|
||||
cc::TransferableResource* out) {
|
||||
if (!data.ReadSize(&out->size) ||
|
||||
|
@ -11,7 +11,8 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<cc::mojom::TransferableResource, cc::TransferableResource> {
|
||||
struct StructTraits<cc::mojom::TransferableResourceDataView,
|
||||
cc::TransferableResource> {
|
||||
static uint32_t id(const cc::TransferableResource& resource) {
|
||||
return resource.id;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<media_router::mojom::RouteMessage,
|
||||
struct StructTraits<media_router::mojom::RouteMessageDataView,
|
||||
media_router::RouteMessage> {
|
||||
static media_router::mojom::RouteMessage::Type type(
|
||||
const media_router::RouteMessage& msg) {
|
||||
|
@ -1,2 +1,5 @@
|
||||
per-file *.mojom=set noparent
|
||||
per-file *.mojom=file://ipc/SECURITY_OWNERS
|
||||
|
||||
per-file *_struct_traits*.*=set noparent
|
||||
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
|
@ -6,8 +6,9 @@
|
||||
|
||||
namespace mojo {
|
||||
|
||||
bool StructTraits<arc::mojom::ScreenRect, gfx::Rect>::Read(
|
||||
arc::mojom::ScreenRectDataView data, gfx::Rect* out) {
|
||||
bool StructTraits<arc::mojom::ScreenRectDataView, gfx::Rect>::Read(
|
||||
arc::mojom::ScreenRectDataView data,
|
||||
gfx::Rect* out) {
|
||||
if (data.right() < data.left() || data.bottom() < data.top())
|
||||
return false;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<arc::mojom::ScreenRect, gfx::Rect> {
|
||||
struct StructTraits<arc::mojom::ScreenRectDataView, gfx::Rect> {
|
||||
static int32_t left(const gfx::Rect& p) { return p.x(); }
|
||||
static int32_t top(const gfx::Rect& p) { return p.y(); }
|
||||
static int32_t right(const gfx::Rect& p) { return p.right(); }
|
||||
|
@ -329,7 +329,7 @@ bool EnumTraits<mojom::PasswordFormFieldPredictionType,
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::FormFieldData, FormFieldData>::Read(
|
||||
bool StructTraits<mojom::FormFieldDataDataView, FormFieldData>::Read(
|
||||
mojom::FormFieldDataDataView data,
|
||||
FormFieldData* out) {
|
||||
if (!data.ReadLabel(&out->label))
|
||||
@ -376,8 +376,9 @@ bool StructTraits<mojom::FormFieldData, FormFieldData>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::FormData, FormData>::Read(mojom::FormDataDataView data,
|
||||
FormData* out) {
|
||||
bool StructTraits<mojom::FormDataDataView, FormData>::Read(
|
||||
mojom::FormDataDataView data,
|
||||
FormData* out) {
|
||||
if (!data.ReadName(&out->name))
|
||||
return false;
|
||||
if (!data.ReadOrigin(&out->origin))
|
||||
@ -395,7 +396,8 @@ bool StructTraits<mojom::FormData, FormData>::Read(mojom::FormDataDataView data,
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::FormFieldDataPredictions, FormFieldDataPredictions>::
|
||||
bool StructTraits<mojom::FormFieldDataPredictionsDataView,
|
||||
FormFieldDataPredictions>::
|
||||
Read(mojom::FormFieldDataPredictionsDataView data,
|
||||
FormFieldDataPredictions* out) {
|
||||
if (!data.ReadField(&out->field))
|
||||
@ -415,9 +417,10 @@ bool StructTraits<mojom::FormFieldDataPredictions, FormFieldDataPredictions>::
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::FormDataPredictions, FormDataPredictions>::Read(
|
||||
mojom::FormDataPredictionsDataView data,
|
||||
FormDataPredictions* out) {
|
||||
bool StructTraits<mojom::FormDataPredictionsDataView,
|
||||
FormDataPredictions>::Read(mojom::FormDataPredictionsDataView
|
||||
data,
|
||||
FormDataPredictions* out) {
|
||||
if (!data.ReadData(&out->data))
|
||||
return false;
|
||||
if (!data.ReadSignature(&out->signature))
|
||||
@ -429,7 +432,7 @@ bool StructTraits<mojom::FormDataPredictions, FormDataPredictions>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::PasswordAndRealm, PasswordAndRealm>::Read(
|
||||
bool StructTraits<mojom::PasswordAndRealmDataView, PasswordAndRealm>::Read(
|
||||
mojom::PasswordAndRealmDataView data,
|
||||
PasswordAndRealm* out) {
|
||||
if (!data.ReadPassword(&out->password))
|
||||
@ -441,9 +444,10 @@ bool StructTraits<mojom::PasswordAndRealm, PasswordAndRealm>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::UsernamesCollectionKey, UsernamesCollectionKey>::Read(
|
||||
mojom::UsernamesCollectionKeyDataView data,
|
||||
UsernamesCollectionKey* out) {
|
||||
bool StructTraits<
|
||||
mojom::UsernamesCollectionKeyDataView,
|
||||
UsernamesCollectionKey>::Read(mojom::UsernamesCollectionKeyDataView data,
|
||||
UsernamesCollectionKey* out) {
|
||||
if (!data.ReadUsername(&out->username))
|
||||
return false;
|
||||
if (!data.ReadPassword(&out->password))
|
||||
@ -455,7 +459,7 @@ bool StructTraits<mojom::UsernamesCollectionKey, UsernamesCollectionKey>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
void* StructTraits<mojom::PasswordFormFillData, PasswordFormFillData>::
|
||||
void* StructTraits<mojom::PasswordFormFillDataDataView, PasswordFormFillData>::
|
||||
SetUpContext(const PasswordFormFillData& r) {
|
||||
// Extracts keys vector and values vector from the map, saves them as a pair.
|
||||
auto* pair = new UsernamesCollectionKeysValuesPair();
|
||||
@ -468,15 +472,14 @@ void* StructTraits<mojom::PasswordFormFillData, PasswordFormFillData>::
|
||||
}
|
||||
|
||||
// static
|
||||
void StructTraits<mojom::PasswordFormFillData, PasswordFormFillData>::
|
||||
void StructTraits<mojom::PasswordFormFillDataDataView, PasswordFormFillData>::
|
||||
TearDownContext(const PasswordFormFillData& r, void* context) {
|
||||
delete static_cast<UsernamesCollectionKeysValuesPair*>(context);
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::PasswordFormFillData, PasswordFormFillData>::Read(
|
||||
mojom::PasswordFormFillDataDataView data,
|
||||
PasswordFormFillData* out) {
|
||||
bool StructTraits<mojom::PasswordFormFillDataDataView, PasswordFormFillData>::
|
||||
Read(mojom::PasswordFormFillDataDataView data, PasswordFormFillData* out) {
|
||||
if (!data.ReadName(&out->name) || !data.ReadOrigin(&out->origin) ||
|
||||
!data.ReadAction(&out->action) ||
|
||||
!data.ReadUsernameField(&out->username_field) ||
|
||||
@ -506,7 +509,7 @@ bool StructTraits<mojom::PasswordFormFillData, PasswordFormFillData>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::PasswordFormGenerationData,
|
||||
bool StructTraits<mojom::PasswordFormGenerationDataDataView,
|
||||
PasswordFormGenerationData>::
|
||||
Read(mojom::PasswordFormGenerationDataDataView data,
|
||||
PasswordFormGenerationData* out) {
|
||||
@ -518,7 +521,7 @@ bool StructTraits<mojom::PasswordFormGenerationData,
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::PasswordForm, PasswordForm>::Read(
|
||||
bool StructTraits<mojom::PasswordFormDataView, PasswordForm>::Read(
|
||||
mojom::PasswordFormDataView data,
|
||||
PasswordForm* out) {
|
||||
if (!data.ReadScheme(&out->scheme) ||
|
||||
@ -581,7 +584,7 @@ bool StructTraits<mojom::PasswordForm, PasswordForm>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
void* StructTraits<mojom::PasswordFormFieldPredictionMap,
|
||||
void* StructTraits<mojom::PasswordFormFieldPredictionMapDataView,
|
||||
PasswordFormFieldPredictionMap>::
|
||||
SetUpContext(const PasswordFormFieldPredictionMap& r) {
|
||||
// Extracts keys vector and values vector from the map, saves them as a pair.
|
||||
@ -595,14 +598,14 @@ void* StructTraits<mojom::PasswordFormFieldPredictionMap,
|
||||
}
|
||||
|
||||
// static
|
||||
void StructTraits<mojom::PasswordFormFieldPredictionMap,
|
||||
void StructTraits<mojom::PasswordFormFieldPredictionMapDataView,
|
||||
PasswordFormFieldPredictionMap>::
|
||||
TearDownContext(const PasswordFormFieldPredictionMap& r, void* context) {
|
||||
delete static_cast<KeysValuesPair*>(context);
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::PasswordFormFieldPredictionMap,
|
||||
bool StructTraits<mojom::PasswordFormFieldPredictionMapDataView,
|
||||
PasswordFormFieldPredictionMap>::
|
||||
Read(mojom::PasswordFormFieldPredictionMapDataView data,
|
||||
PasswordFormFieldPredictionMap* out) {
|
||||
@ -623,7 +626,7 @@ bool StructTraits<mojom::PasswordFormFieldPredictionMap,
|
||||
}
|
||||
|
||||
// static
|
||||
void* StructTraits<mojom::FormsPredictionsMap,
|
||||
void* StructTraits<mojom::FormsPredictionsMapDataView,
|
||||
FormsPredictionsMap>::SetUpContext(const FormsPredictionsMap&
|
||||
r) {
|
||||
// Extracts keys vector and values vector from the map, saves them as a pair.
|
||||
@ -637,15 +640,16 @@ void* StructTraits<mojom::FormsPredictionsMap,
|
||||
}
|
||||
|
||||
// static
|
||||
void StructTraits<mojom::FormsPredictionsMap, FormsPredictionsMap>::
|
||||
void StructTraits<mojom::FormsPredictionsMapDataView, FormsPredictionsMap>::
|
||||
TearDownContext(const FormsPredictionsMap& r, void* context) {
|
||||
delete static_cast<KeysValuesPair*>(context);
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::FormsPredictionsMap, FormsPredictionsMap>::Read(
|
||||
mojom::FormsPredictionsMapDataView data,
|
||||
FormsPredictionsMap* out) {
|
||||
bool StructTraits<mojom::FormsPredictionsMapDataView,
|
||||
FormsPredictionsMap>::Read(mojom::FormsPredictionsMapDataView
|
||||
data,
|
||||
FormsPredictionsMap* out) {
|
||||
// Combines keys vector and values vector to the map.
|
||||
std::vector<FormData> keys;
|
||||
if (!data.ReadKeys(&keys))
|
||||
|
@ -93,7 +93,8 @@ struct EnumTraits<autofill::mojom::PasswordFormFieldPredictionType,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::FormFieldData, autofill::FormFieldData> {
|
||||
struct StructTraits<autofill::mojom::FormFieldDataDataView,
|
||||
autofill::FormFieldData> {
|
||||
static const base::string16& label(const autofill::FormFieldData& r) {
|
||||
return r.label;
|
||||
}
|
||||
@ -174,7 +175,7 @@ struct StructTraits<autofill::mojom::FormFieldData, autofill::FormFieldData> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::FormData, autofill::FormData> {
|
||||
struct StructTraits<autofill::mojom::FormDataDataView, autofill::FormData> {
|
||||
static const base::string16& name(const autofill::FormData& r) {
|
||||
return r.name;
|
||||
}
|
||||
@ -199,7 +200,7 @@ struct StructTraits<autofill::mojom::FormData, autofill::FormData> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::FormFieldDataPredictions,
|
||||
struct StructTraits<autofill::mojom::FormFieldDataPredictionsDataView,
|
||||
autofill::FormFieldDataPredictions> {
|
||||
static const autofill::FormFieldData& field(
|
||||
const autofill::FormFieldDataPredictions& r) {
|
||||
@ -236,7 +237,7 @@ struct StructTraits<autofill::mojom::FormFieldDataPredictions,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::FormDataPredictions,
|
||||
struct StructTraits<autofill::mojom::FormDataPredictionsDataView,
|
||||
autofill::FormDataPredictions> {
|
||||
static const autofill::FormData& data(
|
||||
const autofill::FormDataPredictions& r) {
|
||||
@ -257,7 +258,7 @@ struct StructTraits<autofill::mojom::FormDataPredictions,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::PasswordAndRealm,
|
||||
struct StructTraits<autofill::mojom::PasswordAndRealmDataView,
|
||||
autofill::PasswordAndRealm> {
|
||||
static const base::string16& password(const autofill::PasswordAndRealm& r) {
|
||||
return r.password;
|
||||
@ -272,7 +273,7 @@ struct StructTraits<autofill::mojom::PasswordAndRealm,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::UsernamesCollectionKey,
|
||||
struct StructTraits<autofill::mojom::UsernamesCollectionKeyDataView,
|
||||
autofill::UsernamesCollectionKey> {
|
||||
static const base::string16& username(
|
||||
const autofill::UsernamesCollectionKey& r) {
|
||||
@ -293,7 +294,7 @@ struct StructTraits<autofill::mojom::UsernamesCollectionKey,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::PasswordFormFillData,
|
||||
struct StructTraits<autofill::mojom::PasswordFormFillDataDataView,
|
||||
autofill::PasswordFormFillData> {
|
||||
using UsernamesCollectionKeysValuesPair =
|
||||
std::pair<std::vector<autofill::UsernamesCollectionKey>,
|
||||
@ -362,7 +363,7 @@ struct StructTraits<autofill::mojom::PasswordFormFillData,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::PasswordFormGenerationData,
|
||||
struct StructTraits<autofill::mojom::PasswordFormGenerationDataDataView,
|
||||
autofill::PasswordFormGenerationData> {
|
||||
static const base::string16& name(
|
||||
const autofill::PasswordFormGenerationData& r) {
|
||||
@ -383,7 +384,8 @@ struct StructTraits<autofill::mojom::PasswordFormGenerationData,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::PasswordForm, autofill::PasswordForm> {
|
||||
struct StructTraits<autofill::mojom::PasswordFormDataView,
|
||||
autofill::PasswordForm> {
|
||||
static autofill::PasswordForm::Scheme scheme(
|
||||
const autofill::PasswordForm& r) {
|
||||
return r.scheme;
|
||||
@ -533,7 +535,7 @@ struct StructTraits<autofill::mojom::PasswordForm, autofill::PasswordForm> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::PasswordFormFieldPredictionMap,
|
||||
struct StructTraits<autofill::mojom::PasswordFormFieldPredictionMapDataView,
|
||||
autofill::PasswordFormFieldPredictionMap> {
|
||||
using KeysValuesPair =
|
||||
std::pair<std::vector<autofill::FormFieldData>,
|
||||
@ -561,7 +563,7 @@ struct StructTraits<autofill::mojom::PasswordFormFieldPredictionMap,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<autofill::mojom::FormsPredictionsMap,
|
||||
struct StructTraits<autofill::mojom::FormsPredictionsMapDataView,
|
||||
autofill::FormsPredictionsMap> {
|
||||
using KeysValuesPair =
|
||||
std::pair<std::vector<autofill::FormData>,
|
||||
|
@ -17,7 +17,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<metrics::mojom::CallStackModule,
|
||||
struct StructTraits<metrics::mojom::CallStackModuleDataView,
|
||||
base::StackSamplingProfiler::Module> {
|
||||
static uint64_t base_address(
|
||||
const base::StackSamplingProfiler::Module& module) {
|
||||
@ -50,7 +50,7 @@ struct StructTraits<metrics::mojom::CallStackModule,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<metrics::mojom::CallStackFrame,
|
||||
struct StructTraits<metrics::mojom::CallStackFrameDataView,
|
||||
base::StackSamplingProfiler::Frame> {
|
||||
static uint64_t instruction_pointer(
|
||||
const base::StackSamplingProfiler::Frame& frame) {
|
||||
@ -80,7 +80,7 @@ struct StructTraits<metrics::mojom::CallStackFrame,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<metrics::mojom::CallStackProfile,
|
||||
struct StructTraits<metrics::mojom::CallStackProfileDataView,
|
||||
base::StackSamplingProfiler::CallStackProfile> {
|
||||
static const std::vector<base::StackSamplingProfiler::Module>& modules(
|
||||
const base::StackSamplingProfiler::CallStackProfile& profile) {
|
||||
|
@ -49,7 +49,7 @@ bool EnumTraits<mojom::CredentialType, CredentialType>::FromMojom(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::CredentialInfo, CredentialInfo>::Read(
|
||||
bool StructTraits<mojom::CredentialInfoDataView, CredentialInfo>::Read(
|
||||
mojom::CredentialInfoDataView data,
|
||||
CredentialInfo* out) {
|
||||
if (data.ReadType(&out->type) && data.ReadId(&out->id) &&
|
||||
|
@ -22,7 +22,7 @@ struct EnumTraits<password_manager::mojom::CredentialType,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<password_manager::mojom::CredentialInfo,
|
||||
struct StructTraits<password_manager::mojom::CredentialInfoDataView,
|
||||
password_manager::CredentialInfo> {
|
||||
static password_manager::CredentialType type(
|
||||
const password_manager::CredentialInfo& r) {
|
||||
|
@ -92,7 +92,8 @@ bool EnumTraits<mojom::TranslateError, TranslateErrors::Type>::FromMojom(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojom::LanguageDetectionDetails, LanguageDetectionDetails>::
|
||||
bool StructTraits<mojom::LanguageDetectionDetailsDataView,
|
||||
LanguageDetectionDetails>::
|
||||
Read(mojom::LanguageDetectionDetailsDataView data,
|
||||
LanguageDetectionDetails* out) {
|
||||
if (!data.ReadTime(&out->time))
|
||||
|
@ -24,7 +24,7 @@ struct EnumTraits<translate::mojom::TranslateError,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<translate::mojom::LanguageDetectionDetails,
|
||||
struct StructTraits<translate::mojom::LanguageDetectionDetailsDataView,
|
||||
translate::LanguageDetectionDetails> {
|
||||
static const base::Time& time(const translate::LanguageDetectionDetails& r) {
|
||||
return r.time;
|
||||
|
@ -13,7 +13,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<blink::mojom::WebBluetoothDeviceId,
|
||||
struct StructTraits<blink::mojom::WebBluetoothDeviceIdDataView,
|
||||
content::WebBluetoothDeviceId> {
|
||||
static const std::string& device_id(
|
||||
const content::WebBluetoothDeviceId& device_id) {
|
||||
|
@ -13,7 +13,8 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<device::mojom::BluetoothUUID, device::BluetoothUUID> {
|
||||
struct StructTraits<device::mojom::BluetoothUUIDDataView,
|
||||
device::BluetoothUUID> {
|
||||
static const std::string& uuid(const device::BluetoothUUID& uuid) {
|
||||
return uuid.canonical_value();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
bool StructTraits<device::mojom::SensorConfiguration,
|
||||
bool StructTraits<device::mojom::SensorConfigurationDataView,
|
||||
device::PlatformSensorConfiguration>::
|
||||
Read(device::mojom::SensorConfigurationDataView data,
|
||||
device::PlatformSensorConfiguration* out) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<device::mojom::SensorConfiguration,
|
||||
struct StructTraits<device::mojom::SensorConfigurationDataView,
|
||||
device::PlatformSensorConfiguration> {
|
||||
static double frequency(const device::PlatformSensorConfiguration& input) {
|
||||
return input.frequency();
|
||||
|
@ -7,7 +7,7 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
bool StructTraits<gpu::mojom::DxDiagNode, gpu::DxDiagNode>::Read(
|
||||
bool StructTraits<gpu::mojom::DxDiagNodeDataView, gpu::DxDiagNode>::Read(
|
||||
gpu::mojom::DxDiagNodeDataView data,
|
||||
gpu::DxDiagNode* out) {
|
||||
return data.ReadValues(&out->values) && data.ReadChildren(&out->children);
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::DxDiagNode, gpu::DxDiagNode> {
|
||||
struct StructTraits<gpu::mojom::DxDiagNodeDataView, gpu::DxDiagNode> {
|
||||
static bool Read(gpu::mojom::DxDiagNodeDataView data, gpu::DxDiagNode* out);
|
||||
|
||||
static const std::map<std::string, std::string>& values(
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
bool StructTraits<gpu::mojom::GpuDevice, gpu::GPUInfo::GPUDevice>::Read(
|
||||
bool StructTraits<gpu::mojom::GpuDeviceDataView, gpu::GPUInfo::GPUDevice>::Read(
|
||||
gpu::mojom::GpuDeviceDataView data,
|
||||
gpu::GPUInfo::GPUDevice* out) {
|
||||
out->vendor_id = data.vendor_id();
|
||||
@ -182,7 +182,7 @@ bool EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile>::
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<gpu::mojom::VideoDecodeAcceleratorSupportedProfile,
|
||||
bool StructTraits<gpu::mojom::VideoDecodeAcceleratorSupportedProfileDataView,
|
||||
gpu::VideoDecodeAcceleratorSupportedProfile>::
|
||||
Read(gpu::mojom::VideoDecodeAcceleratorSupportedProfileDataView data,
|
||||
gpu::VideoDecodeAcceleratorSupportedProfile* out) {
|
||||
@ -193,7 +193,7 @@ bool StructTraits<gpu::mojom::VideoDecodeAcceleratorSupportedProfile,
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<gpu::mojom::VideoDecodeAcceleratorCapabilities,
|
||||
bool StructTraits<gpu::mojom::VideoDecodeAcceleratorCapabilitiesDataView,
|
||||
gpu::VideoDecodeAcceleratorCapabilities>::
|
||||
Read(gpu::mojom::VideoDecodeAcceleratorCapabilitiesDataView data,
|
||||
gpu::VideoDecodeAcceleratorCapabilities* out) {
|
||||
@ -202,7 +202,7 @@ bool StructTraits<gpu::mojom::VideoDecodeAcceleratorCapabilities,
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfile,
|
||||
bool StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView,
|
||||
gpu::VideoEncodeAcceleratorSupportedProfile>::
|
||||
Read(gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView data,
|
||||
gpu::VideoEncodeAcceleratorSupportedProfile* out) {
|
||||
@ -212,7 +212,7 @@ bool StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfile,
|
||||
data.ReadMaxResolution(&out->max_resolution);
|
||||
}
|
||||
|
||||
bool StructTraits<gpu::mojom::GpuInfo, gpu::GPUInfo>::Read(
|
||||
bool StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo>::Read(
|
||||
gpu::mojom::GpuInfoDataView data,
|
||||
gpu::GPUInfo* out) {
|
||||
out->optimus = data.optimus();
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::GpuDevice, gpu::GPUInfo::GPUDevice> {
|
||||
struct StructTraits<gpu::mojom::GpuDeviceDataView, gpu::GPUInfo::GPUDevice> {
|
||||
static bool Read(gpu::mojom::GpuDeviceDataView data,
|
||||
gpu::GPUInfo::GPUDevice* out);
|
||||
|
||||
@ -60,7 +60,7 @@ struct EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::VideoDecodeAcceleratorSupportedProfile,
|
||||
struct StructTraits<gpu::mojom::VideoDecodeAcceleratorSupportedProfileDataView,
|
||||
gpu::VideoDecodeAcceleratorSupportedProfile> {
|
||||
static bool Read(
|
||||
gpu::mojom::VideoDecodeAcceleratorSupportedProfileDataView data,
|
||||
@ -88,7 +88,7 @@ struct StructTraits<gpu::mojom::VideoDecodeAcceleratorSupportedProfile,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::VideoDecodeAcceleratorCapabilities,
|
||||
struct StructTraits<gpu::mojom::VideoDecodeAcceleratorCapabilitiesDataView,
|
||||
gpu::VideoDecodeAcceleratorCapabilities> {
|
||||
static bool Read(gpu::mojom::VideoDecodeAcceleratorCapabilitiesDataView data,
|
||||
gpu::VideoDecodeAcceleratorCapabilities* out);
|
||||
@ -99,7 +99,7 @@ struct StructTraits<gpu::mojom::VideoDecodeAcceleratorCapabilities,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfile,
|
||||
struct StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView,
|
||||
gpu::VideoEncodeAcceleratorSupportedProfile> {
|
||||
static bool Read(
|
||||
gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView data,
|
||||
@ -127,7 +127,7 @@ struct StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfile,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::GpuInfo, gpu::GPUInfo> {
|
||||
struct StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo> {
|
||||
static bool Read(gpu::mojom::GpuInfoDataView data, gpu::GPUInfo* out);
|
||||
|
||||
static base::TimeDelta initialization_time(const gpu::GPUInfo& input) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::MailboxHolder, gpu::MailboxHolder> {
|
||||
struct StructTraits<gpu::mojom::MailboxHolderDataView, gpu::MailboxHolder> {
|
||||
static const gpu::Mailbox& mailbox(const gpu::MailboxHolder& holder) {
|
||||
return holder.mailbox;
|
||||
}
|
||||
|
@ -7,14 +7,14 @@
|
||||
namespace mojo {
|
||||
|
||||
// static
|
||||
MailboxName StructTraits<gpu::mojom::Mailbox, gpu::Mailbox>::name(
|
||||
MailboxName StructTraits<gpu::mojom::MailboxDataView, gpu::Mailbox>::name(
|
||||
const gpu::Mailbox& mailbox) {
|
||||
return {GL_MAILBOX_SIZE_CHROMIUM, GL_MAILBOX_SIZE_CHROMIUM,
|
||||
const_cast<int8_t*>(&mailbox.name[0])};
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<gpu::mojom::Mailbox, gpu::Mailbox>::Read(
|
||||
bool StructTraits<gpu::mojom::MailboxDataView, gpu::Mailbox>::Read(
|
||||
gpu::mojom::MailboxDataView data,
|
||||
gpu::Mailbox* out) {
|
||||
MailboxName mailbox_name = {0, GL_MAILBOX_SIZE_CHROMIUM, &out->name[0]};
|
||||
|
@ -16,7 +16,7 @@ namespace mojo {
|
||||
using MailboxName = CArray<int8_t>;
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::Mailbox, gpu::Mailbox> {
|
||||
struct StructTraits<gpu::mojom::MailboxDataView, gpu::Mailbox> {
|
||||
static MailboxName name(const gpu::Mailbox& mailbox);
|
||||
static bool Read(gpu::mojom::MailboxDataView data, gpu::Mailbox* out);
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::SyncToken, gpu::SyncToken> {
|
||||
struct StructTraits<gpu::mojom::SyncTokenDataView, gpu::SyncToken> {
|
||||
static bool verified_flush(const gpu::SyncToken& token) {
|
||||
return token.verified_flush();
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<media::mojom::PipelineStatistics,
|
||||
struct StructTraits<media::mojom::PipelineStatisticsDataView,
|
||||
media::PipelineStatistics> {
|
||||
static uint64_t audio_bytes_decoded(const media::PipelineStatistics& input) {
|
||||
return input.audio_bytes_decoded;
|
||||
@ -46,4 +46,4 @@ struct StructTraits<media::mojom::PipelineStatistics,
|
||||
|
||||
} // namespace mojo
|
||||
|
||||
#endif // MEDIA_MOJO_COMMON_PIPELINE_STATISTICS_STRUCT_TRAITS_H_
|
||||
#endif // MEDIA_MOJO_COMMON_PIPELINE_STATISTICS_STRUCT_TRAITS_H_
|
||||
|
@ -12,13 +12,13 @@ namespace mojo {
|
||||
|
||||
// static
|
||||
const std::vector<uint32_t>&
|
||||
StructTraits<mojo::common::mojom::Version, base::Version>::components(
|
||||
StructTraits<mojo::common::mojom::VersionDataView, base::Version>::components(
|
||||
const base::Version& version) {
|
||||
return version.components();
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<mojo::common::mojom::Version, base::Version>::Read(
|
||||
bool StructTraits<mojo::common::mojom::VersionDataView, base::Version>::Read(
|
||||
mojo::common::mojom::VersionDataView data,
|
||||
base::Version* out) {
|
||||
std::vector<uint32_t> components;
|
||||
|
@ -14,7 +14,7 @@ class Version;
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<mojo::common::mojom::Version, base::Version> {
|
||||
struct StructTraits<mojo::common::mojom::VersionDataView, base::Version> {
|
||||
static bool IsNull(const base::Version& version) {
|
||||
return !version.IsValid();
|
||||
}
|
||||
|
@ -8,7 +8,11 @@
|
||||
namespace mojo {
|
||||
|
||||
// This must be specialized for any type |T| to be serialized/deserialized as
|
||||
// a mojom struct of type |MojomType|.
|
||||
// a mojom struct. |DataViewType| is the corresponding data view type of the
|
||||
// mojom struct. For example, if the mojom struct is example.Foo,
|
||||
// |DataViewType| will be example::FooDataView, which can also be referred to by
|
||||
// example::Foo::DataView (in chromium) and example::blink::Foo::DataView (in
|
||||
// blink).
|
||||
//
|
||||
// Each specialization needs to implement a few things:
|
||||
// 1. Static getters for each field in the Mojom type. These should be
|
||||
@ -20,19 +24,22 @@ namespace mojo {
|
||||
// from |input|.
|
||||
//
|
||||
// Serializable form of a field:
|
||||
// Value or reference of the same type used in |MojomType|, or the
|
||||
// following alternatives:
|
||||
// Value or reference of the same type used in the generated stuct
|
||||
// wrapper type, or the following alternatives:
|
||||
// - string:
|
||||
// Value or reference of any type that has a StringTraits defined.
|
||||
// Supported by default: base::StringPiece, std::string.
|
||||
// Supported by default: base::StringPiece, std::string, mojo::String,
|
||||
// WTF::String (in blink).
|
||||
//
|
||||
// - array:
|
||||
// Value or reference of any type that has an ArrayTraits defined.
|
||||
// Supported by default: std::vector, WTF::Vector (in blink), CArray.
|
||||
// Supported by default: std::vector, CArray, mojo::Array, WTF::Vector
|
||||
// (in blink), mojo::WTFArray (in blink).
|
||||
//
|
||||
// - map:
|
||||
// Value or reference of any type that has a MapTraits defined.
|
||||
// Supported by default: std::map.
|
||||
// Supported by default: std::map, std::unordered_map, mojo::Map,
|
||||
// WTF::HashMap (in blink), mojo::WTFMap (in blink).
|
||||
//
|
||||
// - struct:
|
||||
// Value or reference of any type that has a StructTraits defined.
|
||||
@ -40,6 +47,10 @@ namespace mojo {
|
||||
// - enum:
|
||||
// Value of any type that has an EnumTraits defined.
|
||||
//
|
||||
// For any nullable string/struct/array/map/union field you could also
|
||||
// return value or reference of base::Optional<T>/WTF::Optional<T>, if T
|
||||
// has the right *Traits defined.
|
||||
//
|
||||
// During serialization, getters for string/struct/array/map/union fields
|
||||
// are called twice (one for size calculation and one for actual
|
||||
// serialization). If you want to return a value (as opposed to a
|
||||
@ -49,14 +60,13 @@ namespace mojo {
|
||||
// Getters for fields of other types are called once.
|
||||
//
|
||||
// 2. A static Read() method to set the contents of a |T| instance from a
|
||||
// |MojomType|DataView (e.g., if |MojomType| is test::Example, the data
|
||||
// view will be test::ExampleDataView).
|
||||
// DataViewType.
|
||||
//
|
||||
// static bool Read(|MojomType|DataView data, T* output);
|
||||
// static bool Read(DataViewType data, T* output);
|
||||
//
|
||||
// The generated |MojomType|DataView type provides a convenient,
|
||||
// inexpensive view of a serialized struct's field data. The caller
|
||||
// guarantees that |!data.is_null()|.
|
||||
// The generated DataViewType provides a convenient, inexpensive view of a
|
||||
// serialized struct's field data. The caller guarantees that
|
||||
// |!data.is_null()|.
|
||||
//
|
||||
// Returning false indicates invalid incoming data and causes the message
|
||||
// pipe receiving it to be disconnected. Therefore, you can do custom
|
||||
@ -112,9 +122,12 @@ namespace mojo {
|
||||
// reference/value to the Mojo bindings for serialization:
|
||||
// - if T is used in the "type_mappings" section of a typemap config file,
|
||||
// you need to declare it as pass-by-value:
|
||||
// type_mappings = [ "MojomType=T(pass_by_value)" ]
|
||||
// - if another type U's StructTraits has a getter for T, it needs to return
|
||||
// non-const reference/value.
|
||||
// type_mappings = [ "MojomType=T(move_only)" ]
|
||||
// or
|
||||
// type_mappings = [ "MojomType=T(copyable_pass_by_value)" ]
|
||||
//
|
||||
// - if another type U's StructTraits/UnionTraits has a getter for T, it
|
||||
// needs to return non-const reference/value.
|
||||
//
|
||||
// EXAMPLE:
|
||||
//
|
||||
@ -129,7 +142,7 @@ namespace mojo {
|
||||
//
|
||||
// StructTraits for Foo:
|
||||
// template <>
|
||||
// struct StructTraits<Foo, CustomFoo> {
|
||||
// struct StructTraits<FooDataView, CustomFoo> {
|
||||
// // Optional methods dealing with null:
|
||||
// static bool IsNull(const CustomFoo& input);
|
||||
// static void SetToNull(CustomFoo* output);
|
||||
@ -145,7 +158,7 @@ namespace mojo {
|
||||
// static bool Read(FooDataView data, CustomFoo* output);
|
||||
// };
|
||||
//
|
||||
template <typename MojomType, typename T>
|
||||
template <typename DataViewType, typename T>
|
||||
struct StructTraits;
|
||||
|
||||
} // namespace mojo
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<test::blink::TypemappedRect, test::RectBlink> {
|
||||
struct StructTraits<test::blink::TypemappedRectDataView, test::RectBlink> {
|
||||
static int x(const test::RectBlink& r) { return r.x(); }
|
||||
static int y(const test::RectBlink& r) { return r.y(); }
|
||||
static int width(const test::RectBlink& r) { return r.width(); }
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<test::TypemappedRect, test::RectChromium> {
|
||||
struct StructTraits<test::TypemappedRectDataView, test::RectChromium> {
|
||||
static int x(const test::RectChromium& r) { return r.x(); }
|
||||
static int y(const test::RectChromium& r) { return r.y(); }
|
||||
static int width(const test::RectChromium& r) { return r.width(); }
|
||||
|
@ -14,7 +14,7 @@ struct Context {
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
void* StructTraits<test::NestedStructWithTraits,
|
||||
void* StructTraits<test::NestedStructWithTraitsDataView,
|
||||
test::NestedStructWithTraitsImpl>::
|
||||
SetUpContext(const test::NestedStructWithTraitsImpl& input) {
|
||||
Context* context = new Context;
|
||||
@ -23,7 +23,7 @@ void* StructTraits<test::NestedStructWithTraits,
|
||||
}
|
||||
|
||||
// static
|
||||
void StructTraits<test::NestedStructWithTraits,
|
||||
void StructTraits<test::NestedStructWithTraitsDataView,
|
||||
test::NestedStructWithTraitsImpl>::
|
||||
TearDownContext(const test::NestedStructWithTraitsImpl& input,
|
||||
void* context) {
|
||||
@ -33,7 +33,7 @@ void StructTraits<test::NestedStructWithTraits,
|
||||
}
|
||||
|
||||
// static
|
||||
int32_t StructTraits<test::NestedStructWithTraits,
|
||||
int32_t StructTraits<test::NestedStructWithTraitsDataView,
|
||||
test::NestedStructWithTraitsImpl>::
|
||||
value(const test::NestedStructWithTraitsImpl& input, void* context) {
|
||||
Context* context_obj = static_cast<Context*>(context);
|
||||
@ -42,7 +42,7 @@ int32_t StructTraits<test::NestedStructWithTraits,
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<test::NestedStructWithTraits,
|
||||
bool StructTraits<test::NestedStructWithTraitsDataView,
|
||||
test::NestedStructWithTraitsImpl>::
|
||||
Read(test::NestedStructWithTraits::DataView data,
|
||||
test::NestedStructWithTraitsImpl* output) {
|
||||
@ -80,9 +80,9 @@ bool EnumTraits<test::EnumWithTraits, test::EnumWithTraitsImpl>::FromMojom(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<test::StructWithTraits, test::StructWithTraitsImpl>::Read(
|
||||
test::StructWithTraits::DataView data,
|
||||
test::StructWithTraitsImpl* out) {
|
||||
bool StructTraits<test::StructWithTraitsDataView, test::StructWithTraitsImpl>::
|
||||
Read(test::StructWithTraits::DataView data,
|
||||
test::StructWithTraitsImpl* out) {
|
||||
test::EnumWithTraitsImpl f_enum;
|
||||
if (!data.ReadFEnum(&f_enum))
|
||||
return false;
|
||||
@ -126,7 +126,7 @@ bool StructTraits<test::StructWithTraits, test::StructWithTraitsImpl>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<test::MoveOnlyStructWithTraits,
|
||||
bool StructTraits<test::MoveOnlyStructWithTraitsDataView,
|
||||
test::MoveOnlyStructWithTraitsImpl>::
|
||||
Read(test::MoveOnlyStructWithTraits::DataView data,
|
||||
test::MoveOnlyStructWithTraitsImpl* out) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<test::NestedStructWithTraits,
|
||||
struct StructTraits<test::NestedStructWithTraitsDataView,
|
||||
test::NestedStructWithTraitsImpl> {
|
||||
static void* SetUpContext(const test::NestedStructWithTraitsImpl& input);
|
||||
static void TearDownContext(const test::NestedStructWithTraitsImpl& input,
|
||||
@ -27,7 +27,7 @@ struct StructTraits<test::NestedStructWithTraits,
|
||||
static int32_t value(const test::NestedStructWithTraitsImpl& input,
|
||||
void* context);
|
||||
|
||||
static bool Read(test::NestedStructWithTraits::DataView data,
|
||||
static bool Read(test::NestedStructWithTraitsDataView data,
|
||||
test::NestedStructWithTraitsImpl* output);
|
||||
};
|
||||
|
||||
@ -39,9 +39,10 @@ struct EnumTraits<test::EnumWithTraits, test::EnumWithTraitsImpl> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> {
|
||||
struct StructTraits<test::StructWithTraitsDataView,
|
||||
test::StructWithTraitsImpl> {
|
||||
// Deserialization to test::StructTraitsImpl.
|
||||
static bool Read(test::StructWithTraits::DataView data,
|
||||
static bool Read(test::StructWithTraitsDataView data,
|
||||
test::StructWithTraitsImpl* out);
|
||||
|
||||
// Fields in test::StructWithTraits.
|
||||
@ -98,10 +99,10 @@ struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<test::TrivialStructWithTraits,
|
||||
struct StructTraits<test::TrivialStructWithTraitsDataView,
|
||||
test::TrivialStructWithTraitsImpl> {
|
||||
// Deserialization to test::TrivialStructTraitsImpl.
|
||||
static bool Read(test::TrivialStructWithTraits::DataView data,
|
||||
static bool Read(test::TrivialStructWithTraitsDataView data,
|
||||
test::TrivialStructWithTraitsImpl* out) {
|
||||
out->value = data.value();
|
||||
return true;
|
||||
@ -115,10 +116,10 @@ struct StructTraits<test::TrivialStructWithTraits,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<test::MoveOnlyStructWithTraits,
|
||||
struct StructTraits<test::MoveOnlyStructWithTraitsDataView,
|
||||
test::MoveOnlyStructWithTraitsImpl> {
|
||||
// Deserialization to test::MoveOnlyStructTraitsImpl.
|
||||
static bool Read(test::MoveOnlyStructWithTraits::DataView data,
|
||||
static bool Read(test::MoveOnlyStructWithTraitsDataView data,
|
||||
test::MoveOnlyStructWithTraitsImpl* out);
|
||||
|
||||
// Fields in test::MoveOnlyStructWithTraits.
|
||||
@ -129,13 +130,14 @@ struct StructTraits<test::MoveOnlyStructWithTraits,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<test::StructWithTraitsForUniquePtr, std::unique_ptr<int>> {
|
||||
struct StructTraits<test::StructWithTraitsForUniquePtrDataView,
|
||||
std::unique_ptr<int>> {
|
||||
static bool IsNull(const std::unique_ptr<int>& data) { return !data; }
|
||||
static void SetToNull(std::unique_ptr<int>* data) { data->reset(); }
|
||||
|
||||
static int f_int32(const std::unique_ptr<int>& data) { return *data; }
|
||||
|
||||
static bool Read(test::StructWithTraitsForUniquePtr::DataView data,
|
||||
static bool Read(test::StructWithTraitsForUniquePtrDataView data,
|
||||
std::unique_ptr<int>* out) {
|
||||
out->reset(new int(data.f_int32()));
|
||||
return true;
|
||||
@ -143,7 +145,7 @@ struct StructTraits<test::StructWithTraitsForUniquePtr, std::unique_ptr<int>> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct UnionTraits<test::UnionWithTraits,
|
||||
struct UnionTraits<test::UnionWithTraitsDataView,
|
||||
std::unique_ptr<test::UnionWithTraitsBase>> {
|
||||
static bool IsNull(const std::unique_ptr<test::UnionWithTraitsBase>& data) {
|
||||
return !data;
|
||||
@ -152,12 +154,12 @@ struct UnionTraits<test::UnionWithTraits,
|
||||
data->reset();
|
||||
}
|
||||
|
||||
static test::UnionWithTraits::DataView::Tag GetTag(
|
||||
static test::UnionWithTraitsDataView::Tag GetTag(
|
||||
const std::unique_ptr<test::UnionWithTraitsBase>& data) {
|
||||
if (data->type() == test::UnionWithTraitsBase::Type::INT32)
|
||||
return test::UnionWithTraits::DataView::Tag::F_INT32;
|
||||
return test::UnionWithTraitsDataView::Tag::F_INT32;
|
||||
|
||||
return test::UnionWithTraits::DataView::Tag::F_STRUCT;
|
||||
return test::UnionWithTraitsDataView::Tag::F_STRUCT;
|
||||
}
|
||||
|
||||
static int32_t f_int32(
|
||||
@ -170,14 +172,14 @@ struct UnionTraits<test::UnionWithTraits,
|
||||
return static_cast<test::UnionWithTraitsStruct*>(data.get())->get_struct();
|
||||
}
|
||||
|
||||
static bool Read(test::UnionWithTraits::DataView data,
|
||||
static bool Read(test::UnionWithTraitsDataView data,
|
||||
std::unique_ptr<test::UnionWithTraitsBase>* out) {
|
||||
switch (data.tag()) {
|
||||
case test::UnionWithTraits::DataView::Tag::F_INT32: {
|
||||
case test::UnionWithTraitsDataView::Tag::F_INT32: {
|
||||
out->reset(new test::UnionWithTraitsInt32(data.f_int32()));
|
||||
return true;
|
||||
}
|
||||
case test::UnionWithTraits::DataView::Tag::F_STRUCT: {
|
||||
case test::UnionWithTraitsDataView::Tag::F_STRUCT: {
|
||||
auto* struct_object = new test::UnionWithTraitsStruct();
|
||||
out->reset(struct_object);
|
||||
return data.ReadFStruct(&struct_object->get_mutable_struct());
|
||||
|
@ -8,7 +8,11 @@
|
||||
namespace mojo {
|
||||
|
||||
// This must be specialized for any type |T| to be serialized/deserialized as
|
||||
// a mojom union of type |MojomType|.
|
||||
// a mojom union. |DataViewType| is the corresponding data view type of the
|
||||
// mojom union. For example, if the mojom union is example.Foo, |DataViewType|
|
||||
// will be example::FooDataView, which can also be referred to by
|
||||
// example::Foo::DataView (in chromium) and example::blink::Foo::DataView (in
|
||||
// blink).
|
||||
//
|
||||
// Similar to StructTraits, each specialization of UnionTraits implements the
|
||||
// following methods:
|
||||
@ -22,12 +26,12 @@ namespace mojo {
|
||||
// 5. A static GetTag() method indicating which field is the current active
|
||||
// field for serialization:
|
||||
//
|
||||
// static |MojomType|DataView::Tag GetTag(const T& input);
|
||||
// static DataViewType::Tag GetTag(const T& input);
|
||||
//
|
||||
// During serialization, only the field getter corresponding to this tag
|
||||
// will be called.
|
||||
//
|
||||
template <typename MojomType, typename T>
|
||||
template <typename DataViewType, typename T>
|
||||
struct UnionTraits;
|
||||
|
||||
} // namespace mojo
|
||||
|
@ -84,10 +84,10 @@ class {{struct.name}}DataView {
|
||||
}
|
||||
|
||||
{%- else %}
|
||||
{{kind|cpp_wrapper_type}} {{name}}() const {
|
||||
{{kind|cpp_field_type}} {{name}}() const {
|
||||
{%- if pf.min_version != 0 %}
|
||||
if (data_->header_.version < {{pf.min_version}})
|
||||
return {{kind|cpp_wrapper_type}}{};
|
||||
return {{kind|cpp_field_type}}{};
|
||||
{%- endif %}
|
||||
return data_->{{name}};
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
{%- set data_type = struct|get_qualified_name_for_kind(internal=True) %}
|
||||
|
||||
template <>
|
||||
struct {{export_attribute}} StructTraits<{{mojom_type}}, {{mojom_type}}Ptr> {
|
||||
struct {{export_attribute}} StructTraits<{{mojom_type}}::DataView, {{mojom_type}}Ptr> {
|
||||
static bool IsNull(const {{mojom_type}}Ptr& input) { return !input; }
|
||||
static void SetToNull({{mojom_type}}Ptr* output) { output->reset(); }
|
||||
|
||||
@ -23,7 +23,7 @@ struct {{export_attribute}} StructTraits<{{mojom_type}}, {{mojom_type}}Ptr> {
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
static bool Read({{mojom_type}}DataView input, {{mojom_type}}Ptr* output);
|
||||
static bool Read({{mojom_type}}::DataView input, {{mojom_type}}Ptr* output);
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
@ -31,7 +31,7 @@ namespace internal {
|
||||
template <typename MaybeConstUserType>
|
||||
struct Serializer<{{mojom_type}}Ptr, MaybeConstUserType> {
|
||||
using UserType = typename std::remove_const<MaybeConstUserType>::type;
|
||||
using Traits = StructTraits<{{mojom_type}}, UserType>;
|
||||
using Traits = StructTraits<{{mojom_type}}::DataView, UserType>;
|
||||
|
||||
static size_t PrepareToSerialize(MaybeConstUserType& input,
|
||||
SerializationContext* context) {
|
||||
@ -73,7 +73,7 @@ struct Serializer<{{mojom_type}}Ptr, MaybeConstUserType> {
|
||||
if (!input)
|
||||
return CallSetToNullIfExists<Traits>(output);
|
||||
|
||||
{{mojom_type}}DataView data_view(input, context);
|
||||
{{mojom_type}}::DataView data_view(input, context);
|
||||
return Traits::Read(data_view, output);
|
||||
}
|
||||
};
|
||||
|
@ -2,8 +2,8 @@
|
||||
{%- set mojom_type = struct|get_qualified_name_for_kind %}
|
||||
|
||||
// static
|
||||
bool StructTraits<{{mojom_type}}, {{mojom_type}}Ptr>::Read(
|
||||
{{mojom_type}}DataView input,
|
||||
bool StructTraits<{{mojom_type}}::DataView, {{mojom_type}}Ptr>::Read(
|
||||
{{mojom_type}}::DataView input,
|
||||
{{mojom_type}}Ptr* output) {
|
||||
bool success = true;
|
||||
{{mojom_type}}Ptr result({{mojom_type}}::New());
|
||||
|
@ -2,7 +2,8 @@
|
||||
{%- set data_type = union|get_qualified_name_for_kind(internal=True) %}
|
||||
|
||||
template <>
|
||||
struct {{export_attribute}} UnionTraits<{{mojom_type}}, {{mojom_type}}Ptr> {
|
||||
struct {{export_attribute}} UnionTraits<{{mojom_type}}::DataView,
|
||||
{{mojom_type}}Ptr> {
|
||||
static bool IsNull(const {{mojom_type}}Ptr& input) { return !input; }
|
||||
static void SetToNull({{mojom_type}}Ptr* output) { output->reset(); }
|
||||
|
||||
@ -26,7 +27,7 @@ struct {{export_attribute}} UnionTraits<{{mojom_type}}, {{mojom_type}}Ptr> {
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
static bool Read({{mojom_type}}DataView input, {{mojom_type}}Ptr* output);
|
||||
static bool Read({{mojom_type}}::DataView input, {{mojom_type}}Ptr* output);
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
@ -34,7 +35,7 @@ namespace internal {
|
||||
template <typename MaybeConstUserType>
|
||||
struct Serializer<{{mojom_type}}Ptr, MaybeConstUserType> {
|
||||
using UserType = typename std::remove_const<MaybeConstUserType>::type;
|
||||
using Traits = UnionTraits<{{mojom_type}}, UserType>;
|
||||
using Traits = UnionTraits<{{mojom_type}}::DataView, UserType>;
|
||||
|
||||
static size_t PrepareToSerialize(MaybeConstUserType& input,
|
||||
bool inlined,
|
||||
@ -161,7 +162,7 @@ struct Serializer<{{mojom_type}}Ptr, MaybeConstUserType> {
|
||||
if (!input || input->is_null())
|
||||
return CallSetToNullIfExists<Traits>(output);
|
||||
|
||||
{{mojom_type}}DataView data_view(input, context);
|
||||
{{mojom_type}}::DataView data_view(input, context);
|
||||
return Traits::Read(data_view, output);
|
||||
}
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
{%- set mojom_type = union|get_qualified_name_for_kind %}
|
||||
|
||||
// static
|
||||
bool UnionTraits<{{mojom_type}}, {{mojom_type}}Ptr>::Read(
|
||||
{{mojom_type}}DataView input,
|
||||
bool UnionTraits<{{mojom_type}}::DataView, {{mojom_type}}Ptr>::Read(
|
||||
{{mojom_type}}::DataView input,
|
||||
{{mojom_type}}Ptr* output) {
|
||||
*output = {{mojom_type}}::New();
|
||||
{{mojom_type}}Ptr& result = *output;
|
||||
|
@ -11,7 +11,8 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<shell::mojom::CapabilityRequest, shell::CapabilityRequest> {
|
||||
struct StructTraits<shell::mojom::CapabilityRequest::DataView,
|
||||
shell::CapabilityRequest> {
|
||||
static const shell::Classes& classes(
|
||||
const shell::CapabilityRequest& request) {
|
||||
return request.classes;
|
||||
@ -44,7 +45,8 @@ struct StructTraits<shell::mojom::CapabilityRequest, shell::CapabilityRequest> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<shell::mojom::CapabilitySpec, shell::CapabilitySpec> {
|
||||
struct StructTraits<shell::mojom::CapabilitySpec::DataView,
|
||||
shell::CapabilitySpec> {
|
||||
static const std::map<shell::Class, shell::Interfaces>& provided(
|
||||
const shell::CapabilitySpec& spec) {
|
||||
return spec.provided;
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<shell::mojom::Identity, shell::Identity> {
|
||||
struct StructTraits<shell::mojom::IdentityDataView, shell::Identity> {
|
||||
static const std::string& name(const shell::Identity& identity) {
|
||||
return identity.name();
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ bool EnumTraits<display::mojom::TouchSupport, display::Display::TouchSupport>::
|
||||
return display::Display::TOUCH_SUPPORT_UNKNOWN;
|
||||
}
|
||||
|
||||
bool StructTraits<display::mojom::Display, display::Display>::Read(
|
||||
bool StructTraits<display::mojom::DisplayDataView, display::Display>::Read(
|
||||
display::mojom::DisplayDataView data,
|
||||
display::Display* out) {
|
||||
out->set_id(data.id());
|
||||
|
@ -27,7 +27,7 @@ struct EnumTraits<display::mojom::TouchSupport,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<display::mojom::Display, display::Display> {
|
||||
struct StructTraits<display::mojom::DisplayDataView, display::Display> {
|
||||
static int64_t id(const display::Display& display) { return display.id(); }
|
||||
|
||||
static const gfx::Rect& bounds(const display::Display& display) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<skia::mojom::BitmapArray, std::vector<SkBitmap>> {
|
||||
struct StructTraits<skia::mojom::BitmapArrayDataView, std::vector<SkBitmap>> {
|
||||
static const std::vector<SkBitmap>& bitmaps(
|
||||
const std::vector<SkBitmap>& bitmaps) {
|
||||
return bitmaps;
|
||||
@ -27,4 +27,4 @@ struct StructTraits<skia::mojom::BitmapArray, std::vector<SkBitmap>> {
|
||||
|
||||
} // namespace mojo
|
||||
|
||||
#endif // SKIA_PUBLIC_INTERFACES_BITMAP_ARRAY_STRUCT_TRAITS_H_
|
||||
#endif // SKIA_PUBLIC_INTERFACES_BITMAP_ARRAY_STRUCT_TRAITS_H_
|
||||
|
@ -107,52 +107,56 @@ skia::mojom::ColorProfileType SkColorSpaceToMojo(SkColorSpace* cs) {
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
bool StructTraits<skia::mojom::Bitmap, SkBitmap>::IsNull(const SkBitmap& b) {
|
||||
bool StructTraits<skia::mojom::BitmapDataView, SkBitmap>::IsNull(
|
||||
const SkBitmap& b) {
|
||||
return b.isNull();
|
||||
}
|
||||
|
||||
// static
|
||||
void StructTraits<skia::mojom::Bitmap, SkBitmap>::SetToNull(SkBitmap* b) {
|
||||
void StructTraits<skia::mojom::BitmapDataView, SkBitmap>::SetToNull(
|
||||
SkBitmap* b) {
|
||||
b->reset();
|
||||
}
|
||||
|
||||
// static
|
||||
skia::mojom::ColorType StructTraits<skia::mojom::Bitmap, SkBitmap>::color_type(
|
||||
const SkBitmap& b) {
|
||||
skia::mojom::ColorType StructTraits<skia::mojom::BitmapDataView,
|
||||
SkBitmap>::color_type(const SkBitmap& b) {
|
||||
return SkColorTypeToMojo(b.colorType());
|
||||
}
|
||||
|
||||
// static
|
||||
skia::mojom::AlphaType StructTraits<skia::mojom::Bitmap, SkBitmap>::alpha_type(
|
||||
const SkBitmap& b) {
|
||||
skia::mojom::AlphaType StructTraits<skia::mojom::BitmapDataView,
|
||||
SkBitmap>::alpha_type(const SkBitmap& b) {
|
||||
return SkAlphaTypeToMojo(b.alphaType());
|
||||
}
|
||||
|
||||
// static
|
||||
skia::mojom::ColorProfileType
|
||||
StructTraits<skia::mojom::Bitmap, SkBitmap>::profile_type(const SkBitmap& b) {
|
||||
StructTraits<skia::mojom::BitmapDataView, SkBitmap>::profile_type(
|
||||
const SkBitmap& b) {
|
||||
return SkColorSpaceToMojo(b.colorSpace());
|
||||
}
|
||||
|
||||
// static
|
||||
uint32_t StructTraits<skia::mojom::Bitmap, SkBitmap>::width(const SkBitmap& b) {
|
||||
uint32_t StructTraits<skia::mojom::BitmapDataView, SkBitmap>::width(
|
||||
const SkBitmap& b) {
|
||||
return b.width() < 0 ? 0 : static_cast<uint32_t>(b.width());
|
||||
}
|
||||
|
||||
// static
|
||||
uint32_t StructTraits<skia::mojom::Bitmap, SkBitmap>::height(
|
||||
uint32_t StructTraits<skia::mojom::BitmapDataView, SkBitmap>::height(
|
||||
const SkBitmap& b) {
|
||||
return b.height() < 0 ? 0 : static_cast<uint32_t>(b.height());
|
||||
}
|
||||
|
||||
// static
|
||||
BitmapBuffer StructTraits<skia::mojom::Bitmap, SkBitmap>::pixel_data(
|
||||
BitmapBuffer StructTraits<skia::mojom::BitmapDataView, SkBitmap>::pixel_data(
|
||||
const SkBitmap& b) {
|
||||
return {b.getSize(), b.getSize(), static_cast<uint8_t*>(b.getPixels())};
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<skia::mojom::Bitmap, SkBitmap>::Read(
|
||||
bool StructTraits<skia::mojom::BitmapDataView, SkBitmap>::Read(
|
||||
skia::mojom::BitmapDataView data,
|
||||
SkBitmap* b) {
|
||||
// TODO: Ensure width and height are reasonable, eg. <= kMaxBitmapSize?
|
||||
@ -186,14 +190,14 @@ bool StructTraits<skia::mojom::Bitmap, SkBitmap>::Read(
|
||||
}
|
||||
|
||||
// static
|
||||
void* StructTraits<skia::mojom::Bitmap, SkBitmap>::SetUpContext(
|
||||
void* StructTraits<skia::mojom::BitmapDataView, SkBitmap>::SetUpContext(
|
||||
const SkBitmap& b) {
|
||||
b.lockPixels();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
void StructTraits<skia::mojom::Bitmap, SkBitmap>::TearDownContext(
|
||||
void StructTraits<skia::mojom::BitmapDataView, SkBitmap>::TearDownContext(
|
||||
const SkBitmap& b,
|
||||
void* context) {
|
||||
b.unlockPixels();
|
||||
|
@ -16,7 +16,7 @@ using BitmapBuffer = CArray<uint8_t>;
|
||||
|
||||
// Struct traits to use SkBitmap for skia::mojom::Bitmap in Chrome C++ code.
|
||||
template <>
|
||||
struct StructTraits<skia::mojom::Bitmap, SkBitmap> {
|
||||
struct StructTraits<skia::mojom::BitmapDataView, SkBitmap> {
|
||||
static bool IsNull(const SkBitmap& b);
|
||||
static void SetToNull(SkBitmap* b);
|
||||
static skia::mojom::ColorType color_type(const SkBitmap& b);
|
||||
|
@ -31,7 +31,7 @@ struct ArrayTraits<ImageFilterBuffer> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<skia::mojom::ImageFilter, sk_sp<SkImageFilter>> {
|
||||
struct StructTraits<skia::mojom::ImageFilterDataView, sk_sp<SkImageFilter>> {
|
||||
static ImageFilterBuffer data(const sk_sp<SkImageFilter>& filter) {
|
||||
ImageFilterBuffer buffer;
|
||||
buffer.data = sk_sp<SkData>(SkValidatingSerializeFlattenable(filter.get()));
|
||||
|
@ -13,7 +13,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<url::mojom::blink::Url, ::blink::KURL> {
|
||||
struct StructTraits<url::mojom::blink::Url::DataView, ::blink::KURL> {
|
||||
static WTF::String url(const ::blink::KURL& blinkUrl)
|
||||
{
|
||||
if (!blinkUrl.isValid() || blinkUrl.getString().length() > url::kMaxURLChars) {
|
||||
@ -22,7 +22,7 @@ struct StructTraits<url::mojom::blink::Url, ::blink::KURL> {
|
||||
|
||||
return blinkUrl.getString();
|
||||
}
|
||||
static bool Read(url::mojom::blink::UrlDataView data, ::blink::KURL* out)
|
||||
static bool Read(url::mojom::blink::Url::DataView data, ::blink::KURL* out)
|
||||
{
|
||||
WTF::String urlString;
|
||||
if (!data.ReadUrl(&urlString))
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<url::mojom::blink::Origin, RefPtr<::blink::SecurityOrigin>> {
|
||||
struct StructTraits<url::mojom::blink::Origin::DataView, RefPtr<::blink::SecurityOrigin>> {
|
||||
static WTF::String scheme(const RefPtr<::blink::SecurityOrigin>& origin)
|
||||
{
|
||||
return origin->protocol();
|
||||
@ -29,7 +29,7 @@ struct StructTraits<url::mojom::blink::Origin, RefPtr<::blink::SecurityOrigin>>
|
||||
{
|
||||
return origin->isUnique();
|
||||
}
|
||||
static bool Read(url::mojom::blink::OriginDataView data, RefPtr<::blink::SecurityOrigin>* out)
|
||||
static bool Read(url::mojom::blink::Origin::DataView data, RefPtr<::blink::SecurityOrigin>* out)
|
||||
{
|
||||
if (data.unique()) {
|
||||
*out = ::blink::SecurityOrigin::createUnique();
|
||||
|
@ -19,7 +19,7 @@ namespace display {
|
||||
|
||||
#if !defined(OS_IOS)
|
||||
namespace mojom {
|
||||
class Display;
|
||||
class DisplayDataView;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -186,7 +186,8 @@ class DISPLAY_EXPORT Display final {
|
||||
int depth_per_component_;
|
||||
|
||||
#if !defined(OS_IOS)
|
||||
friend struct mojo::StructTraits<display::mojom::Display, display::Display>;
|
||||
friend struct mojo::StructTraits<display::mojom::DisplayDataView,
|
||||
display::Display>;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ bool EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType>::FromMojom(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StructTraits<ui::mojom::InputDevice, ui::InputDevice>::Read(
|
||||
bool StructTraits<ui::mojom::InputDeviceDataView, ui::InputDevice>::Read(
|
||||
ui::mojom::InputDeviceDataView data,
|
||||
ui::InputDevice* out) {
|
||||
out->id = data.id();
|
||||
@ -96,9 +96,9 @@ bool EnumTraits<ui::mojom::StylusState, ui::StylusState>::FromMojom(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StructTraits<ui::mojom::TouchscreenDevice, ui::TouchscreenDevice>::Read(
|
||||
ui::mojom::TouchscreenDeviceDataView data,
|
||||
ui::TouchscreenDevice* out) {
|
||||
bool StructTraits<ui::mojom::TouchscreenDeviceDataView, ui::TouchscreenDevice>::
|
||||
Read(ui::mojom::TouchscreenDeviceDataView data,
|
||||
ui::TouchscreenDevice* out) {
|
||||
if (!data.ReadInputDevice(static_cast<ui::InputDevice*>(out)))
|
||||
return false;
|
||||
|
||||
|
@ -23,7 +23,7 @@ struct EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<ui::mojom::InputDevice, ui::InputDevice> {
|
||||
struct StructTraits<ui::mojom::InputDeviceDataView, ui::InputDevice> {
|
||||
static int32_t id(const ui::InputDevice& device) { return device.id; }
|
||||
|
||||
static ui::InputDeviceType type(const ui::InputDevice& device) {
|
||||
@ -56,7 +56,8 @@ struct EnumTraits<ui::mojom::StylusState, ui::StylusState> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<ui::mojom::TouchscreenDevice, ui::TouchscreenDevice> {
|
||||
struct StructTraits<ui::mojom::TouchscreenDeviceDataView,
|
||||
ui::TouchscreenDevice> {
|
||||
static const ui::InputDevice& input_device(
|
||||
const ui::TouchscreenDevice& device) {
|
||||
return static_cast<const ui::InputDevice&>(device);
|
||||
|
@ -27,7 +27,7 @@ namespace ui {
|
||||
|
||||
#if !defined(OS_IOS)
|
||||
namespace mojom {
|
||||
class LatencyInfo;
|
||||
class LatencyInfoDataView;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -238,7 +238,8 @@ class EVENTS_BASE_EXPORT LatencyInfo {
|
||||
|
||||
#if !defined(OS_IOS)
|
||||
friend struct IPC::ParamTraits<ui::LatencyInfo>;
|
||||
friend struct mojo::StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>;
|
||||
friend struct mojo::StructTraits<ui::mojom::LatencyInfoDataView,
|
||||
ui::LatencyInfo>;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1,2 +1,5 @@
|
||||
per-file *.mojom=set noparent
|
||||
per-file *.mojom=file://ipc/SECURITY_OWNERS
|
||||
|
||||
per-file *_struct_traits*.*=set noparent
|
||||
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
|
@ -118,22 +118,24 @@ static_assert(ui::mojom::kEventFlagForwardMouseButton ==
|
||||
static_cast<int32_t>(ui::EF_FORWARD_MOUSE_BUTTON),
|
||||
"EVENT_FLAGS must match");
|
||||
|
||||
ui::mojom::EventType StructTraits<ui::mojom::Event, EventUniquePtr>::action(
|
||||
ui::mojom::EventType
|
||||
StructTraits<ui::mojom::EventDataView, EventUniquePtr>::action(
|
||||
const EventUniquePtr& event) {
|
||||
return UIEventTypeToMojo(event->type());
|
||||
}
|
||||
|
||||
int32_t StructTraits<ui::mojom::Event, EventUniquePtr>::flags(
|
||||
int32_t StructTraits<ui::mojom::EventDataView, EventUniquePtr>::flags(
|
||||
const EventUniquePtr& event) {
|
||||
return event->flags();
|
||||
}
|
||||
|
||||
int64_t StructTraits<ui::mojom::Event, EventUniquePtr>::time_stamp(
|
||||
int64_t StructTraits<ui::mojom::EventDataView, EventUniquePtr>::time_stamp(
|
||||
const EventUniquePtr& event) {
|
||||
return event->time_stamp().ToInternalValue();
|
||||
}
|
||||
|
||||
ui::mojom::KeyDataPtr StructTraits<ui::mojom::Event, EventUniquePtr>::key_data(
|
||||
ui::mojom::KeyDataPtr
|
||||
StructTraits<ui::mojom::EventDataView, EventUniquePtr>::key_data(
|
||||
const EventUniquePtr& event) {
|
||||
if (!event->IsKeyEvent())
|
||||
return nullptr;
|
||||
@ -154,7 +156,7 @@ ui::mojom::KeyDataPtr StructTraits<ui::mojom::Event, EventUniquePtr>::key_data(
|
||||
}
|
||||
|
||||
ui::mojom::PointerDataPtr
|
||||
StructTraits<ui::mojom::Event, EventUniquePtr>::pointer_data(
|
||||
StructTraits<ui::mojom::EventDataView, EventUniquePtr>::pointer_data(
|
||||
const EventUniquePtr& event) {
|
||||
if (!event->IsPointerEvent() && !event->IsMouseWheelEvent())
|
||||
return nullptr;
|
||||
@ -232,7 +234,7 @@ StructTraits<ui::mojom::Event, EventUniquePtr>::pointer_data(
|
||||
return pointer_data;
|
||||
}
|
||||
|
||||
bool StructTraits<ui::mojom::Event, EventUniquePtr>::Read(
|
||||
bool StructTraits<ui::mojom::EventDataView, EventUniquePtr>::Read(
|
||||
ui::mojom::EventDataView event,
|
||||
EventUniquePtr* out) {
|
||||
switch (event.action()) {
|
||||
|
@ -16,7 +16,7 @@ namespace mojo {
|
||||
using EventUniquePtr = std::unique_ptr<ui::Event>;
|
||||
|
||||
template <>
|
||||
struct StructTraits<ui::mojom::Event, EventUniquePtr> {
|
||||
struct StructTraits<ui::mojom::EventDataView, EventUniquePtr> {
|
||||
static ui::mojom::EventType action(const EventUniquePtr& event);
|
||||
static int32_t flags(const EventUniquePtr& event);
|
||||
static int64_t time_stamp(const EventUniquePtr& event);
|
||||
|
@ -179,28 +179,28 @@ ui::LatencyComponentType MojoLatencyComponentTypeToUI(
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
int64_t
|
||||
StructTraits<ui::mojom::LatencyComponent, ui::LatencyInfo::LatencyComponent>::
|
||||
int64_t StructTraits<ui::mojom::LatencyComponentDataView,
|
||||
ui::LatencyInfo::LatencyComponent>::
|
||||
sequence_number(const ui::LatencyInfo::LatencyComponent& component) {
|
||||
return component.sequence_number;
|
||||
}
|
||||
|
||||
// static
|
||||
base::TimeTicks
|
||||
StructTraits<ui::mojom::LatencyComponent, ui::LatencyInfo::LatencyComponent>::
|
||||
base::TimeTicks StructTraits<ui::mojom::LatencyComponentDataView,
|
||||
ui::LatencyInfo::LatencyComponent>::
|
||||
event_time(const ui::LatencyInfo::LatencyComponent& component) {
|
||||
return component.event_time;
|
||||
}
|
||||
|
||||
// static
|
||||
uint32_t
|
||||
StructTraits<ui::mojom::LatencyComponent, ui::LatencyInfo::LatencyComponent>::
|
||||
uint32_t StructTraits<ui::mojom::LatencyComponentDataView,
|
||||
ui::LatencyInfo::LatencyComponent>::
|
||||
event_count(const ui::LatencyInfo::LatencyComponent& component) {
|
||||
return component.event_count;
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<ui::mojom::LatencyComponent,
|
||||
bool StructTraits<ui::mojom::LatencyComponentDataView,
|
||||
ui::LatencyInfo::LatencyComponent>::
|
||||
Read(ui::mojom::LatencyComponentDataView data,
|
||||
ui::LatencyInfo::LatencyComponent* out) {
|
||||
@ -213,21 +213,21 @@ bool StructTraits<ui::mojom::LatencyComponent,
|
||||
|
||||
// static
|
||||
ui::mojom::LatencyComponentType
|
||||
StructTraits<ui::mojom::LatencyComponentId,
|
||||
StructTraits<ui::mojom::LatencyComponentIdDataView,
|
||||
std::pair<ui::LatencyComponentType, int64_t>>::
|
||||
type(const std::pair<ui::LatencyComponentType, int64_t>& id) {
|
||||
return UILatencyComponentTypeToMojo(id.first);
|
||||
}
|
||||
|
||||
// static
|
||||
int64_t StructTraits<ui::mojom::LatencyComponentId,
|
||||
int64_t StructTraits<ui::mojom::LatencyComponentIdDataView,
|
||||
std::pair<ui::LatencyComponentType, int64_t>>::
|
||||
id(const std::pair<ui::LatencyComponentType, int64_t>& id) {
|
||||
return id.second;
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<ui::mojom::LatencyComponentId,
|
||||
bool StructTraits<ui::mojom::LatencyComponentIdDataView,
|
||||
std::pair<ui::LatencyComponentType, int64_t>>::
|
||||
Read(ui::mojom::LatencyComponentIdDataView data,
|
||||
std::pair<ui::LatencyComponentType, int64_t>* out) {
|
||||
@ -238,39 +238,39 @@ bool StructTraits<ui::mojom::LatencyComponentId,
|
||||
|
||||
// static
|
||||
const std::string&
|
||||
StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::trace_name(
|
||||
StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::trace_name(
|
||||
const ui::LatencyInfo& info) {
|
||||
return info.trace_name_;
|
||||
}
|
||||
|
||||
const ui::LatencyInfo::LatencyMap&
|
||||
StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::latency_components(
|
||||
const ui::LatencyInfo& info) {
|
||||
StructTraits<ui::mojom::LatencyInfoDataView,
|
||||
ui::LatencyInfo>::latency_components(const ui::LatencyInfo& info) {
|
||||
return info.latency_components();
|
||||
}
|
||||
InputCoordinateArray
|
||||
StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::input_coordinates(
|
||||
const ui::LatencyInfo& info) {
|
||||
StructTraits<ui::mojom::LatencyInfoDataView,
|
||||
ui::LatencyInfo>::input_coordinates(const ui::LatencyInfo& info) {
|
||||
return {info.input_coordinates_size_, ui::LatencyInfo::kMaxInputCoordinates,
|
||||
const_cast<gfx::PointF*>(info.input_coordinates_)};
|
||||
}
|
||||
|
||||
int64_t StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::trace_id(
|
||||
int64_t StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::trace_id(
|
||||
const ui::LatencyInfo& info) {
|
||||
return info.trace_id();
|
||||
}
|
||||
|
||||
bool StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::coalesced(
|
||||
bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::coalesced(
|
||||
const ui::LatencyInfo& info) {
|
||||
return info.coalesced();
|
||||
}
|
||||
|
||||
bool StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::terminated(
|
||||
bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::terminated(
|
||||
const ui::LatencyInfo& info) {
|
||||
return info.terminated();
|
||||
}
|
||||
|
||||
bool StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::Read(
|
||||
bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::Read(
|
||||
ui::mojom::LatencyInfoDataView data,
|
||||
ui::LatencyInfo* out) {
|
||||
if (!data.ReadTraceName(&out->trace_name_))
|
||||
|
@ -38,7 +38,7 @@ struct ArrayTraits<ui::LatencyInfo::LatencyMap> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<ui::mojom::LatencyComponent,
|
||||
struct StructTraits<ui::mojom::LatencyComponentDataView,
|
||||
ui::LatencyInfo::LatencyComponent> {
|
||||
static int64_t sequence_number(
|
||||
const ui::LatencyInfo::LatencyComponent& component);
|
||||
@ -51,7 +51,7 @@ struct StructTraits<ui::mojom::LatencyComponent,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<ui::mojom::LatencyComponentPair,
|
||||
struct StructTraits<ui::mojom::LatencyComponentPairDataView,
|
||||
ui::LatencyInfo::LatencyMap::value_type> {
|
||||
static const std::pair<ui::LatencyComponentType, int64_t>& key(
|
||||
const ui::LatencyInfo::LatencyMap::value_type& input) {
|
||||
@ -67,7 +67,7 @@ struct StructTraits<ui::mojom::LatencyComponentPair,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<ui::mojom::LatencyComponentId,
|
||||
struct StructTraits<ui::mojom::LatencyComponentIdDataView,
|
||||
std::pair<ui::LatencyComponentType, int64_t>> {
|
||||
static ui::mojom::LatencyComponentType type(
|
||||
const std::pair<ui::LatencyComponentType, int64_t>& id);
|
||||
@ -77,7 +77,7 @@ struct StructTraits<ui::mojom::LatencyComponentId,
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo> {
|
||||
struct StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo> {
|
||||
static const std::string& trace_name(const ui::LatencyInfo& info);
|
||||
static const ui::LatencyInfo::LatencyMap& latency_components(
|
||||
const ui::LatencyInfo& info);
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::Insets, gfx::Insets> {
|
||||
struct StructTraits<gfx::mojom::InsetsDataView, gfx::Insets> {
|
||||
static int top(const gfx::Insets& p) { return p.top(); }
|
||||
static int left(const gfx::Insets& p) { return p.left(); }
|
||||
static int bottom(const gfx::Insets& p) { return p.bottom(); }
|
||||
@ -32,7 +32,7 @@ struct StructTraits<gfx::mojom::Insets, gfx::Insets> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::InsetsF, gfx::InsetsF> {
|
||||
struct StructTraits<gfx::mojom::InsetsFDataView, gfx::InsetsF> {
|
||||
static float top(const gfx::InsetsF& p) { return p.top(); }
|
||||
static float left(const gfx::InsetsF& p) { return p.left(); }
|
||||
static float bottom(const gfx::InsetsF& p) { return p.bottom(); }
|
||||
@ -44,7 +44,7 @@ struct StructTraits<gfx::mojom::InsetsF, gfx::InsetsF> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::Point, gfx::Point> {
|
||||
struct StructTraits<gfx::mojom::PointDataView, gfx::Point> {
|
||||
static int x(const gfx::Point& p) { return p.x(); }
|
||||
static int y(const gfx::Point& p) { return p.y(); }
|
||||
static bool Read(gfx::mojom::PointDataView data, gfx::Point* out) {
|
||||
@ -54,7 +54,7 @@ struct StructTraits<gfx::mojom::Point, gfx::Point> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::PointF, gfx::PointF> {
|
||||
struct StructTraits<gfx::mojom::PointFDataView, gfx::PointF> {
|
||||
static float x(const gfx::PointF& p) { return p.x(); }
|
||||
static float y(const gfx::PointF& p) { return p.y(); }
|
||||
static bool Read(gfx::mojom::PointFDataView data, gfx::PointF* out) {
|
||||
@ -64,7 +64,7 @@ struct StructTraits<gfx::mojom::PointF, gfx::PointF> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::Rect, gfx::Rect> {
|
||||
struct StructTraits<gfx::mojom::RectDataView, gfx::Rect> {
|
||||
static int x(const gfx::Rect& p) { return p.x(); }
|
||||
static int y(const gfx::Rect& p) { return p.y(); }
|
||||
static int width(const gfx::Rect& p) { return p.width(); }
|
||||
@ -79,7 +79,7 @@ struct StructTraits<gfx::mojom::Rect, gfx::Rect> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::RectF, gfx::RectF> {
|
||||
struct StructTraits<gfx::mojom::RectFDataView, gfx::RectF> {
|
||||
static float x(const gfx::RectF& p) { return p.x(); }
|
||||
static float y(const gfx::RectF& p) { return p.y(); }
|
||||
static float width(const gfx::RectF& p) { return p.width(); }
|
||||
@ -94,7 +94,7 @@ struct StructTraits<gfx::mojom::RectF, gfx::RectF> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::Size, gfx::Size> {
|
||||
struct StructTraits<gfx::mojom::SizeDataView, gfx::Size> {
|
||||
static int width(const gfx::Size& p) { return p.width(); }
|
||||
static int height(const gfx::Size& p) { return p.height(); }
|
||||
static bool Read(gfx::mojom::SizeDataView data, gfx::Size* out) {
|
||||
@ -107,7 +107,7 @@ struct StructTraits<gfx::mojom::Size, gfx::Size> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::SizeF, gfx::SizeF> {
|
||||
struct StructTraits<gfx::mojom::SizeFDataView, gfx::SizeF> {
|
||||
static float width(const gfx::SizeF& p) { return p.width(); }
|
||||
static float height(const gfx::SizeF& p) { return p.height(); }
|
||||
static bool Read(gfx::mojom::SizeFDataView data, gfx::SizeF* out) {
|
||||
@ -120,7 +120,7 @@ struct StructTraits<gfx::mojom::SizeF, gfx::SizeF> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::Vector2d, gfx::Vector2d> {
|
||||
struct StructTraits<gfx::mojom::Vector2dDataView, gfx::Vector2d> {
|
||||
static int x(const gfx::Vector2d& v) { return v.x(); }
|
||||
static int y(const gfx::Vector2d& v) { return v.y(); }
|
||||
static bool Read(gfx::mojom::Vector2dDataView data, gfx::Vector2d* out) {
|
||||
@ -131,7 +131,7 @@ struct StructTraits<gfx::mojom::Vector2d, gfx::Vector2d> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::Vector2dF, gfx::Vector2dF> {
|
||||
struct StructTraits<gfx::mojom::Vector2dFDataView, gfx::Vector2dF> {
|
||||
static float x(const gfx::Vector2dF& v) { return v.x(); }
|
||||
static float y(const gfx::Vector2dF& v) { return v.y(); }
|
||||
static bool Read(gfx::mojom::Vector2dFDataView data, gfx::Vector2dF* out) {
|
||||
|
@ -11,7 +11,8 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::AcceleratedWidget, gfx::AcceleratedWidget> {
|
||||
struct StructTraits<gfx::mojom::AcceleratedWidgetDataView,
|
||||
gfx::AcceleratedWidget> {
|
||||
static uint64_t widget(const gfx::AcceleratedWidget& widget) {
|
||||
#if defined(OS_WIN) || defined(USE_OZONE) || defined(USE_X11)
|
||||
#if defined(OS_WIN)
|
||||
|
@ -47,7 +47,7 @@ gfx::SelectionBound::Type MojoSelectionBoundTypeToGfx(
|
||||
}
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::SelectionBound, gfx::SelectionBound> {
|
||||
struct StructTraits<gfx::mojom::SelectionBoundDataView, gfx::SelectionBound> {
|
||||
static gfx::mojom::SelectionBoundType type(const gfx::SelectionBound& input) {
|
||||
return GfxSelectionBoundTypeToMojo(input.type());
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ struct ArrayTraits<SkMatrix44> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gfx::mojom::Transform, gfx::Transform> {
|
||||
struct StructTraits<gfx::mojom::TransformDataView, gfx::Transform> {
|
||||
static const SkMatrix44& matrix(const gfx::Transform& transform) {
|
||||
return transform.matrix();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<url::mojom::Origin, url::Origin> {
|
||||
struct StructTraits<url::mojom::OriginDataView, url::Origin> {
|
||||
static const std::string& scheme(const url::Origin& r) { return r.scheme(); }
|
||||
static const std::string& host(const url::Origin& r) { return r.host(); }
|
||||
static uint16_t port(const url::Origin& r) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<url::mojom::Url, GURL> {
|
||||
struct StructTraits<url::mojom::UrlDataView, GURL> {
|
||||
static base::StringPiece url(const GURL& r) {
|
||||
if (r.possibly_invalid_spec().length() > url::kMaxURLChars ||
|
||||
!r.is_valid()) {
|
||||
|
Reference in New Issue
Block a user