| OLD | NEW |
| 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_STATE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> // For |std::swap()|. | 10 #include <algorithm> // For |std::swap()|. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 void Swap(InterfacePtrState* other) { | 87 void Swap(InterfacePtrState* other) { |
| 88 using std::swap; | 88 using std::swap; |
| 89 swap(other->proxy_, proxy_); | 89 swap(other->proxy_, proxy_); |
| 90 swap(other->router_, router_); | 90 swap(other->router_, router_); |
| 91 handle_.swap(other->handle_); | 91 handle_.swap(other->handle_); |
| 92 runner_.swap(other->runner_); | 92 runner_.swap(other->runner_); |
| 93 swap(other->version_, version_); | 93 swap(other->version_, version_); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void Bind(InterfacePtrInfo<Interface> info, | 96 bool WaitForIncomingResponse() override { |
| 97 scoped_refptr<base::SingleThreadTaskRunner> runner) { | 97 ConfigureProxyIfNecessary(); |
| 98 DCHECK(!proxy_); | |
| 99 DCHECK(!router_); | |
| 100 DCHECK(!handle_.is_valid()); | |
| 101 DCHECK_EQ(0u, version_); | |
| 102 DCHECK(info.is_valid()); | |
| 103 | 98 |
| 104 handle_ = info.PassHandle(); | 99 handle_ = info.PassHandle(); |
| 105 version_ = info.version(); | 100 version_ = info.version(); |
| 106 runner_ = std::move(runner); | 101 runner_ = std::move(runner); |
| 107 } | 102 } |
| 108 | 103 |
| 109 bool HasAssociatedInterfaces() const { return false; } | 104 bool HasAssociatedInterfaces() const { return false; } |
| 110 | 105 |
| 111 // After this method is called, the object is in an invalid state and | 106 // After this method is called, the object is in an invalid state and |
| 112 // shouldn't be reused. | 107 // shouldn't be reused. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 246 |
| 252 handle_ = info.PassHandle(); | 247 handle_ = info.PassHandle(); |
| 253 version_ = info.version(); | 248 version_ = info.version(); |
| 254 runner_ = std::move(runner); | 249 runner_ = std::move(runner); |
| 255 } | 250 } |
| 256 | 251 |
| 257 bool HasAssociatedInterfaces() const { | 252 bool HasAssociatedInterfaces() const { |
| 258 return router_ ? router_->HasAssociatedEndpoints() : false; | 253 return router_ ? router_->HasAssociatedEndpoints() : false; |
| 259 } | 254 } |
| 260 | 255 |
| 256 bool WaitForIncomingResponse() { |
| 257 ConfigureProxyIfNecessary(); |
| 258 |
| 259 DCHECK(router_); |
| 260 return router_->WaitForIncomingMessage(MOJO_DEADLINE_INDEFINITE); |
| 261 } |
| 262 |
| 261 // After this method is called, the object is in an invalid state and | 263 // After this method is called, the object is in an invalid state and |
| 262 // shouldn't be reused. | 264 // shouldn't be reused. |
| 263 InterfacePtrInfo<Interface> PassInterface() { | 265 InterfacePtrInfo<Interface> PassInterface() { |
| 264 endpoint_client_.reset(); | 266 endpoint_client_.reset(); |
| 265 proxy_.reset(); | 267 proxy_.reset(); |
| 266 return InterfacePtrInfo<Interface>( | 268 return InterfacePtrInfo<Interface>( |
| 267 router_ ? router_->PassMessagePipe() : std::move(handle_), version_); | 269 router_ ? router_->PassMessagePipe() : std::move(handle_), version_); |
| 268 } | 270 } |
| 269 | 271 |
| 270 bool is_bound() const { return handle_.is_valid() || endpoint_client_; } | 272 bool is_bound() const { return handle_.is_valid() || endpoint_client_; } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 341 |
| 340 uint32_t version_; | 342 uint32_t version_; |
| 341 | 343 |
| 342 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); | 344 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); |
| 343 }; | 345 }; |
| 344 | 346 |
| 345 } // namespace internal | 347 } // namespace internal |
| 346 } // namespace mojo | 348 } // namespace mojo |
| 347 | 349 |
| 348 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ | 350 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
| OLD | NEW |