OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/memory_mapped_file.h" | 5 #include "base/files/memory_mapped_file.h" |
6 | 6 |
7 #include <sys/mman.h> | 7 #include <sys/mman.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/posix/eintr_wrapper.h" | |
13 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
14 | 13 |
15 namespace base { | 14 namespace base { |
16 | 15 |
17 MemoryMappedFile::MemoryMappedFile() | 16 MemoryMappedFile::MemoryMappedFile() |
18 : file_(kInvalidPlatformFileValue), | 17 : file_(kInvalidPlatformFileValue), |
19 data_(NULL), | 18 data_(NULL), |
20 length_(0) { | 19 length_(0) { |
21 } | 20 } |
22 | 21 |
(...skipping 14 matching lines...) Expand all Loading... |
37 | 36 |
38 return data_ != MAP_FAILED; | 37 return data_ != MAP_FAILED; |
39 } | 38 } |
40 | 39 |
41 void MemoryMappedFile::CloseHandles() { | 40 void MemoryMappedFile::CloseHandles() { |
42 ThreadRestrictions::AssertIOAllowed(); | 41 ThreadRestrictions::AssertIOAllowed(); |
43 | 42 |
44 if (data_ != NULL) | 43 if (data_ != NULL) |
45 munmap(data_, length_); | 44 munmap(data_, length_); |
46 if (file_ != kInvalidPlatformFileValue) | 45 if (file_ != kInvalidPlatformFileValue) |
47 ignore_result(HANDLE_EINTR(close(file_))); | 46 close(file_); |
48 | 47 |
49 data_ = NULL; | 48 data_ = NULL; |
50 length_ = 0; | 49 length_ = 0; |
51 file_ = kInvalidPlatformFileValue; | 50 file_ = kInvalidPlatformFileValue; |
52 } | 51 } |
53 | 52 |
54 } // namespace base | 53 } // namespace base |
OLD | NEW |