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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 void SharedMemory::Lock() { | 199 void SharedMemory::Lock() { |
200 Lock(INFINITE, NULL); | 200 Lock(INFINITE, NULL); |
201 } | 201 } |
202 | 202 |
203 bool SharedMemory::Lock(uint32 timeout_ms, SECURITY_ATTRIBUTES* sec_attr) { | 203 bool SharedMemory::Lock(uint32 timeout_ms, SECURITY_ATTRIBUTES* sec_attr) { |
204 if (lock_ == NULL) { | 204 if (lock_ == NULL) { |
205 std::wstring name = name_; | 205 std::wstring name = name_; |
206 name.append(L"lock"); | 206 name.append(L"lock"); |
207 lock_ = CreateMutex(sec_attr, FALSE, name.c_str()); | 207 lock_ = CreateMutex(sec_attr, FALSE, name.c_str()); |
208 if (lock_ == NULL) { | 208 if (lock_ == NULL) { |
209 PLOG(ERROR) << "Could not create mutex."; | 209 DPLOG(ERROR) << "Could not create mutex."; |
210 return false; // there is nothing good we can do here. | 210 return false; // there is nothing good we can do here. |
211 } | 211 } |
212 } | 212 } |
213 DWORD result = WaitForSingleObject(lock_, timeout_ms); | 213 DWORD result = WaitForSingleObject(lock_, timeout_ms); |
214 | 214 |
215 // Return false for WAIT_ABANDONED, WAIT_TIMEOUT or WAIT_FAILED. | 215 // Return false for WAIT_ABANDONED, WAIT_TIMEOUT or WAIT_FAILED. |
216 return (result == WAIT_OBJECT_0); | 216 return (result == WAIT_OBJECT_0); |
217 } | 217 } |
218 | 218 |
219 void SharedMemory::Unlock() { | 219 void SharedMemory::Unlock() { |
220 DCHECK(lock_ != NULL); | 220 DCHECK(lock_ != NULL); |
221 ReleaseMutex(lock_); | 221 ReleaseMutex(lock_); |
222 } | 222 } |
223 | 223 |
224 SharedMemoryHandle SharedMemory::handle() const { | 224 SharedMemoryHandle SharedMemory::handle() const { |
225 return mapped_file_; | 225 return mapped_file_; |
226 } | 226 } |
227 | 227 |
228 } // namespace base | 228 } // namespace base |
OLD | NEW |