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 <aclapi.h> | 7 #include <aclapi.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 Unmap(); | 164 Unmap(); |
165 Close(); | 165 Close(); |
166 } | 166 } |
167 | 167 |
168 // static | 168 // static |
169 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { | 169 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { |
170 return handle.IsValid(); | 170 return handle.IsValid(); |
171 } | 171 } |
172 | 172 |
173 // static | 173 // static |
174 SharedMemoryHandle SharedMemory::NULLHandle() { | |
175 return SharedMemoryHandle(); | |
176 } | |
177 | |
178 // static | |
179 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { | 174 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { |
180 handle.Close(); | 175 handle.Close(); |
181 } | 176 } |
182 | 177 |
183 // static | 178 // static |
184 size_t SharedMemory::GetHandleLimit() { | 179 size_t SharedMemory::GetHandleLimit() { |
185 // Rounded down from value reported here: | 180 // Rounded down from value reported here: |
186 // http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx | 181 // http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx |
187 return static_cast<size_t>(1 << 23); | 182 return static_cast<size_t>(1 << 23); |
188 } | 183 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 382 |
388 SharedMemoryHandle SharedMemory::TakeHandle() { | 383 SharedMemoryHandle SharedMemory::TakeHandle() { |
389 SharedMemoryHandle handle(mapped_file_.Take(), base::GetCurrentProcId()); | 384 SharedMemoryHandle handle(mapped_file_.Take(), base::GetCurrentProcId()); |
390 handle.SetOwnershipPassesToIPC(true); | 385 handle.SetOwnershipPassesToIPC(true); |
391 memory_ = nullptr; | 386 memory_ = nullptr; |
392 mapped_size_ = 0; | 387 mapped_size_ = 0; |
393 return handle; | 388 return handle; |
394 } | 389 } |
395 | 390 |
396 } // namespace base | 391 } // namespace base |
OLD | NEW |