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

Unified Diff: mojo/public/cpp/bindings/associated_interface_ptr_info.h

Issue 1465293002: Mojo C++ bindings: introduce public associated-interface-related types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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_
« no previous file with comments | « mojo/public/cpp/bindings/associated_interface_ptr.h ('k') | mojo/public/cpp/bindings/associated_interface_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698