Commit 01fc3dec authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

mojo: Add platform-agnostic PlatformFile accessors to PlatformHandle

Bug: 710376, 778317
Change-Id: Ifc5cd2a0d961c3503a7732252398cdd24f30fcf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2053929Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741226}
parent 25d1a370
......@@ -6,6 +6,7 @@
#define MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_HANDLE_H_
#include "base/component_export.h"
#include "base/files/platform_file.h"
#include "base/logging.h"
#include "base/macros.h"
#include "build/build_config.h"
......@@ -184,6 +185,34 @@ class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformHandle {
}
#endif
bool is_valid_platform_file() const {
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
return is_valid_fd();
#elif defined(OS_WIN)
return is_valid_handle();
#else
#error "Unsupported platform"
#endif
}
base::ScopedPlatformFile TakePlatformFile() {
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
return TakeFD();
#elif defined(OS_WIN)
return TakeHandle();
#else
#error "Unsupported platform"
#endif
}
base::PlatformFile ReleasePlatformFile() WARN_UNUSED_RESULT {
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
return ReleaseFD();
#elif defined(OS_WIN)
return ReleaseHandle();
#else
#error "Unsupported platform"
#endif
}
private:
Type type_ = Type::kNone;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment