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

Side by Side Diff: base/memory/shared_memory_handle.h

Issue 1418113003: mac: Add auto-close and share-read-only functionality to SharedMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from mark. Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/memory/shared_memory_handle_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // The SharedMemoryHandle must be valid. 150 // The SharedMemoryHandle must be valid.
151 // Returns whether the SharedMemoryHandle was successfully mapped into memory. 151 // Returns whether the SharedMemoryHandle was successfully mapped into memory.
152 // On success, |memory| is an output variable that contains the start of the 152 // On success, |memory| is an output variable that contains the start of the
153 // mapped memory. 153 // mapped memory.
154 bool MapAt(off_t offset, size_t bytes, void** memory, bool read_only); 154 bool MapAt(off_t offset, size_t bytes, void** memory, bool read_only);
155 155
156 // Closes the underlying OS primitive. 156 // Closes the underlying OS primitive.
157 void Close() const; 157 void Close() const;
158 158
159 void SetOwnershipPassesToIPC(bool ownership_passes);
160 bool OwnershipPassesToIPC() const;
161
159 private: 162 private:
160 // Shared code between copy constructor and operator=. 163 // Shared code between copy constructor and operator=.
161 void CopyRelevantData(const SharedMemoryHandle& handle); 164 void CopyRelevantData(const SharedMemoryHandle& handle);
162 165
163 Type type_; 166 Type type_;
164 167
165 // Each instance of a SharedMemoryHandle is backed either by a POSIX fd or a 168 // Each instance of a SharedMemoryHandle is backed either by a POSIX fd or a
166 // mach port. |type_| determines the backing member. 169 // mach port. |type_| determines the backing member.
167 union { 170 union {
168 FileDescriptor file_descriptor_; 171 FileDescriptor file_descriptor_;
169 172
170 struct { 173 struct {
171 mach_port_t memory_object_; 174 mach_port_t memory_object_;
172 175
173 // The size of the shared memory region when |type_| is MACH. Only 176 // The size of the shared memory region when |type_| is MACH. Only
174 // relevant if |memory_object_| is not |MACH_PORT_NULL|. 177 // relevant if |memory_object_| is not |MACH_PORT_NULL|.
175 mach_vm_size_t size_; 178 mach_vm_size_t size_;
176 179
177 // The pid of the process in which |memory_object_| is usable. Only 180 // The pid of the process in which |memory_object_| is usable. Only
178 // relevant if |memory_object_| is not |MACH_PORT_NULL|. 181 // relevant if |memory_object_| is not |MACH_PORT_NULL|.
179 base::ProcessId pid_; 182 base::ProcessId pid_;
183
184 // Whether passing this object as a parameter to an IPC message passes
185 // ownership of |memory_object_| to the IPC stack. This is meant to mimic
186 // the behavior of the |auto_close| parameter of FileDescriptor.
187 // Defaults to |false|.
188 bool ownership_passes_to_ipc_;
180 }; 189 };
181 }; 190 };
182 }; 191 };
183 #endif 192 #endif
184 193
185 } // namespace base 194 } // namespace base
186 195
187 #endif // BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ 196 #endif // BASE_MEMORY_SHARED_MEMORY_HANDLE_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/shared_memory_handle_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698