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

Unified Diff: ipc/ipc_platform_file.cc

Issue 2846293002: Make PlatformFileForTransit its own class on Windows. (Closed)
Patch Set: Change message serialization to write nothing if the handle isn't valid. Created 3 years, 8 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 | « ipc/ipc_platform_file.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_platform_file.cc
diff --git a/ipc/ipc_platform_file.cc b/ipc/ipc_platform_file.cc
index dbcfddcc779e69ff8fab92b1523c1551ada522e9..db5f8e523463731a1c0d03c0a40bdba271d73bb9 100644
--- a/ipc/ipc_platform_file.cc
+++ b/ipc/ipc_platform_file.cc
@@ -11,6 +11,32 @@
namespace IPC {
+#if defined(OS_WIN)
+PlatformFileForTransit::PlatformFileForTransit() : handle_(nullptr) {}
+
+PlatformFileForTransit::PlatformFileForTransit(HANDLE handle)
+ : handle_(handle) {}
+
+bool PlatformFileForTransit::operator==(
+ const PlatformFileForTransit& platform_file) const {
+ return handle_ == platform_file.handle_;
+}
+
+bool PlatformFileForTransit::operator!=(
+ const PlatformFileForTransit& platform_file) const {
+ return !(*this == platform_file);
+}
+
+HANDLE PlatformFileForTransit::GetHandle() const {
+ return handle_;
+}
+
+bool PlatformFileForTransit::IsValid() const {
+ return handle_ != nullptr;
+}
+
+#endif // defined(OS_WIN)
+
PlatformFileForTransit GetPlatformFileForTransit(base::PlatformFile handle,
bool close_source_handle) {
#if defined(OS_WIN)
@@ -24,10 +50,7 @@ PlatformFileForTransit GetPlatformFileForTransit(base::PlatformFile handle,
return IPC::InvalidPlatformFileForTransit();
}
- IPC::PlatformFileForTransit out_handle = IPC::PlatformFileForTransit(
- raw_handle, base::GetCurrentProcId());
- out_handle.SetOwnershipPassesToIPC(true);
- return out_handle;
+ return IPC::PlatformFileForTransit(raw_handle);
#elif defined(OS_POSIX)
// If asked to close the source, we can simply re-use the source fd instead of
// dup()ing and close()ing.
« no previous file with comments | « ipc/ipc_platform_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698