From b6413b49b4a1bf216bbc70cc330e905c42db5c5b Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Wed, 29 Sep 2010 20:32:22 +0000 Subject: shared_memory: remove wstrings, fix callers. BUG=23581 TEST=compiles Review URL: http://codereview.chromium.org/3555002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60985 0039d316-1c4b-4281-b951-d872f2087c98 --- base/shared_memory_posix.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'base/shared_memory_posix.cc') diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc index 2dae8af..32b3dae7 100644 --- a/base/shared_memory_posix.cc +++ b/base/shared_memory_posix.cc @@ -77,7 +77,7 @@ void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { close(handle.fd); } -bool SharedMemory::Create(const std::wstring &name, bool read_only, +bool SharedMemory::Create(const std::string& name, bool read_only, bool open_existing, uint32 size) { read_only_ = read_only; @@ -96,7 +96,7 @@ bool SharedMemory::Create(const std::wstring &name, bool read_only, // Our current implementation of shmem is with mmap()ing of files. // These files need to be deleted explicitly. // In practice this call is only needed for unit tests. -bool SharedMemory::Delete(const std::wstring& name) { +bool SharedMemory::Delete(const std::string& name) { FilePath path; if (!FilePathForMemoryName(name, &path)) return false; @@ -109,7 +109,7 @@ bool SharedMemory::Delete(const std::wstring& name) { return true; } -bool SharedMemory::Open(const std::wstring &name, bool read_only) { +bool SharedMemory::Open(const std::string& name, bool read_only) { read_only_ = read_only; int posix_flags = 0; @@ -118,22 +118,21 @@ bool SharedMemory::Open(const std::wstring &name, bool read_only) { return CreateOrOpen(name, posix_flags, 0); } -// For the given shmem named |memname|, return a filename to mmap() +// For the given shmem named |mem_name|, return a filename to mmap() // (and possibly create). Modifies |filename|. Return false on // error, or true of we are happy. -bool SharedMemory::FilePathForMemoryName(const std::wstring& memname, +bool SharedMemory::FilePathForMemoryName(const std::string& mem_name, FilePath* path) { // mem_name will be used for a filename; make sure it doesn't // contain anything which will confuse us. - DCHECK(memname.find_first_of(L"/") == std::string::npos); - DCHECK(memname.find_first_of(L"\0") == std::string::npos); + DCHECK(mem_name.find('/') == std::string::npos); + DCHECK(mem_name.find('\0') == std::string::npos); FilePath temp_dir; - if (file_util::GetShmemTempDir(&temp_dir) == false) + if (!file_util::GetShmemTempDir(&temp_dir)) return false; - *path = temp_dir.AppendASCII("com.google.chrome.shmem." + - WideToUTF8(memname)); + *path = temp_dir.AppendASCII("com.google.chrome.shmem." + mem_name); return true; } @@ -143,7 +142,7 @@ bool SharedMemory::FilePathForMemoryName(const std::wstring& memname, // 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 FilePathForMemoryName(). -bool SharedMemory::CreateOrOpen(const std::wstring &name, +bool SharedMemory::CreateOrOpen(const std::string& name, int posix_flags, uint32 size) { DCHECK(mapped_file_ == -1); @@ -151,7 +150,7 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name, FILE *fp; FilePath path; - if (name == L"") { + if (name.empty()) { // It doesn't make sense to have a read-only private piece of shmem DCHECK(posix_flags & (O_RDWR | O_WRONLY)); -- cgit v1.1