OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return false; | 129 return false; |
130 } | 130 } |
131 | 131 |
132 bool SharedMemory::Map(uint32 bytes) { | 132 bool SharedMemory::Map(uint32 bytes) { |
133 if (mapped_file_ == NULL) | 133 if (mapped_file_ == NULL) |
134 return false; | 134 return false; |
135 | 135 |
136 memory_ = MapViewOfFile(mapped_file_, | 136 memory_ = MapViewOfFile(mapped_file_, |
137 read_only_ ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS, 0, 0, bytes); | 137 read_only_ ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS, 0, 0, bytes); |
138 if (memory_ != NULL) { | 138 if (memory_ != NULL) { |
| 139 DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) & |
| 140 (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1)); |
139 return true; | 141 return true; |
140 } | 142 } |
141 return false; | 143 return false; |
142 } | 144 } |
143 | 145 |
144 bool SharedMemory::Unmap() { | 146 bool SharedMemory::Unmap() { |
145 if (memory_ == NULL) | 147 if (memory_ == NULL) |
146 return false; | 148 return false; |
147 | 149 |
148 UnmapViewOfFile(memory_); | 150 UnmapViewOfFile(memory_); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 void SharedMemory::Unlock() { | 217 void SharedMemory::Unlock() { |
216 DCHECK(lock_ != NULL); | 218 DCHECK(lock_ != NULL); |
217 ReleaseMutex(lock_); | 219 ReleaseMutex(lock_); |
218 } | 220 } |
219 | 221 |
220 SharedMemoryHandle SharedMemory::handle() const { | 222 SharedMemoryHandle SharedMemory::handle() const { |
221 return mapped_file_; | 223 return mapped_file_; |
222 } | 224 } |
223 | 225 |
224 } // namespace base | 226 } // namespace base |
OLD | NEW |