I have a receiver implementation class (let's call it MyImpl) that accepts a PendingRemote (let's call it MyRemote) as one of its mojo methods. When the remote is bound, I'd like to immediately make an async call to one of its getters (GetID) so that I can organize all Remotes that share the same ID. This creates some awkward logic, however:
MyImpl receives the pending remote and binds it.MyImpl calls MyRemote()->GetID(callback)to get its ID, which should be constant for the lifetime of the remote.MyImpl also adds MyRemote to a list of remotes to keep the object alive while we wait for a response.The question is - how do we access and/or find the remote that was added in step 3 so we can sort it? Is there a UUID or some other property I can pass to the callback to identify it?
Even broader question - is there a better way to do this? We can alternatively add the ID as an argument to the impl method that accepts the PendingRemote, but that is also problematic as the caller doesn't technically have to use the ID that is associated with the remote object (and we want them to).
Hello,I asked this question internally (YAQS) before realizing there was a mailing list. Copying the details below:---------------------------------------------I have a receiver implementation class (let's call it
MyImpl) that accepts a PendingRemote (let's call itMyRemote) as one of its mojo methods. When the remote is bound, I'd like to immediately make an async call to one of its getters (GetID) so that I can organize all Remotes that share the same ID. This creates some awkward logic, however:
MyImplreceives the pending remote and binds it.MyImplcallsMyRemote()->GetID(callback)to get its ID, which should be constant for the lifetime of the remote.MyImplalso addsMyRemoteto a list of remotes to keep the object alive while we wait for a response.- The ID callback fires with the Remote's ID. Now we need to sort the original Remote into a bucket that matches the returned ID.
The question is - how do we access and/or find the remote that was added in step 3 so we can sort it? Is there a UUID or some other property I can pass to the callback to identify it?
Even broader question - is there a better way to do this? We can alternatively add the ID as an argument to the impl method that accepts the PendingRemote, but that is also problematic as the caller doesn't technically have to use the ID that is associated with the remote object (and we want them to).
--
You received this message because you are subscribed to the Google Groups "chromium-mojo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-moj...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-mojo/CAHb-o4yo35LXhdrwr%2BCs7qn%3DoFg5bapWUFTGTw30rgDCdsYF%3DQ%40mail.gmail.com.
--
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-mojo/CA%2BapAgF1-MnRTeYdTPoeSgDqNODngqv2RFeS05tznGMgrdxgDA%40mail.gmail.com.
Yes - sorry for the vagueness! I'm not sure what the visibility of this mailing list is, nor am I sure what I'm allowed to divulge for internal teams, so I'm erring on the side of caution. I've added more details below with some remaining ambiguity (please ignore the original example):The Remotes contain two methods: one that returns a regex string for pattern matching, and one that contains a reference to a remote callback that should be fired when the regex is a match. In order for this Remote to be useful, we have to immediately ask it what the regex is so that we can trigger the callback later. When we get the regex, we have to then associate it back to the right remote. And I'd rather not have the caller pass in the regex as an arg, since it will technically not need to be == to the regex that's contained receiver-side, so we open ourselves to errors there.
dtapuska@ provided an interesting reference where the Remote is bound to the callback. I wasn't aware you could do that - is this an appropriate solution? Then when the callback is fired, we can permanently store the Remote + the details where needed. I just don't know what happens if the Remote disconnects midway through that process.
But from a security/correctness perspective, this seems pretty much the same as:- process A calls process B with WaitForMatch(string regex, pending_remote<MatchedCallback> remote)- process B waits for a match on `regex` and invokes MatchedCallback::DidMatch() on a match.In both scenarios, process B is responsible for handling the regex matching. And in both scenarios, process B (if untrustworthy) can choose to ignore the regex and do its own thing, right? So I don't feel like it makes a difference where/when the regex is passed, so preferring the simpler option seems better.
Also, there are some security implications to passing regex across IPC. I'd suggest looping in security reviewers sooner rather than later: in the past, I believe we've tried to avoid trusting regex from an untrustworthy source (e.g. see https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/mojom/safe_url_pattern.mojom;l=9;drc=18196c6a774d2d25f45ce31a8e3bb7225e72943a).