How should a Mojo client register a member function as a Mojo function callback?

34 views
Skip to first unread message

Simon Que

unread,
Jun 16, 2016, 3:41:43 AM6/16/16
to mojo...@chromium.org, Ilya Sherman, Will Harris
Hi Mojo team,

Ilya and I were wondering what the proper pattern is for calling a remote Mojo function that returns some data and thus requires a callback / response handler. See Lines 19-21 here:
https://codereview.chromium.org/2056973002/diff/20001/chrome/renderer/leak_detector_remote_client.cc

Our concern is that it may not be safe to use base::Unretained(this) when binding the class member function as a callback. Looking at the Mojo documentation, I see an example here that binds a non-member function:

However, there is no example of using a class member function for this purpose. What is the proper way to do it?

Thanks,

Simon

Jeff Brown

unread,
Jun 16, 2016, 11:58:00 AM6/16/16
to Simon Que, mojo...@chromium.org, Ilya Sherman, Will Harris

Binding to class members are fine as long as you ensure that the interface pointer is released before the object is destroyed.  Callbacks won't be invoked once the interface is unbound.


--
You received this message because you are subscribed to the Google Groups "mojo-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojo-dev+u...@chromium.org.
Reply all
Reply to author
Forward
0 new messages