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 <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 Unmap(); | 51 Unmap(); |
52 Close(); | 52 Close(); |
53 } | 53 } |
54 | 54 |
55 // static | 55 // static |
56 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { | 56 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { |
57 return handle.IsValid(); | 57 return handle.IsValid(); |
58 } | 58 } |
59 | 59 |
60 // static | 60 // static |
61 SharedMemoryHandle SharedMemory::NULLHandle() { | |
62 return SharedMemoryHandle(); | |
63 } | |
64 | |
65 // static | |
66 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { | 61 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { |
67 DCHECK(handle.IsValid()); | 62 DCHECK(handle.IsValid()); |
68 handle.Close(); | 63 handle.Close(); |
69 } | 64 } |
70 | 65 |
71 // static | 66 // static |
72 size_t SharedMemory::GetHandleLimit() { | 67 size_t SharedMemory::GetHandleLimit() { |
73 return base::GetMaxFds(); | 68 return base::GetMaxFds(); |
74 } | 69 } |
75 | 70 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 struct stat file_stat; | 407 struct stat file_stat; |
413 if (HANDLE_EINTR( | 408 if (HANDLE_EINTR( |
414 ::fstat(static_cast<int>(handle().GetHandle()), &file_stat)) != 0) | 409 ::fstat(static_cast<int>(handle().GetHandle()), &file_stat)) != 0) |
415 return false; | 410 return false; |
416 id->first = file_stat.st_dev; | 411 id->first = file_stat.st_dev; |
417 id->second = file_stat.st_ino; | 412 id->second = file_stat.st_ino; |
418 return true; | 413 return true; |
419 } | 414 } |
420 | 415 |
421 } // namespace base | 416 } // namespace base |
OLD | NEW |