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/memory/shared_memory.h" | 5 #include "base/memory/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/strings/utf_string_conversions.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 | 11 |
12 // Returns the length of the memory section starting at the supplied address. | 12 // Returns the length of the memory section starting at the supplied address. |
13 size_t GetMemorySectionSize(void* address) { | 13 size_t GetMemorySectionSize(void* address) { |
14 MEMORY_BASIC_INFORMATION memory_info; | 14 MEMORY_BASIC_INFORMATION memory_info; |
15 if (!::VirtualQuery(address, &memory_info, sizeof(memory_info))) | 15 if (!::VirtualQuery(address, &memory_info, sizeof(memory_info))) |
16 return 0; | 16 return 0; |
17 return memory_info.RegionSize - (static_cast<char*>(address) - | 17 return memory_info.RegionSize - (static_cast<char*>(address) - |
18 static_cast<char*>(memory_info.AllocationBase)); | 18 static_cast<char*>(memory_info.AllocationBase)); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 void SharedMemory::Unlock() { | 251 void SharedMemory::Unlock() { |
252 DCHECK(lock_ != NULL); | 252 DCHECK(lock_ != NULL); |
253 ReleaseMutex(lock_); | 253 ReleaseMutex(lock_); |
254 } | 254 } |
255 | 255 |
256 SharedMemoryHandle SharedMemory::handle() const { | 256 SharedMemoryHandle SharedMemory::handle() const { |
257 return mapped_file_; | 257 return mapped_file_; |
258 } | 258 } |
259 | 259 |
260 } // namespace base | 260 } // namespace base |
OLD | NEW |