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

Unified Diff: base/shared_memory.h

Issue 19724: Properly honor base::SharedMemory semantics for name="" to mean... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_win.cc ('k') | base/shared_memory_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/shared_memory.h
===================================================================
--- base/shared_memory.h (revision 8817)
+++ base/shared_memory.h (working copy)
@@ -24,6 +24,10 @@
typedef HANDLE SharedMemoryLock;
#elif defined(OS_POSIX)
typedef int SharedMemoryHandle;
+// TODO(port): these semaphores can leak if we crash, causing
+// autobuilder problems. Transition to something easier to clean up
+// (e.g. lockf/flock).
+// TODO(port): make sure what we transition to is fast enough.
typedef sem_t* SharedMemoryLock;
#endif
@@ -51,12 +55,18 @@
// If read_only is true, opens the memory as read-only.
// If open_existing is true, and the shared memory already exists,
// opens the existing shared memory and ignores the size parameter.
+ // If name is the empty string, use a unique name.
// Returns true on success, false on failure.
bool Create(const std::wstring& name, bool read_only, bool open_existing,
size_t size);
+ // Deletes resources associated with a shared memory segment based on name.
+ // Not all platforms require this call.
+ bool Delete(const std::wstring& name);
+
// Opens a shared memory segment based on a name.
// If read_only is true, opens for read-only access.
+ // If name is the empty string, use a unique name.
// Returns true on success, false on failure.
bool Open(const std::wstring& name, bool read_only);
@@ -120,7 +130,9 @@
private:
#if defined(OS_POSIX)
- bool CreateOrOpen(const std::wstring &name, int posix_flags);
+ bool CreateOrOpen(const std::wstring &name, int posix_flags, size_t size);
+ bool FilenameForMemoryName(const std::wstring &memname,
+ std::wstring *filename);
#endif
bool ShareToProcessCommon(ProcessHandle process,
SharedMemoryHandle* new_handle,
@@ -132,6 +144,9 @@
bool read_only_;
size_t max_size_;
SharedMemoryLock lock_;
+#if defined(OS_POSIX)
+ std::string sem_name_;
+#endif
DISALLOW_EVIL_CONSTRUCTORS(SharedMemory);
};
« no previous file with comments | « base/file_util_win.cc ('k') | base/shared_memory_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698