| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 ::CloseHandle(handle); | 93 ::CloseHandle(handle); |
| 94 } | 94 } |
| 95 | 95 |
| 96 // static | 96 // static |
| 97 size_t SharedMemory::GetHandleLimit() { | 97 size_t SharedMemory::GetHandleLimit() { |
| 98 // Rounded down from value reported here: | 98 // Rounded down from value reported here: |
| 99 // http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx | 99 // http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx |
| 100 return static_cast<size_t>(1 << 23); | 100 return static_cast<size_t>(1 << 23); |
| 101 } | 101 } |
| 102 | 102 |
| 103 SharedMemoryHandle SharedMemory::ShallowCopyHandle( |
| 104 const SharedMemoryHandle& handle) { |
| 105 return handle; |
| 106 } |
| 107 |
| 103 bool SharedMemory::CreateAndMapAnonymous(size_t size) { | 108 bool SharedMemory::CreateAndMapAnonymous(size_t size) { |
| 104 return CreateAnonymous(size) && Map(size); | 109 return CreateAnonymous(size) && Map(size); |
| 105 } | 110 } |
| 106 | 111 |
| 107 bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { | 112 bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { |
| 108 // TODO(bsy,sehr): crbug.com/210609 NaCl forces us to round up 64k here, | 113 // TODO(bsy,sehr): crbug.com/210609 NaCl forces us to round up 64k here, |
| 109 // wasting 32k per mapping on average. | 114 // wasting 32k per mapping on average. |
| 110 static const size_t kSectionMask = 65536 - 1; | 115 static const size_t kSectionMask = 65536 - 1; |
| 111 DCHECK(!options.executable); | 116 DCHECK(!options.executable); |
| 112 DCHECK(!mapped_file_); | 117 DCHECK(!mapped_file_); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 void SharedMemory::UnlockDeprecated() { | 280 void SharedMemory::UnlockDeprecated() { |
| 276 DCHECK(lock_ != NULL); | 281 DCHECK(lock_ != NULL); |
| 277 ReleaseMutex(lock_); | 282 ReleaseMutex(lock_); |
| 278 } | 283 } |
| 279 | 284 |
| 280 SharedMemoryHandle SharedMemory::handle() const { | 285 SharedMemoryHandle SharedMemory::handle() const { |
| 281 return mapped_file_; | 286 return mapped_file_; |
| 282 } | 287 } |
| 283 | 288 |
| 284 } // namespace base | 289 } // namespace base |
| OLD | NEW |