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

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

Issue 2849633002: Get rid of base::SharedMemory::NULLHandle(); (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | base/memory/shared_memory_handle.h » ('j') | ui/surface/transport_dib.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // that |read_only| matches the permissions of the handle. 84 // that |read_only| matches the permissions of the handle.
85 SharedMemory(const SharedMemoryHandle& handle, bool read_only); 85 SharedMemory(const SharedMemoryHandle& handle, bool read_only);
86 86
87 // Closes any open files. 87 // Closes any open files.
88 ~SharedMemory(); 88 ~SharedMemory();
89 89
90 // Return true iff the given handle is valid (i.e. not the distingished 90 // Return true iff the given handle is valid (i.e. not the distingished
91 // invalid value; NULL for a HANDLE and -1 for a file descriptor) 91 // invalid value; NULL for a HANDLE and -1 for a file descriptor)
92 static bool IsHandleValid(const SharedMemoryHandle& handle); 92 static bool IsHandleValid(const SharedMemoryHandle& handle);
93 93
94 // Returns invalid handle (see comment above for exact definition).
95 static SharedMemoryHandle NULLHandle();
96
97 // Closes a shared memory handle. 94 // Closes a shared memory handle.
98 static void CloseHandle(const SharedMemoryHandle& handle); 95 static void CloseHandle(const SharedMemoryHandle& handle);
99 96
100 // Returns the maximum number of handles that can be open at once per process. 97 // Returns the maximum number of handles that can be open at once per process.
101 static size_t GetHandleLimit(); 98 static size_t GetHandleLimit();
102 99
103 // Duplicates The underlying OS primitive. Returns NULLHandle() on failure. 100 // Duplicates The underlying OS primitive. Returns an invalid handle on
104 // The caller is responsible for destroying the duplicated OS primitive. 101 // failure. The caller is responsible for destroying the duplicated OS
102 // primitive.
105 static SharedMemoryHandle DuplicateHandle(const SharedMemoryHandle& handle); 103 static SharedMemoryHandle DuplicateHandle(const SharedMemoryHandle& handle);
106 104
107 #if defined(OS_POSIX) 105 #if defined(OS_POSIX)
108 // This method requires that the SharedMemoryHandle is backed by a POSIX fd. 106 // This method requires that the SharedMemoryHandle is backed by a POSIX fd.
109 static int GetFdFromSharedMemoryHandle(const SharedMemoryHandle& handle); 107 static int GetFdFromSharedMemoryHandle(const SharedMemoryHandle& handle);
110 #endif 108 #endif
111 109
112 #if defined(OS_POSIX) && !defined(OS_ANDROID) 110 #if defined(OS_POSIX) && !defined(OS_ANDROID)
113 // Gets the size of the shared memory region referred to by |handle|. 111 // Gets the size of the shared memory region referred to by |handle|.
114 // Returns false on a failure to determine the size. On success, populates the 112 // Returns false on a failure to determine the size. On success, populates the
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 void* memory_; 312 void* memory_;
315 bool read_only_; 313 bool read_only_;
316 size_t requested_size_; 314 size_t requested_size_;
317 315
318 DISALLOW_COPY_AND_ASSIGN(SharedMemory); 316 DISALLOW_COPY_AND_ASSIGN(SharedMemory);
319 }; 317 };
320 318
321 } // namespace base 319 } // namespace base
322 320
323 #endif // BASE_MEMORY_SHARED_MEMORY_H_ 321 #endif // BASE_MEMORY_SHARED_MEMORY_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/shared_memory_handle.h » ('j') | ui/surface/transport_dib.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698