Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/mman.h> | 9 #include <sys/mman.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 return SharedMemoryHandle(); | 92 return SharedMemoryHandle(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // static | 95 // static |
| 96 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { | 96 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { |
| 97 DCHECK_GE(handle.fd, 0); | 97 DCHECK_GE(handle.fd, 0); |
| 98 if (HANDLE_EINTR(close(handle.fd)) < 0) | 98 if (HANDLE_EINTR(close(handle.fd)) < 0) |
| 99 DPLOG(ERROR) << "close"; | 99 DPLOG(ERROR) << "close"; |
| 100 } | 100 } |
| 101 | 101 |
| 102 //static | |
| 103 SharedMemoryHandle SharedMemory::DuplicateHandle( | |
| 104 const SharedMemoryHandle& handle) { | |
| 105 SharedMemoryHandle result; | |
| 106 result.fd = dup(handle.fd); | |
|
piman
2013/06/05 00:30:55
nit: HANDLE_EINTR
slavi
2013/06/06 23:02:47
Done.
| |
| 107 result.auto_close = false; | |
|
piman
2013/06/05 00:30:55
nit: make that true
It doesn't have an effect in m
slavi
2013/06/06 23:02:47
Done.
| |
| 108 return result; | |
| 109 } | |
| 110 | |
| 102 // static | 111 // static |
| 103 size_t SharedMemory::GetHandleLimit() { | 112 size_t SharedMemory::GetHandleLimit() { |
| 104 return base::GetMaxFds(); | 113 return base::GetMaxFds(); |
| 105 } | 114 } |
| 106 | 115 |
| 107 bool SharedMemory::CreateAndMapAnonymous(size_t size) { | 116 bool SharedMemory::CreateAndMapAnonymous(size_t size) { |
| 108 return CreateAnonymous(size) && Map(size); | 117 return CreateAnonymous(size) && Map(size); |
| 109 } | 118 } |
| 110 | 119 |
| 111 #if !defined(OS_ANDROID) | 120 #if !defined(OS_ANDROID) |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 new_handle->fd = new_fd; | 388 new_handle->fd = new_fd; |
| 380 new_handle->auto_close = true; | 389 new_handle->auto_close = true; |
| 381 | 390 |
| 382 if (close_self) | 391 if (close_self) |
| 383 Close(); | 392 Close(); |
| 384 | 393 |
| 385 return true; | 394 return true; |
| 386 } | 395 } |
| 387 | 396 |
| 388 } // namespace base | 397 } // namespace base |
| OLD | NEW |