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

Unified Diff: mojo/edk/platform/platform_handle.cc

Issue 1505983002: EDK: Remove platform_handle_utils*. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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 | « mojo/edk/platform/platform_handle.h ('k') | mojo/edk/platform/scoped_platform_handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/platform/platform_handle.cc
diff --git a/mojo/edk/platform/platform_handle.cc b/mojo/edk/platform/platform_handle.cc
index 8a7c7be1b70d16eb3745e129f50932969dc49f3b..c65600e424237f6833226f2286a478e1ba3a630d 100644
--- a/mojo/edk/platform/platform_handle.cc
+++ b/mojo/edk/platform/platform_handle.cc
@@ -8,6 +8,8 @@
#include <errno.h>
#include <unistd.h>
+#include "mojo/edk/platform/scoped_platform_handle.h"
+
namespace mojo {
namespace platform {
@@ -26,5 +28,15 @@ void PlatformHandle::CloseIfNecessary() {
fd = -1;
}
+ScopedPlatformHandle PlatformHandle::Duplicate() const {
+ // This is slightly redundant, but it's good to be safe (and avoid the system
+ // call and resulting EBADF).
+ if (!is_valid())
+ return ScopedPlatformHandle();
+ // Note that |dup()| returns -1 on error (which is exactly the value we use
+ // for invalid |PlatformHandle| FDs).
+ return ScopedPlatformHandle(PlatformHandle(dup(fd)));
+}
+
} // namespace embedder
} // namespace mojo
« no previous file with comments | « mojo/edk/platform/platform_handle.h ('k') | mojo/edk/platform/scoped_platform_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698