| Index: mojo/public/cpp/bindings/associated_interface_ptr_info.h
|
| diff --git a/mojo/public/cpp/bindings/associated_interface_ptr_info.h b/mojo/public/cpp/bindings/associated_interface_ptr_info.h
|
| index 55f9c4a68f6431786136d1377f08041a59fdc312..43f90276e59f8ebd55ec5dc4d14cb79572c43e21 100644
|
| --- a/mojo/public/cpp/bindings/associated_interface_ptr_info.h
|
| +++ b/mojo/public/cpp/bindings/associated_interface_ptr_info.h
|
| @@ -5,28 +5,81 @@
|
| #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_
|
| #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_
|
|
|
| -#include "mojo/public/cpp/system/macros.h"
|
| +#include "base/macros.h"
|
| +#include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h"
|
|
|
| namespace mojo {
|
|
|
| +namespace internal {
|
| +class AssociatedInterfacePtrInfoHelper;
|
| +}
|
| +
|
| // AssociatedInterfacePtrInfo stores necessary information to construct an
|
| -// associated interface pointer.
|
| -// TODO(yzshen): implement it.
|
| +// associated interface pointer. It is similar to InterfacePtrInfo except that
|
| +// it doesn't own a message pipe handle.
|
| template <typename Interface>
|
| class AssociatedInterfacePtrInfo {
|
| - MOJO_MOVE_ONLY_TYPE(AssociatedInterfacePtrInfo);
|
| + MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(AssociatedInterfacePtrInfo);
|
|
|
| public:
|
| - AssociatedInterfacePtrInfo() {}
|
| - AssociatedInterfacePtrInfo(AssociatedInterfacePtrInfo&& other) {}
|
| + AssociatedInterfacePtrInfo() : version_(0u) {}
|
| +
|
| + AssociatedInterfacePtrInfo(AssociatedInterfacePtrInfo&& other)
|
| + : handle_(other.handle_.Pass()), version_(other.version_) {
|
| + other.version_ = 0u;
|
| + }
|
| +
|
| + ~AssociatedInterfacePtrInfo() {}
|
|
|
| AssociatedInterfacePtrInfo& operator=(AssociatedInterfacePtrInfo&& other) {
|
| + if (this != &other) {
|
| + handle_ = other.handle_.Pass();
|
| + version_ = other.version_;
|
| + other.version_ = 0u;
|
| + }
|
| +
|
| return *this;
|
| }
|
|
|
| - bool is_valid() const { return false; }
|
| + bool is_valid() const { return handle_.is_valid(); }
|
| +
|
| + uint32_t version() const { return version_; }
|
| + void set_version(uint32_t version) { version_ = version; }
|
| +
|
| + private:
|
| + friend class internal::AssociatedInterfacePtrInfoHelper;
|
| +
|
| + internal::ScopedInterfaceEndpointHandle handle_;
|
| + uint32_t version_;
|
| +};
|
| +
|
| +namespace internal {
|
| +
|
| +// With this helper, AssociatedInterfacePtrInfo doesn't have to expose any
|
| +// operations related to ScopedInterfaceEndpointHandle, which is an internal
|
| +// class.
|
| +class AssociatedInterfacePtrInfoHelper {
|
| + public:
|
| + template <typename Interface>
|
| + static ScopedInterfaceEndpointHandle PassHandle(
|
| + AssociatedInterfacePtrInfo<Interface>* info) {
|
| + return info->handle_.Pass();
|
| + }
|
| +
|
| + template <typename Interface>
|
| + static const ScopedInterfaceEndpointHandle& GetHandle(
|
| + AssociatedInterfacePtrInfo<Interface>* info) {
|
| + return info->handle_;
|
| + }
|
| +
|
| + template <typename Interface>
|
| + static void SetHandle(AssociatedInterfacePtrInfo<Interface>* info,
|
| + ScopedInterfaceEndpointHandle handle) {
|
| + info->handle_ = handle.Pass();
|
| + }
|
| };
|
|
|
| +} // namespace internal
|
| } // namespace mojo
|
|
|
| #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_
|
|
|