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

Unified Diff: ipc/ipc_platform_file.h

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_message_utils.cc ('k') | ipc/ipc_platform_file.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_platform_file.h
diff --git a/ipc/ipc_platform_file.h b/ipc/ipc_platform_file.h
index 15807f60b75bd87cb05d7735a568f55d40eb3c84..ea295af8c5455e1e3be788fe093b0573534419bb 100644
--- a/ipc/ipc_platform_file.h
+++ b/ipc/ipc_platform_file.h
@@ -14,17 +14,32 @@
#include "base/file_descriptor_posix.h"
#endif
-#if defined(OS_WIN)
-#include "base/memory/shared_memory_handle.h"
-#endif
-
namespace IPC {
#if defined(OS_WIN)
-// The semantics for IPC transfer of a SharedMemoryHandle are exactly the same
-// as for a PlatformFileForTransit. The object wraps a HANDLE, and has some
-// metadata that indicates the process to which the HANDLE belongs.
-using PlatformFileForTransit = base::SharedMemoryHandle;
+class IPC_EXPORT PlatformFileForTransit {
+ public:
+ // Creates an invalid platform file.
+ PlatformFileForTransit();
+
+ // Creates a platform file that takes unofficial ownership of |handle|. Note
+ // that ownership is not handled by a Scoped* class due to usage patterns of
+ // this class and its POSIX counterpart [base::FileDescriptor]. When this
+ // class is used as an input to an IPC message, the IPC subsystem will close
+ // |handle|. When this class is used as the output from an IPC message, the
+ // receiver is expected to take ownership of |handle|.
+ explicit PlatformFileForTransit(HANDLE handle);
+
+ // Comparison operators.
+ bool operator==(const PlatformFileForTransit& platform_file) const;
+ bool operator!=(const PlatformFileForTransit& platform_file) const;
+
+ HANDLE GetHandle() const;
+ bool IsValid() const;
+
+ private:
+ HANDLE handle_;
+};
#elif defined(OS_POSIX)
typedef base::FileDescriptor PlatformFileForTransit;
#endif
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | ipc/ipc_platform_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698