| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 272 | 272 | 
| 273 #endif  // !defined(OS_ANDROID) | 273 #endif  // !defined(OS_ANDROID) | 
| 274 | 274 | 
| 275 bool SharedMemory::MapAt(off_t offset, size_t bytes) { | 275 bool SharedMemory::MapAt(off_t offset, size_t bytes) { | 
| 276   if (mapped_file_ == -1) | 276   if (mapped_file_ == -1) | 
| 277     return false; | 277     return false; | 
| 278 | 278 | 
| 279   if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) | 279   if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) | 
| 280     return false; | 280     return false; | 
| 281 | 281 | 
|  | 282   if (memory_) | 
|  | 283     return false; | 
|  | 284 | 
| 282 #if defined(OS_ANDROID) | 285 #if defined(OS_ANDROID) | 
| 283   // On Android, Map can be called with a size and offset of zero to use the | 286   // On Android, Map can be called with a size and offset of zero to use the | 
| 284   // ashmem-determined size. | 287   // ashmem-determined size. | 
| 285   if (bytes == 0) { | 288   if (bytes == 0) { | 
| 286     DCHECK_EQ(0, offset); | 289     DCHECK_EQ(0, offset); | 
| 287     int ashmem_bytes = ashmem_get_size_region(mapped_file_); | 290     int ashmem_bytes = ashmem_get_size_region(mapped_file_); | 
| 288     if (ashmem_bytes < 0) | 291     if (ashmem_bytes < 0) | 
| 289       return false; | 292       return false; | 
| 290     bytes = ashmem_bytes; | 293     bytes = ashmem_bytes; | 
| 291   } | 294   } | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 455   new_handle->fd = new_fd; | 458   new_handle->fd = new_fd; | 
| 456   new_handle->auto_close = true; | 459   new_handle->auto_close = true; | 
| 457 | 460 | 
| 458   if (close_self) | 461   if (close_self) | 
| 459     Close(); | 462     Close(); | 
| 460 | 463 | 
| 461   return true; | 464   return true; | 
| 462 } | 465 } | 
| 463 | 466 | 
| 464 }  // namespace base | 467 }  // namespace base | 
| OLD | NEW | 
|---|