Add type converters impl for url/mojo/origin.mojom |
||
Issue descriptionWhile I'm working for Issue 582391 , I noticed that I need to use the url.mojom.Origin but it has no type converters impl, so I would like to do this work. Would you please let me know whether it makes sense or not? Thanks~ In my .mojom file: " struct CredentialInfo { XXXXXX url.mojom.Origin federation; XXXXXX }; "
,
Mar 9 2016
Hi, Ken, Thanks a lot for so quick feedback! But when I want to transfer mojom::CredentialInfo via a mojo interface function, seems I must do the conversion between url::Origin and url::mojom::OriginPtr.
I suppose the StructTraits is for the serialization/deserialization work inside mojo and how could mojo interface function callers use StructTraits directly? Sorry maybe I'm misunderstanding about StructTraits.. Thanks in advance~
Generated class:
mojom::CredentialInfo {
XXXXXX
url::mojom::OriginPtr federation;
XXXXXX
}
,
Mar 9 2016
What you want to do is apply a typemap to your mojom. So your mojom rule
would look something like:
mojom("interfaces") {
sources = [
"credential_manager.mojom"
]
typemaps = [
"//url/mojo/origin.typemap"
]
}
If you do this, your generated bindings will replace references to
url.mojom.Origin with references to url::Origin, so your example generated
struct would look like:
class Credentalinfo {
// ...
url::Origin federation;
};
and the bindings will understand how to serialize the |federation| field in
the wire format defined by url::mojom::Origin. This also works if you use
url.mojom.Origin as a message parameter. The method signature will expect a
const url::Origin& instead of a url::mojom::OriginPtr.
,
Mar 9 2016
Big Thanks! It's clear now and I think this is amazing! Thanks and sorry to take your time for this issue!
,
Mar 9 2016
And, sorry for additional question: Seems we're using type_converters in many mojofication works until now, and now the typemap/StructTraits seems more direct and powerful than type_converters, should we prefer using typemap/StructTraits for all defined mojom struct in future mojofication work. Or is there any criteria to help make a choice? Thanks~
,
Apr 11 2016
|
||
►
Sign in to add a comment |
||
Comment 1 by roc...@chromium.org
, Mar 9 2016