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 <mach/mach_vm.h> | 9 #include <mach/mach_vm.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 struct stat stat; | 324 struct stat stat; |
325 if (fstat(fileno(fp.get()), &stat) != 0) | 325 if (fstat(fileno(fp.get()), &stat) != 0) |
326 return false; | 326 return false; |
327 const size_t current_size = stat.st_size; | 327 const size_t current_size = stat.st_size; |
328 if (current_size != options.size) { | 328 if (current_size != options.size) { |
329 if (HANDLE_EINTR(ftruncate(fileno(fp.get()), options.size)) != 0) | 329 if (HANDLE_EINTR(ftruncate(fileno(fp.get()), options.size)) != 0) |
330 return false; | 330 return false; |
331 } | 331 } |
332 requested_size_ = options.size; | 332 requested_size_ = options.size; |
333 | 333 |
334 return PrepareMapFile(fp.Pass(), readonly_fd.Pass()); | 334 return PrepareMapFile(std::move(fp), std::move(readonly_fd)); |
335 } | 335 } |
336 | 336 |
337 bool SharedMemory::MapAt(off_t offset, size_t bytes) { | 337 bool SharedMemory::MapAt(off_t offset, size_t bytes) { |
338 if (!shm_.IsValid()) | 338 if (!shm_.IsValid()) |
339 return false; | 339 return false; |
340 if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) | 340 if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) |
341 return false; | 341 return false; |
342 if (memory_) | 342 if (memory_) |
343 return false; | 343 return false; |
344 | 344 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 491 |
492 if (close_self) { | 492 if (close_self) { |
493 Unmap(); | 493 Unmap(); |
494 Close(); | 494 Close(); |
495 } | 495 } |
496 | 496 |
497 return true; | 497 return true; |
498 } | 498 } |
499 | 499 |
500 } // namespace base | 500 } // namespace base |
OLD | NEW |