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

Unified Diff: mojo/public/platform/native/platform_handle_private.h

Issue 1970513002: Update platform handle (private) API "documentation"/comments. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: review comments 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
« no previous file with comments | « no previous file | mojo/public/platform/native/platform_handle_private_thunks.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/platform/native/platform_handle_private.h
diff --git a/mojo/public/platform/native/platform_handle_private.h b/mojo/public/platform/native/platform_handle_private.h
index adda510073f877d80108cc0fbf0e21815da2cd86..8e46d6a0fc07ca61e6c23ed1cfc023a3d1c7e8a3 100644
--- a/mojo/public/platform/native/platform_handle_private.h
+++ b/mojo/public/platform/native/platform_handle_private.h
@@ -8,25 +8,61 @@
#include "mojo/public/c/system/handle.h"
#include "mojo/public/c/system/result.h"
-typedef int MojoPlatformHandle; // Unix file descriptor
+// |MojoPlatformHandle|: Type for "platform handles", i.e., the underlying OS's
+// handles. Currently this is always just a Unix file descriptor.
+
+typedef int MojoPlatformHandle;
#ifdef __cplusplus
extern "C" {
#endif
-// Wraps |platform_handle| in a MojoHandle so that it can transported. Returns
-// MOJO_RESULT_OK on success, all other results indicate failure. This takes
-// ownership of |platform_handle|, regardless of whether this succeeds.
-MojoResult MojoCreatePlatformHandleWrapper(MojoPlatformHandle platform_handle,
- MojoHandle* wrapper);
-
-// Extracts |platform_handle| from |wrapper|. Returns MOJO_RESULT_OK on success,
-// all other results indicate failure. If this succeeds, it causes |wrapper| to
-// relinquish ownership of |platform_handle|, so MojoClose'ing |wrapper| will no
-// longer close the underlying |platform_handle|. Never the less, it is still
-// neccessary to MojoClose |wrapper|, but this will not affect the underlying
-// descriptor after this call.
-MojoResult MojoExtractPlatformHandle(MojoHandle wrapper,
+// |MojoCreatePlatformHandleWrapper()|: Creates a |MojoHandle| that wraps (and
+// takes ownership of) the platform handle |platform_handle|, which must be
+// valid.
+//
+// On success, |*platform_handle_wrapper_handle| will be set to the wrapper
+// handle. It will have (at least) the |MOJO_HANDLE_RIGHT_TRANSFER|,
+// |MOJO_HANDLE_RIGHT_READ|, and |MOJO_HANDLE_RIGHT_WRITE| rights. Warning: No
+// validation of |platform_handle| is done. (TODO(vtl): This has poor/annoying
+// implications, since we may detect this when we transfer the wrapper handle.)
+//
+// Warning: On failure, this will still take ownership of |platform_handle|
+// (which just means that |platform_handle| will be closed).
+//
+// Returns:
+// |MOJO_RESULT_OK| on success.
+// |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has
+// been reached (e.g., if the maximum number of handles was exceeded).
+MojoResult MojoCreatePlatformHandleWrapper(
+ MojoPlatformHandle platform_handle,
+ MojoHandle* platform_handle_wrapper_handle);
+
+// |MojoExtractPlatformHandle()|: Extracts the wrapped platform handle from
+// |platform_handle_wrapper_handle| (which must have both the
+// |MOJO_HANDLE_RIGHT_READ| and |MOJO_HANDLE_RIGHT_WRITE| rights).
+//
+// On success, |*platform_handle| will be set to the wrapped platform handle and
+// ownership of the wrapped platform handle will be passed to the caller (i.e.,
+// closing |platform_handle_wrapper_handle| will no longer close the platform
+// handle).
+//
+// Warnings:
+// - Even though |platform_handle_wrapper_handle| is then basically useless
+// (it no longer "contains" a platform handle), it must still be closed as
+// usual.
+// - If the wrapped platform handle has already been extracted from
+// |platform_handle_wrapper_handle|, then this will still succeed, but
+// |*platform_handle| will be set to -1.
+//
+// Returns:
+// |MOJO_RESULT_OK| on success.
+// |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g.,
+// |platform_handle_wrapper_handle| is not a valid wrapper handle).
+// |MOJO_RESULT_PERMISSION_DENIED| if |platform_handle_wrapper_handle| does
+// not have the both the |MOJO_HANDLE_RIGHT_READ| and
+// |MOJO_HANDLE_RIGHT_WRITE| rights.
+MojoResult MojoExtractPlatformHandle(MojoHandle platform_handle_wrapper_handle,
MojoPlatformHandle* platform_handle);
#ifdef __cplusplus
« no previous file with comments | « no previous file | mojo/public/platform/native/platform_handle_private_thunks.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698