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

Unified Diff: mojo/public/bindings/remote_ptr.h

Issue 150713002: Mojo: Add ErrorHandler to RemotePtr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update per review feedback Created 6 years, 11 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/public/bindings/lib/connector.cc ('k') | mojo/public/bindings/tests/connector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/remote_ptr.h
diff --git a/mojo/public/bindings/remote_ptr.h b/mojo/public/bindings/remote_ptr.h
index 7acd971b6897265cf53c113ac1993afea4b383c4..bbf36f95b91f865913572b746558c0663122fc78 100644
--- a/mojo/public/bindings/remote_ptr.h
+++ b/mojo/public/bindings/remote_ptr.h
@@ -15,7 +15,7 @@ namespace mojo {
// A RemotePtr is a smart-pointer for managing the connection of a message pipe
// to an interface proxy.
//
-// EXAMPLE
+// EXAMPLE:
//
// On the client side of a service, RemotePtr might be used like so:
//
@@ -46,6 +46,15 @@ namespace mojo {
// mojo::RemotePtr<FooClient> client_;
// };
//
+// NOTE:
+//
+// 1- It is valid to pass NULL for the peer if you are not interested in
+// receiving incoming messages. Those messages will still be consumed.
+//
+// 2- You may optionally register an ErrorHandler on the RemotePtr to be
+// notified if the peer has gone away. Alternatively, you may poll the
+// |encountered_error()| method to check if the peer has gone away.
+//
template <typename S>
class RemotePtr {
struct State;
@@ -55,8 +64,9 @@ class RemotePtr {
RemotePtr() : state_(NULL) {}
explicit RemotePtr(ScopedMessagePipeHandle message_pipe,
typename S::_Peer* peer = NULL,
+ ErrorHandler* error_handler = NULL,
MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter())
- : state_(new State(message_pipe.Pass(), peer, waiter)) {
+ : state_(new State(message_pipe.Pass(), peer, error_handler, waiter)) {
}
// Move-only constructor and operator=.
@@ -90,9 +100,10 @@ class RemotePtr {
void reset(ScopedMessagePipeHandle message_pipe,
typename S::_Peer* peer = NULL,
+ ErrorHandler* error_handler = NULL,
MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) {
delete state_;
- state_ = new State(message_pipe.Pass(), peer, waiter);
+ state_ = new State(message_pipe.Pass(), peer, error_handler, waiter);
}
bool encountered_error() const {
@@ -103,12 +114,13 @@ class RemotePtr {
private:
struct State {
State(ScopedMessagePipeHandle message_pipe, typename S::_Peer* peer,
- MojoAsyncWaiter* waiter)
+ ErrorHandler* error_handler, MojoAsyncWaiter* waiter)
: connector(message_pipe.Pass(), waiter),
proxy(&connector),
stub(peer) {
+ connector.set_error_handler(error_handler);
if (peer)
- connector.SetIncomingReceiver(&stub);
+ connector.set_incoming_receiver(&stub);
}
internal::Connector connector;
typename S::_Proxy proxy;
« no previous file with comments | « mojo/public/bindings/lib/connector.cc ('k') | mojo/public/bindings/tests/connector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698