OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |