| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_helper.h" | 5 #include "base/memory/shared_memory_helper.h" |
| 6 | 6 |
| 7 #include "base/threading/thread_restrictions.h" | 7 #include "base/threading/thread_restrictions.h" |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 if (!*fp) | 42 if (!*fp) |
| 43 return false; | 43 return false; |
| 44 | 44 |
| 45 // Deleting the file prevents anyone else from mapping it in (making it | 45 // Deleting the file prevents anyone else from mapping it in (making it |
| 46 // private), and prevents the need for cleanup (once the last fd is | 46 // private), and prevents the need for cleanup (once the last fd is |
| 47 // closed, it is truly freed). | 47 // closed, it is truly freed). |
| 48 path_unlinker.reset(path); | 48 path_unlinker.reset(path); |
| 49 | 49 |
| 50 if (options.share_read_only) { | 50 if (options.share_read_only) { |
| 51 // Also open as readonly so that we can ShareReadOnlyToProcess. | 51 // Also open as readonly so that we can GetReadOnlyHandle. |
| 52 readonly_fd->reset(HANDLE_EINTR(open(path->value().c_str(), O_RDONLY))); | 52 readonly_fd->reset(HANDLE_EINTR(open(path->value().c_str(), O_RDONLY))); |
| 53 if (!readonly_fd->is_valid()) { | 53 if (!readonly_fd->is_valid()) { |
| 54 DPLOG(ERROR) << "open(\"" << path->value() << "\", O_RDONLY) failed"; | 54 DPLOG(ERROR) << "open(\"" << path->value() << "\", O_RDONLY) failed"; |
| 55 fp->reset(); | 55 fp->reset(); |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 89 if (*mapped_file == -1) { | 89 if (*mapped_file == -1) { |
| 90 NOTREACHED() << "Call to dup failed, errno=" << errno; | 90 NOTREACHED() << "Call to dup failed, errno=" << errno; |
| 91 } | 91 } |
| 92 *readonly_mapped_file = readonly_fd.release(); | 92 *readonly_mapped_file = readonly_fd.release(); |
| 93 | 93 |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 #endif // !defined(OS_ANDROID) | 96 #endif // !defined(OS_ANDROID) |
| 97 | 97 |
| 98 } // namespace base | 98 } // namespace base |
| OLD | NEW |