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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // static | 48 // static |
49 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { | 49 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { |
50 return handle != NULL; | 50 return handle != NULL; |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 SharedMemoryHandle SharedMemory::NULLHandle() { | 54 SharedMemoryHandle SharedMemory::NULLHandle() { |
55 return NULL; | 55 return NULL; |
56 } | 56 } |
57 | 57 |
| 58 // static |
| 59 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { |
| 60 DCHECK(handle != NULL); |
| 61 ::CloseHandle(handle); |
| 62 } |
| 63 |
58 bool SharedMemory::Create(const std::wstring &name, bool read_only, | 64 bool SharedMemory::Create(const std::wstring &name, bool read_only, |
59 bool open_existing, size_t size) { | 65 bool open_existing, size_t size) { |
60 DCHECK(mapped_file_ == NULL); | 66 DCHECK(mapped_file_ == NULL); |
61 | 67 |
62 name_ = name; | 68 name_ = name; |
63 read_only_ = read_only; | 69 read_only_ = read_only; |
64 mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, | 70 mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, |
65 read_only_ ? PAGE_READONLY : PAGE_READWRITE, 0, static_cast<DWORD>(size), | 71 read_only_ ? PAGE_READONLY : PAGE_READWRITE, 0, static_cast<DWORD>(size), |
66 name.empty() ? NULL : name.c_str()); | 72 name.empty() ? NULL : name.c_str()); |
67 if (!mapped_file_) | 73 if (!mapped_file_) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 void SharedMemory::Unlock() { | 182 void SharedMemory::Unlock() { |
177 DCHECK(lock_ != NULL); | 183 DCHECK(lock_ != NULL); |
178 ReleaseMutex(lock_); | 184 ReleaseMutex(lock_); |
179 } | 185 } |
180 | 186 |
181 SharedMemoryHandle SharedMemory::handle() const { | 187 SharedMemoryHandle SharedMemory::handle() const { |
182 return mapped_file_; | 188 return mapped_file_; |
183 } | 189 } |
184 | 190 |
185 } // namespace base | 191 } // namespace base |
OLD | NEW |