| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 // Our current implementation of shmem is with mmap()ing of files. | 195 // Our current implementation of shmem is with mmap()ing of files. |
| 196 // These files need to be deleted explicitly. | 196 // These files need to be deleted explicitly. |
| 197 // In practice this call is only needed for unit tests. | 197 // In practice this call is only needed for unit tests. |
| 198 bool SharedMemory::Delete(const std::string& name) { | 198 bool SharedMemory::Delete(const std::string& name) { |
| 199 FilePath path; | 199 FilePath path; |
| 200 if (!FilePathForMemoryName(name, &path)) | 200 if (!FilePathForMemoryName(name, &path)) |
| 201 return false; | 201 return false; |
| 202 | 202 |
| 203 if (file_util::PathExists(path)) { | 203 if (file_util::PathExists(path)) { |
| 204 return file_util::Delete(path, false); | 204 return base::Delete(path, false); |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Doesn't exist, so success. | 207 // Doesn't exist, so success. |
| 208 return true; | 208 return true; |
| 209 } | 209 } |
| 210 | 210 |
| 211 bool SharedMemory::Open(const std::string& name, bool read_only) { | 211 bool SharedMemory::Open(const std::string& name, bool read_only) { |
| 212 FilePath path; | 212 FilePath path; |
| 213 if (!FilePathForMemoryName(name, &path)) | 213 if (!FilePathForMemoryName(name, &path)) |
| 214 return false; | 214 return false; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 new_handle->fd = new_fd; | 379 new_handle->fd = new_fd; |
| 380 new_handle->auto_close = true; | 380 new_handle->auto_close = true; |
| 381 | 381 |
| 382 if (close_self) | 382 if (close_self) |
| 383 Close(); | 383 Close(); |
| 384 | 384 |
| 385 return true; | 385 return true; |
| 386 } | 386 } |
| 387 | 387 |
| 388 } // namespace base | 388 } // namespace base |
| OLD | NEW |