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

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

Issue 2852803002: Remove base::SharedMemory::ShareToProcess. (Closed)
Patch Set: Rebase. Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef BASE_MEMORY_SHARED_MEMORY_H_
6 #define BASE_MEMORY_SHARED_MEMORY_H_ 6 #define BASE_MEMORY_SHARED_MEMORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // It is safe to call Close repeatedly. 206 // It is safe to call Close repeatedly.
207 void Close(); 207 void Close();
208 208
209 // Returns a read-only handle to this shared memory region. The caller takes 209 // Returns a read-only handle to this shared memory region. The caller takes
210 // ownership of the handle. CHECK-fails if the region wasn't Created or 210 // ownership of the handle. CHECK-fails if the region wasn't Created or
211 // Opened with share_read_only=true. When the handle is passed to the IPC 211 // Opened with share_read_only=true. When the handle is passed to the IPC
212 // subsystem, that takes ownership of the handle. As such, it's not valid to 212 // subsystem, that takes ownership of the handle. As such, it's not valid to
213 // pass the sample handle to the IPC subsystem twice. 213 // pass the sample handle to the IPC subsystem twice.
214 SharedMemoryHandle GetReadOnlyHandle(); 214 SharedMemoryHandle GetReadOnlyHandle();
215 215
216 // Shares the shared memory to another process. Attempts
217 // to create a platform-specific new_handle which can be
218 // used in a remote process to access the shared memory
219 // file. new_handle is an output parameter to receive
220 // the handle for use in the remote process.
221 // Returns true on success, false otherwise.
222 bool ShareToProcess(ProcessHandle process,
223 SharedMemoryHandle* new_handle) {
224 return ShareToProcessCommon(process, new_handle);
225 }
226
227 #if defined(OS_POSIX) && (!defined(OS_MACOSX) || defined(OS_IOS)) && \ 216 #if defined(OS_POSIX) && (!defined(OS_MACOSX) || defined(OS_IOS)) && \
228 !defined(OS_NACL) 217 !defined(OS_NACL)
229 using UniqueId = std::pair<dev_t, ino_t>; 218 using UniqueId = std::pair<dev_t, ino_t>;
230 219
231 struct UniqueIdHash { 220 struct UniqueIdHash {
232 size_t operator()(const UniqueId& id) const { 221 size_t operator()(const UniqueId& id) const {
233 return HashInts(id.first, id.second); 222 return HashInts(id.first, id.second);
234 } 223 }
235 }; 224 };
236 225
237 // Returns a unique ID for this shared memory's handle. Note this function may 226 // Returns a unique ID for this shared memory's handle. Note this function may
238 // access file system and be slow. 227 // access file system and be slow.
239 bool GetUniqueId(UniqueId* id) const; 228 bool GetUniqueId(UniqueId* id) const;
240 #endif 229 #endif
241 230
242 private: 231 private:
243 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \ 232 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \
244 (!defined(OS_MACOSX) || defined(OS_IOS)) 233 (!defined(OS_MACOSX) || defined(OS_IOS))
245 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); 234 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path);
246 #endif 235 #endif
247 236
248 #if defined(OS_MACOSX)
249 bool Share(SharedMemoryHandle* new_handle);
250 #endif
251
252 bool ShareToProcessCommon(ProcessHandle process,
253 SharedMemoryHandle* new_handle);
254
255 #if defined(OS_WIN) 237 #if defined(OS_WIN)
256 // If true indicates this came from an external source so needs extra checks 238 // If true indicates this came from an external source so needs extra checks
257 // before being mapped. 239 // before being mapped.
258 bool external_section_; 240 bool external_section_;
259 std::wstring name_; 241 std::wstring name_;
260 win::ScopedHandle mapped_file_; 242 win::ScopedHandle mapped_file_;
261 #else 243 #else
262 // The OS primitive that backs the shared memory region. 244 // The OS primitive that backs the shared memory region.
263 SharedMemoryHandle shm_; 245 SharedMemoryHandle shm_;
264 246
(...skipping 12 matching lines...) Expand all
277 void* memory_; 259 void* memory_;
278 bool read_only_; 260 bool read_only_;
279 size_t requested_size_; 261 size_t requested_size_;
280 262
281 DISALLOW_COPY_AND_ASSIGN(SharedMemory); 263 DISALLOW_COPY_AND_ASSIGN(SharedMemory);
282 }; 264 };
283 265
284 } // namespace base 266 } // namespace base
285 267
286 #endif // BASE_MEMORY_SHARED_MEMORY_H_ 268 #endif // BASE_MEMORY_SHARED_MEMORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698