Index: base/memory/shared_memory_handle.h |
diff --git a/base/memory/shared_memory_handle.h b/base/memory/shared_memory_handle.h |
index dc33eeafa11faef22f73be0d44dd30447e43118b..ed8b69bdd5ec05c8808a04cec73d0417f9f75e81 100644 |
--- a/base/memory/shared_memory_handle.h |
+++ b/base/memory/shared_memory_handle.h |
@@ -28,7 +28,40 @@ namespace base { |
// SharedMemoryHandle is a platform specific type which represents |
// the underlying OS handle to a shared memory segment. |
#if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) |
-typedef FileDescriptor SharedMemoryHandle; |
+class BASE_EXPORT SharedMemoryHandle { |
Nico
2017/04/27 16:24:44
Since they're now classes everywhere, I think it'd
erikchen
2017/04/27 17:08:10
Added a TODO.
|
+ public: |
+ // The default constructor returns an invalid SharedMemoryHandle. |
+ SharedMemoryHandle(); |
+ |
+ // This constructor is deprecated, as it fails to propagate the GUID, which |
+ // will be added in the near future. |
+ // TODO(rockot): Remove this constructor once Mojo supports GUIDs. |
+ // https://crbug.com/713763. |
+ explicit SharedMemoryHandle(const base::FileDescriptor& file_descriptor); |
+ |
+ // Creates a SharedMemoryHandle from an |fd| supplied from an external |
+ // service. |
+ static SharedMemoryHandle ImportHandle(int fd); |
Nico
2017/04/27 16:24:44
This type of thing seems to be a ctor instead of a
erikchen
2017/04/27 17:08:10
The constructors on Mac/Win will be going away. On
|
+ |
+ // Returns the underlying OS resource. |
+ int GetHandle() const; |
+ |
+ // Whether the underlying OS resource is valid. |
+ bool IsValid() const; |
+ |
+ // Closes the underlying OS resource. |
+ // The fact that this method needs to be "const" is an artifact of the |
+ // original interface for base::SharedMemory::CloseHandle. |
+ void Close() const; |
+ |
+ // Invalidates [but doesn't close] the underlying OS resource. |
Nico
2017/04/27 16:24:44
Maybe say "leak unless careful" in the comment. So
erikchen
2017/04/27 17:08:10
Done.
|
+ void Invalidate(); |
+ |
+ // Duplicates the underlying OS resource. |
+ SharedMemoryHandle Duplicate() const; |
+ |
+ FileDescriptor file_descriptor; |
Nico
2017/04/27 16:24:44
make private
erikchen
2017/04/27 17:08:10
Can't do that, Chrome IPC serialization requires t
Nico
2017/04/27 17:38:50
Add accessors for what's needed by IPC?
erikchen
2017/04/27 18:13:42
Done.
[The Chrome IPC macros don't support non-pu
|
+}; |
#elif defined(OS_WIN) |
class BASE_EXPORT SharedMemoryHandle { |
public: |