| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ | 5 #ifndef BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ |
| 6 #define BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ | 6 #define BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/trace_event/memory_allocator_dump_guid.h" |
| 10 #include "base/unguessable_token.h" | 11 #include "base/unguessable_token.h" |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 | 13 |
| 13 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 14 #include <windows.h> | 15 #include <windows.h> |
| 15 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
| 16 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 17 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
| 17 #include <mach/mach.h> | 18 #include <mach/mach.h> |
| 18 #include "base/base_export.h" | 19 #include "base/base_export.h" |
| 19 #include "base/file_descriptor_posix.h" | 20 #include "base/file_descriptor_posix.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 static SharedMemoryHandle ImportHandle(int fd, size_t size); | 156 static SharedMemoryHandle ImportHandle(int fd, size_t size); |
| 156 | 157 |
| 157 // Returns the underlying OS resource. | 158 // Returns the underlying OS resource. |
| 158 int GetHandle() const; | 159 int GetHandle() const; |
| 159 | 160 |
| 160 // Invalidates [but doesn't close] the underlying OS resource. This will leak | 161 // Invalidates [but doesn't close] the underlying OS resource. This will leak |
| 161 // unless the caller is careful. | 162 // unless the caller is careful. |
| 162 int Release(); | 163 int Release(); |
| 163 #endif | 164 #endif |
| 164 | 165 |
| 166 std::string GetGUIDNameForTracing() const; |
| 167 |
| 168 trace_event::MemoryAllocatorDumpGuid GetGUIDForTracing() const; |
| 169 |
| 165 private: | 170 private: |
| 166 #if defined(OS_MACOSX) && !defined(OS_IOS) | 171 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 167 friend class SharedMemory; | 172 friend class SharedMemory; |
| 168 | 173 |
| 169 Type type_ = MACH; | 174 Type type_ = MACH; |
| 170 | 175 |
| 171 // Each instance of a SharedMemoryHandle is backed either by a POSIX fd or a | 176 // Each instance of a SharedMemoryHandle is backed either by a POSIX fd or a |
| 172 // mach port. |type_| determines the backing member. | 177 // mach port. |type_| determines the backing member. |
| 173 union { | 178 union { |
| 174 FileDescriptor file_descriptor_; | 179 FileDescriptor file_descriptor_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 198 | 203 |
| 199 base::UnguessableToken guid_; | 204 base::UnguessableToken guid_; |
| 200 | 205 |
| 201 // The size of the region referenced by the SharedMemoryHandle. | 206 // The size of the region referenced by the SharedMemoryHandle. |
| 202 size_t size_ = 0; | 207 size_t size_ = 0; |
| 203 }; | 208 }; |
| 204 | 209 |
| 205 } // namespace base | 210 } // namespace base |
| 206 | 211 |
| 207 #endif // BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ | 212 #endif // BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ |
| OLD | NEW |