| Index: third_party/mojo/src/mojo/public/cpp/bindings/lib/interface_ptr_internal.h
|
| diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/lib/interface_ptr_internal.h b/third_party/mojo/src/mojo/public/cpp/bindings/lib/interface_ptr_internal.h
|
| index 3618a26aa320e927673797f3c842c0151dc5f4fb..a3ed7940787b551697b3df46a733d7356200d166 100644
|
| --- a/third_party/mojo/src/mojo/public/cpp/bindings/lib/interface_ptr_internal.h
|
| +++ b/third_party/mojo/src/mojo/public/cpp/bindings/lib/interface_ptr_internal.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include <algorithm> // For |std::swap()|.
|
|
|
| +#include "mojo/public/cpp/bindings/interface_ptr_info.h"
|
| #include "mojo/public/cpp/bindings/lib/filter_chain.h"
|
| #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
|
| #include "mojo/public/cpp/bindings/lib/router.h"
|
| @@ -20,7 +21,8 @@ namespace internal {
|
| template <typename Interface>
|
| class InterfacePtrState {
|
| public:
|
| - InterfacePtrState() : proxy_(nullptr), router_(nullptr), waiter_(nullptr) {}
|
| + InterfacePtrState()
|
| + : proxy_(nullptr), router_(nullptr), waiter_(nullptr), version_(0u) {}
|
|
|
| ~InterfacePtrState() {
|
| // Destruction order matters here. We delete |proxy_| first, even though
|
| @@ -37,21 +39,28 @@ class InterfacePtrState {
|
| return proxy_;
|
| }
|
|
|
| + uint32_t version() const { return version_; }
|
| +
|
| void Swap(InterfacePtrState* other) {
|
| - std::swap(other->proxy_, proxy_);
|
| - std::swap(other->router_, router_);
|
| + using std::swap;
|
| + swap(other->proxy_, proxy_);
|
| + swap(other->router_, router_);
|
| handle_.swap(other->handle_);
|
| - std::swap(other->waiter_, waiter_);
|
| + swap(other->waiter_, waiter_);
|
| + swap(other->version_, version_);
|
| }
|
|
|
| - void Bind(ScopedMessagePipeHandle handle, const MojoAsyncWaiter* waiter) {
|
| + void Bind(InterfacePtrInfo<Interface> info, const MojoAsyncWaiter* waiter) {
|
| MOJO_DCHECK(!proxy_);
|
| MOJO_DCHECK(!router_);
|
| MOJO_DCHECK(!handle_.is_valid());
|
| MOJO_DCHECK(!waiter_);
|
| + MOJO_DCHECK(version_ == 0u);
|
| + MOJO_DCHECK(info.is_valid());
|
|
|
| - handle_ = handle.Pass();
|
| + handle_ = info.PassHandle();
|
| waiter_ = waiter;
|
| + version_ = info.version();
|
| }
|
|
|
| bool WaitForIncomingMethodCall() {
|
| @@ -61,12 +70,11 @@ class InterfacePtrState {
|
| return router_->WaitForIncomingMessage();
|
| }
|
|
|
| - ScopedMessagePipeHandle PassMessagePipe() {
|
| - if (router_)
|
| - return router_->PassMessagePipe();
|
| -
|
| - waiter_ = nullptr;
|
| - return handle_.Pass();
|
| + // After this method is called, the object is in an invalid state and
|
| + // shouldn't be reused.
|
| + InterfacePtrInfo<Interface> PassInterface() {
|
| + return InterfacePtrInfo<Interface>(
|
| + router_ ? router_->PassMessagePipe() : handle_.Pass(), version_);
|
| }
|
|
|
| bool is_bound() const { return handle_.is_valid() || router_; }
|
| @@ -116,11 +124,13 @@ class InterfacePtrState {
|
| Router* router_;
|
|
|
| // |proxy_| and |router_| are not initialized until read/write with the
|
| - // message pipe handle is needed. Before that, |handle_| and |waiter_| store
|
| - // the arguments of Bind().
|
| + // message pipe handle is needed. |handle_| and |waiter_| are valid between
|
| + // the Bind() call and the initialization of |proxy_| and |router_|.
|
| ScopedMessagePipeHandle handle_;
|
| const MojoAsyncWaiter* waiter_;
|
|
|
| + uint32_t version_;
|
| +
|
| MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
|
| };
|
|
|
|
|