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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 // Our current implementation of shmem is with mmap()ing of files. | 231 // Our current implementation of shmem is with mmap()ing of files. |
232 // These files need to be deleted explicitly. | 232 // These files need to be deleted explicitly. |
233 // In practice this call is only needed for unit tests. | 233 // In practice this call is only needed for unit tests. |
234 bool SharedMemory::Delete(const std::string& name) { | 234 bool SharedMemory::Delete(const std::string& name) { |
235 FilePath path; | 235 FilePath path; |
236 if (!FilePathForMemoryName(name, &path)) | 236 if (!FilePathForMemoryName(name, &path)) |
237 return false; | 237 return false; |
238 | 238 |
239 if (PathExists(path)) | 239 if (PathExists(path)) |
240 return base::Delete(path, false); | 240 return base::DeleteFile(path, false); |
241 | 241 |
242 // Doesn't exist, so success. | 242 // Doesn't exist, so success. |
243 return true; | 243 return true; |
244 } | 244 } |
245 | 245 |
246 bool SharedMemory::Open(const std::string& name, bool read_only) { | 246 bool SharedMemory::Open(const std::string& name, bool read_only) { |
247 FilePath path; | 247 FilePath path; |
248 if (!FilePathForMemoryName(name, &path)) | 248 if (!FilePathForMemoryName(name, &path)) |
249 return false; | 249 return false; |
250 | 250 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 new_handle->fd = new_fd; | 414 new_handle->fd = new_fd; |
415 new_handle->auto_close = true; | 415 new_handle->auto_close = true; |
416 | 416 |
417 if (close_self) | 417 if (close_self) |
418 Close(); | 418 Close(); |
419 | 419 |
420 return true; | 420 return true; |
421 } | 421 } |
422 | 422 |
423 } // namespace base | 423 } // namespace base |
OLD | NEW |