Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1489)

Unified Diff: mojo/public/cpp/bindings/interface_ptr.h

Issue 405653003: mojo: Make InterfacePtr<> testable in if() statements without .get(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.cc ('k') | mojo/public/cpp/bindings/tests/handle_passing_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/interface_ptr.h
diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h
index b868a0a5c36167c1885c16f597a600bfed4ecef2..80c09c7227effc2fb36a6049361703a4a27eb503 100644
--- a/mojo/public/cpp/bindings/interface_ptr.h
+++ b/mojo/public/cpp/bindings/interface_ptr.h
@@ -104,6 +104,16 @@ class InterfacePtr {
return &internal_state_;
}
+ // Allow InterfacePtr<> to be used in boolean expressions, but not
yzshen1 2014/07/18 19:17:43 One thing that may worth considering: I just lande
Elliot Glaysher 2014/07/18 19:32:15 What do you propose replacing get() with?
yzshen1 2014/07/18 19:38:45 Maybe an IsBound() method on the internal state, w
+ // implicitly convertible to a real bool (which is dangerous).
+ private:
+ typedef internal::InterfacePtrState<Interface> InterfacePtr::*Testable;
+
+ public:
+ operator Testable() const {
+ return get() ? &InterfacePtr::internal_state_ : NULL;
+ }
+
private:
typedef internal::InterfacePtrState<Interface> State;
mutable State internal_state_;
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.cc ('k') | mojo/public/cpp/bindings/tests/handle_passing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698