Non-pure-virtual mojom interfaces

6 views
Skip to first unread message

Xiaohan Wang

unread,
Aug 12, 2021, 7:39:21 PM8/12/21
to chromium-mojo
Hello,

When we have multiple implementations of a mojom interface (e.g. in tests), we have to override all the mojom interface methods since all the generated interfaces a pure virtual. In many cases those functions are just empty.

I wonder whether it makes sense to allow non-pure-virtual mojom interface methods so a default implementation is provided in the generated code? I can see the convenience of it in many cases. Thoughts?

Best,
Xiaohan

Ken Rockot

unread,
Aug 12, 2021, 7:59:31 PM8/12/21
to Xiaohan Wang, chromium-mojo
I think this could be an OK thing to do for tests, emitting something in the generated mojom-test-utils.h. I would hesitate to change the primary generated interface classes though, because then it seems really easy by default to overlook existing implementations when adding new interface methods.

Even in tests, default no-op methods could lead to confusing failure modes for methods that take a reply callback. One option there would be to keep such methods as pure-virtual, but then the whole idea gets kind of muddy and inconsistent IMHO.


Best,
Xiaohan

--
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/dceccf16-0c3b-4820-b654-c6a4e09ec049n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages