New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593228 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Apr 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Add type converters impl for url/mojo/origin.mojom

Project Member Reported by leon....@intel.com, Mar 9 2016

Issue description


While 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
};
"
 
I don't think we want type converters for these types if we can avoid them.
We have StructTraits for mapping directly to the url mojom wire format.

Comment 2 by leon....@intel.com, 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
}
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.

Comment 4 by leon....@intel.com, 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!

Comment 5 by leon....@intel.com, 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~

Comment 6 by leon....@intel.com, Apr 11 2016

Status: WontFix (was: Untriaged)

Sign in to add a comment