OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/metrics/persistent_memory_allocator.h" | 5 #include "base/metrics/persistent_memory_allocator.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 747 |
748 SharedPersistentMemoryAllocator::~SharedPersistentMemoryAllocator() {} | 748 SharedPersistentMemoryAllocator::~SharedPersistentMemoryAllocator() {} |
749 | 749 |
750 // static | 750 // static |
751 bool SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( | 751 bool SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( |
752 const SharedMemory& memory) { | 752 const SharedMemory& memory) { |
753 return IsMemoryAcceptable(memory.memory(), memory.mapped_size(), 0, false); | 753 return IsMemoryAcceptable(memory.memory(), memory.mapped_size(), 0, false); |
754 } | 754 } |
755 | 755 |
756 | 756 |
| 757 #if !defined(OS_NACL) |
757 //----- FilePersistentMemoryAllocator ------------------------------------------ | 758 //----- FilePersistentMemoryAllocator ------------------------------------------ |
758 | 759 |
759 FilePersistentMemoryAllocator::FilePersistentMemoryAllocator( | 760 FilePersistentMemoryAllocator::FilePersistentMemoryAllocator( |
760 std::unique_ptr<MemoryMappedFile> file, | 761 std::unique_ptr<MemoryMappedFile> file, |
761 size_t max_size, | 762 size_t max_size, |
762 uint64_t id, | 763 uint64_t id, |
763 base::StringPiece name, | 764 base::StringPiece name, |
764 bool read_only) | 765 bool read_only) |
765 : PersistentMemoryAllocator(const_cast<uint8_t*>(file->data()), | 766 : PersistentMemoryAllocator(const_cast<uint8_t*>(file->data()), |
766 max_size != 0 ? max_size : file->length(), | 767 max_size != 0 ? max_size : file->length(), |
767 0, | 768 0, |
768 id, | 769 id, |
769 name, | 770 name, |
770 read_only), | 771 read_only), |
771 mapped_file_(std::move(file)) {} | 772 mapped_file_(std::move(file)) {} |
772 | 773 |
773 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {} | 774 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {} |
774 | 775 |
775 // static | 776 // static |
776 bool FilePersistentMemoryAllocator::IsFileAcceptable( | 777 bool FilePersistentMemoryAllocator::IsFileAcceptable( |
777 const MemoryMappedFile& file, | 778 const MemoryMappedFile& file, |
778 bool read_only) { | 779 bool read_only) { |
779 return IsMemoryAcceptable(file.data(), file.length(), 0, read_only); | 780 return IsMemoryAcceptable(file.data(), file.length(), 0, read_only); |
780 } | 781 } |
| 782 #endif // !defined(OS_NACL) |
781 | 783 |
782 } // namespace base | 784 } // namespace base |
OLD | NEW |