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

Side by Side Diff: base/shared_memory_win.cc

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, 10 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 | Annotate | Revision Log
« no previous file with comments | « base/shared_memory_unittest.cc ('k') | base/stats_table_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "base/shared_memory.h" 5 #include "base/shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win_util.h" 8 #include "base/win_util.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Check if the shared memory pre-exists. 60 // Check if the shared memory pre-exists.
61 if (GetLastError() == ERROR_ALREADY_EXISTS && !open_existing) { 61 if (GetLastError() == ERROR_ALREADY_EXISTS && !open_existing) {
62 Close(); 62 Close();
63 return false; 63 return false;
64 } 64 }
65 max_size_ = size; 65 max_size_ = size;
66 return true; 66 return true;
67 } 67 }
68 68
69 bool SharedMemory::Delete(const std::wstring& name) {
70 // intentionally empty -- there is nothing for us to do on Windows.
71 return true;
72 }
73
69 bool SharedMemory::Open(const std::wstring &name, bool read_only) { 74 bool SharedMemory::Open(const std::wstring &name, bool read_only) {
70 DCHECK(mapped_file_ == NULL); 75 DCHECK(mapped_file_ == NULL);
71 76
72 name_ = name; 77 name_ = name;
73 read_only_ = read_only; 78 read_only_ = read_only;
74 mapped_file_ = OpenFileMapping( 79 mapped_file_ = OpenFileMapping(
75 read_only_ ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS, false, 80 read_only_ ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS, false,
76 name.empty() ? NULL : name.c_str()); 81 name.empty() ? NULL : name.c_str());
77 if (mapped_file_ != NULL) { 82 if (mapped_file_ != NULL) {
78 // Note: size_ is not set in this case. 83 // Note: size_ is not set in this case.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 162 }
158 WaitForSingleObject(lock_, INFINITE); 163 WaitForSingleObject(lock_, INFINITE);
159 } 164 }
160 165
161 void SharedMemory::Unlock() { 166 void SharedMemory::Unlock() {
162 DCHECK(lock_ != NULL); 167 DCHECK(lock_ != NULL);
163 ReleaseMutex(lock_); 168 ReleaseMutex(lock_);
164 } 169 }
165 170
166 } // namespace base 171 } // namespace base
OLDNEW
« no previous file with comments | « base/shared_memory_unittest.cc ('k') | base/stats_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698