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 19 matching lines...) Expand all Loading... |
30 #include "third_party/ashmem/ashmem.h" | 30 #include "third_party/ashmem/ashmem.h" |
31 #endif | 31 #endif |
32 | 32 |
33 namespace base { | 33 namespace base { |
34 | 34 |
35 SharedMemory::SharedMemory() | 35 SharedMemory::SharedMemory() |
36 : mapped_size_(0), memory_(NULL), read_only_(false), requested_size_(0) {} | 36 : mapped_size_(0), memory_(NULL), read_only_(false), requested_size_(0) {} |
37 | 37 |
38 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) | 38 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) |
39 : shm_(handle), | 39 : shm_(handle), |
40 | |
41 mapped_size_(0), | 40 mapped_size_(0), |
42 memory_(NULL), | 41 memory_(NULL), |
43 read_only_(read_only), | 42 read_only_(read_only), |
44 requested_size_(0) {} | 43 requested_size_(0) {} |
45 | 44 |
46 SharedMemory::~SharedMemory() { | 45 SharedMemory::~SharedMemory() { |
47 Unmap(); | 46 Unmap(); |
48 Close(); | 47 Close(); |
49 } | 48 } |
50 | 49 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 struct stat file_stat; | 372 struct stat file_stat; |
374 if (HANDLE_EINTR( | 373 if (HANDLE_EINTR( |
375 ::fstat(static_cast<int>(handle().GetHandle()), &file_stat)) != 0) | 374 ::fstat(static_cast<int>(handle().GetHandle()), &file_stat)) != 0) |
376 return false; | 375 return false; |
377 id->first = file_stat.st_dev; | 376 id->first = file_stat.st_dev; |
378 id->second = file_stat.st_ino; | 377 id->second = file_stat.st_ino; |
379 return true; | 378 return true; |
380 } | 379 } |
381 | 380 |
382 } // namespace base | 381 } // namespace base |
OLD | NEW |