summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/shared_memory.h2
-rw-r--r--base/shared_memory_posix.cc11
2 files changed, 5 insertions, 8 deletions
diff --git a/base/shared_memory.h b/base/shared_memory.h
index bd6770c..a368d9f 100644
--- a/base/shared_memory.h
+++ b/base/shared_memory.h
@@ -166,8 +166,8 @@ class SharedMemory {
SharedMemoryHandle* new_handle,
bool close_self);
- std::wstring name_;
#if defined(OS_WIN)
+ std::wstring name_;
HANDLE mapped_file_;
#elif defined(OS_POSIX)
int mapped_file_;
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 37f0c4e..2f0fe22 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -134,11 +134,12 @@ bool SharedMemory::FilenameForMemoryName(const std::wstring &memname,
return true;
}
-// Current expectation is that Cromium only really needs
-// unique/private shmem as specified by "name == L"".
-// TODO(port): confirm that assumption.
+// Chromium mostly only use the unique/private shmem as specified by
+// "name == L"". The exception is in the StatsTable.
// TODO(jrg): there is no way to "clean up" all unused named shmem if
// we restart from a crash. (That isn't a new problem, but it is a problem.)
+// In case we want to delete it later, it may be useful to save the value
+// of mem_filename after FilenameForMemoryName().
bool SharedMemory::CreateOrOpen(const std::wstring &name,
int posix_flags, size_t size) {
DCHECK(mapped_file_ == -1);
@@ -152,7 +153,6 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name,
FilePath path;
fp = file_util::CreateAndOpenTemporaryShmemFile(&path);
- name_ = UTF8ToWide(path.value());
// Deleting the file prevents anyone else from mapping it in
// (making it private), and prevents the need for cleanup (once
@@ -163,7 +163,6 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name,
if (FilenameForMemoryName(name, &mem_filename) == false)
return false;
- name_ = mem_filename;
std::string mode;
switch (posix_flags) {
case (O_RDWR | O_CREAT):
@@ -271,10 +270,8 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
void SharedMemory::Close() {
-
Unmap();
- std::string posix_name(WideToUTF8(name_));
if (mapped_file_ > 0) {
close(mapped_file_);
mapped_file_ = -1;