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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 257 } |
258 | 258 |
259 bool SharedMemory::Open(const std::string& name, bool read_only) { | 259 bool SharedMemory::Open(const std::string& name, bool read_only) { |
260 FilePath path; | 260 FilePath path; |
261 if (!FilePathForMemoryName(name, &path)) | 261 if (!FilePathForMemoryName(name, &path)) |
262 return false; | 262 return false; |
263 | 263 |
264 read_only_ = read_only; | 264 read_only_ = read_only; |
265 | 265 |
266 const char *mode = read_only ? "r" : "r+"; | 266 const char *mode = read_only ? "r" : "r+"; |
267 ScopedFILE fp(base::OpenFile(path, mode)); | 267 ScopedFILE fp(file_util::OpenFile(path, mode)); |
268 int readonly_fd_storage = -1; | 268 int readonly_fd_storage = -1; |
269 ScopedFD readonly_fd(&readonly_fd_storage); | 269 ScopedFD readonly_fd(&readonly_fd_storage); |
270 *readonly_fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY)); | 270 *readonly_fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY)); |
271 if (*readonly_fd < 0) { | 271 if (*readonly_fd < 0) { |
272 DPLOG(ERROR) << "open(\"" << path.value() << "\", O_RDONLY) failed"; | 272 DPLOG(ERROR) << "open(\"" << path.value() << "\", O_RDONLY) failed"; |
273 } | 273 } |
274 return PrepareMapFile(fp.Pass(), readonly_fd.Pass()); | 274 return PrepareMapFile(fp.Pass(), readonly_fd.Pass()); |
275 } | 275 } |
276 | 276 |
277 #endif // !defined(OS_ANDROID) | 277 #endif // !defined(OS_ANDROID) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 new_handle->fd = new_fd; | 459 new_handle->fd = new_fd; |
460 new_handle->auto_close = true; | 460 new_handle->auto_close = true; |
461 | 461 |
462 if (close_self) | 462 if (close_self) |
463 Close(); | 463 Close(); |
464 | 464 |
465 return true; | 465 return true; |
466 } | 466 } |
467 | 467 |
468 } // namespace base | 468 } // namespace base |
OLD | NEW |