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

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

Issue 1991463002: Mojo: Expose untyped associated endpoints through public API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/associated_interface_request.h
diff --git a/mojo/public/cpp/bindings/associated_interface_request.h b/mojo/public/cpp/bindings/associated_interface_request.h
index 36cbe3eb48c0db45b29fe0117e63c2ffe9282b25..a7a7f662166b7e2111a626760b82fcbcaa54270c 100644
--- a/mojo/public/cpp/bindings/associated_interface_request.h
+++ b/mojo/public/cpp/bindings/associated_interface_request.h
@@ -8,14 +8,10 @@
#include <utility>
#include "base/macros.h"
-#include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h"
+#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
namespace mojo {
-namespace internal {
-class AssociatedInterfaceRequestHelper;
-}
-
// AssociatedInterfaceRequest represents an associated interface request. It is
// similar to InterfaceRequest except that it doesn't own a message pipe handle.
template <typename Interface>
@@ -51,39 +47,30 @@ class AssociatedInterfaceRequest {
// handle.
bool is_pending() const { return handle_.is_valid(); }
- private:
- friend class internal::AssociatedInterfaceRequestHelper;
-
- internal::ScopedInterfaceEndpointHandle handle_;
-};
-
-namespace internal {
-
-// With this helper, AssociatedInterfaceRequest doesn't have to expose any
-// operations related to ScopedInterfaceEndpointHandle, which is an internal
-// class.
-class AssociatedInterfaceRequestHelper {
- public:
- template <typename Interface>
- static ScopedInterfaceEndpointHandle PassHandle(
- AssociatedInterfaceRequest<Interface>* request) {
- return std::move(request->handle_);
+ void Bind(ScopedInterfaceEndpointHandle handle) {
+ handle_ = std::move(handle);
}
- template <typename Interface>
- static const ScopedInterfaceEndpointHandle& GetHandle(
- AssociatedInterfaceRequest<Interface>* request) {
- return request->handle_;
+ ScopedInterfaceEndpointHandle PassHandle() {
+ return std::move(handle_);
}
- template <typename Interface>
- static void SetHandle(AssociatedInterfaceRequest<Interface>* request,
- ScopedInterfaceEndpointHandle handle) {
- request->handle_ = std::move(handle);
- }
+ const ScopedInterfaceEndpointHandle& handle() const { return handle_; }
+
+ private:
+ ScopedInterfaceEndpointHandle handle_;
};
-} // namespace internal
+// Makes an AssociatedInterfaceRequest bound to the specified associated
+// endpoint.
+template <typename Interface>
+AssociatedInterfaceRequest<Interface> MakeAssociatedRequest(
+ ScopedInterfaceEndpointHandle handle) {
+ AssociatedInterfaceRequest<Interface> request;
+ request.Bind(std::move(handle));
+ return request;
+}
+
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_
« no previous file with comments | « mojo/public/cpp/bindings/associated_interface_ptr_info.h ('k') | mojo/public/cpp/bindings/lib/associated_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698