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

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_ptr_internal.h

Issue 405653003: mojo: Make InterfacePtr<> testable in if() statements without .get(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to is_bound() 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
7 7
8 #include <assert.h> 8 #include <assert.h>
9 9
10 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 10 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 ScopedMessagePipeHandle PassMessagePipe() { 63 ScopedMessagePipeHandle PassMessagePipe() {
64 if (router_) 64 if (router_)
65 return router_->PassMessagePipe(); 65 return router_->PassMessagePipe();
66 66
67 waiter_ = NULL; 67 waiter_ = NULL;
68 return handle_.Pass(); 68 return handle_.Pass();
69 } 69 }
70 70
71 bool is_bound() const {
72 return handle_.is_valid() || router_;
73 }
74
71 void set_client(typename Interface::Client* client) { 75 void set_client(typename Interface::Client* client) {
72 ConfigureProxyIfNecessary(); 76 ConfigureProxyIfNecessary();
73 77
74 assert(proxy_); 78 assert(proxy_);
75 proxy_->stub.set_sink(client); 79 proxy_->stub.set_sink(client);
76 } 80 }
77 81
78 bool encountered_error() const { 82 bool encountered_error() const {
79 return router_ ? router_->encountered_error() : false; 83 return router_ ? router_->encountered_error() : false;
80 } 84 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ScopedMessagePipeHandle handle_; 141 ScopedMessagePipeHandle handle_;
138 const MojoAsyncWaiter* waiter_; 142 const MojoAsyncWaiter* waiter_;
139 143
140 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); 144 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
141 }; 145 };
142 146
143 } // namespace internal 147 } // namespace internal
144 } // namespace mojo 148 } // namespace mojo
145 149
146 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 150 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/interface_ptr.h ('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