Mojo handles and handle wrappers should consistently provide operator bool |
||
Issue descriptionMojo handles and the various bindings classes that hold message pipe handles are inconsistent about how to check whether or not they hold a handle. Some expose this information via operator bool. Others use: - is_valid() - is_bound() - is_pending() This is unnecessarily confusing. We should add operator bool to these types: - mojo::ScopedHandleBase - mojo::Handle - mojo::InterfaceRequest - mojo::AssociatedInterfaceRequest - mojo::AssociatedInterfacePtrInfo Consider adding it to: - mojo::Binding - mojo::AssociatedBinding Then clean up: remove is_valid(), is_bound() and is_pending() from public mojo types with an operator bool (after migrating everything to use the operator bools).
,
May 14 2018
I assume this is no longer being worked on? I'm getting build failures with GCC 8.1.0 here that look like this (GCC <= 7 is fine):
In file included from ../../mojo/public/cpp/bindings/lib/interface_serialization.h:11,
from gen/url/mojom/url.mojom-shared.h:26,
from gen/services/metrics/public/mojom/ukm_interface.mojom-shared.h:25,
from gen/services/metrics/public/mojom/ukm_interface.mojom.h:28,
from ../../services/metrics/public/cpp/ukm_recorder.h:16,
from ../../cc/trees/proxy_main.cc:24:
../../mojo/public/cpp/bindings/associated_interface_ptr_info.h: In member function ‘mojo::AssociatedInterfacePtrInfo<Interface>::operator bool() const’:
../../mojo/public/cpp/bindings/associated_interface_ptr_info.h:48:43: error: cannot convert ‘const mojo::ScopedInterfaceEndpointHandle’ to ‘bool’ in return
explicit operator bool() const { return handle_; }
^~~~~~~
In file included from ../../mojo/public/cpp/bindings/lib/interface_serialization.h:12,
from gen/url/mojom/url.mojom-shared.h:26,
from gen/services/metrics/public/mojom/ukm_interface.mojom-shared.h:25,
from gen/services/metrics/public/mojom/ukm_interface.mojom.h:28,
from ../../services/metrics/public/cpp/ukm_recorder.h:16,
from ../../cc/trees/proxy_main.cc:24:
../../mojo/public/cpp/bindings/associated_interface_request.h: In member function ‘mojo::AssociatedInterfaceRequest<Interface>::operator bool() const’:
../../mojo/public/cpp/bindings/associated_interface_request.h:53:43: error: cannot convert ‘const mojo::ScopedInterfaceEndpointHandle’ to ‘bool’ in return
explicit operator bool() const { return handle_; }
^~~~~~~
It's not totally clear to me what the semantic meaning of ScopedInterfaceEndpointHandle -> bool would be anyway. Would you guys be OK with changing those two operator bool overloads to call handle_.is_valid()?
,
May 16 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/b65488bce5e804e97acb64ccb696195699a26b8a commit b65488bce5e804e97acb64ccb696195699a26b8a Author: Jüri Valdmann <juri.valdmann@qt.io> Date: Wed May 16 02:27:40 2018 Fix operator bool in AssociatedInterfacePtrInfo and AssociatedInterfaceRequest Current version does not compile with GCC 8.1 and for good reason: there's no operator bool defined in ScopedInterfaceEndpointHandle. Bug: 795173, 819294 Change-Id: Ia0677af3160fb24c376c66863956ee6d171d7caf Reviewed-on: https://chromium-review.googlesource.com/1059153 Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Reviewed-by: Ken Rockot <rockot@chromium.org> Cr-Commit-Position: refs/heads/master@{#558931} [modify] https://crrev.com/b65488bce5e804e97acb64ccb696195699a26b8a/mojo/public/cpp/bindings/associated_interface_ptr_info.h [modify] https://crrev.com/b65488bce5e804e97acb64ccb696195699a26b8a/mojo/public/cpp/bindings/associated_interface_request.h
,
Oct 17
|
||
►
Sign in to add a comment |
||
Comment 1 by bugdroid1@chromium.org
, Jan 17 2018