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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 size, 0, id, name, false) {} | 661 size, 0, id, name, false) {} |
662 | 662 |
663 LocalPersistentMemoryAllocator::~LocalPersistentMemoryAllocator() { | 663 LocalPersistentMemoryAllocator::~LocalPersistentMemoryAllocator() { |
664 delete [] mem_base_; | 664 delete [] mem_base_; |
665 } | 665 } |
666 | 666 |
667 | 667 |
668 //----- SharedPersistentMemoryAllocator ---------------------------------------- | 668 //----- SharedPersistentMemoryAllocator ---------------------------------------- |
669 | 669 |
670 SharedPersistentMemoryAllocator::SharedPersistentMemoryAllocator( | 670 SharedPersistentMemoryAllocator::SharedPersistentMemoryAllocator( |
671 scoped_ptr<SharedMemory> memory, | 671 std::unique_ptr<SharedMemory> memory, |
672 uint64_t id, | 672 uint64_t id, |
673 base::StringPiece name, | 673 base::StringPiece name, |
674 bool read_only) | 674 bool read_only) |
675 : PersistentMemoryAllocator(static_cast<uint8_t*>(memory->memory()), | 675 : PersistentMemoryAllocator(static_cast<uint8_t*>(memory->memory()), |
676 memory->mapped_size(), 0, id, name, read_only), | 676 memory->mapped_size(), |
| 677 0, |
| 678 id, |
| 679 name, |
| 680 read_only), |
677 shared_memory_(std::move(memory)) {} | 681 shared_memory_(std::move(memory)) {} |
678 | 682 |
679 SharedPersistentMemoryAllocator::~SharedPersistentMemoryAllocator() {} | 683 SharedPersistentMemoryAllocator::~SharedPersistentMemoryAllocator() {} |
680 | 684 |
681 // static | 685 // static |
682 bool SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( | 686 bool SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( |
683 const SharedMemory& memory) { | 687 const SharedMemory& memory) { |
684 return IsMemoryAcceptable(memory.memory(), memory.mapped_size(), 0, true); | 688 return IsMemoryAcceptable(memory.memory(), memory.mapped_size(), 0, true); |
685 } | 689 } |
686 | 690 |
687 | 691 |
688 //----- FilePersistentMemoryAllocator ------------------------------------------ | 692 //----- FilePersistentMemoryAllocator ------------------------------------------ |
689 | 693 |
690 FilePersistentMemoryAllocator::FilePersistentMemoryAllocator( | 694 FilePersistentMemoryAllocator::FilePersistentMemoryAllocator( |
691 scoped_ptr<MemoryMappedFile> file, | 695 std::unique_ptr<MemoryMappedFile> file, |
692 uint64_t id, | 696 uint64_t id, |
693 base::StringPiece name) | 697 base::StringPiece name) |
694 : PersistentMemoryAllocator(const_cast<uint8_t*>(file->data()), | 698 : PersistentMemoryAllocator(const_cast<uint8_t*>(file->data()), |
695 file->length(), 0, id, name, true), | 699 file->length(), |
| 700 0, |
| 701 id, |
| 702 name, |
| 703 true), |
696 mapped_file_(std::move(file)) {} | 704 mapped_file_(std::move(file)) {} |
697 | 705 |
698 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {} | 706 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {} |
699 | 707 |
700 // static | 708 // static |
701 bool FilePersistentMemoryAllocator::IsFileAcceptable( | 709 bool FilePersistentMemoryAllocator::IsFileAcceptable( |
702 const MemoryMappedFile& file) { | 710 const MemoryMappedFile& file) { |
703 return IsMemoryAcceptable(file.data(), file.length(), 0, true); | 711 return IsMemoryAcceptable(file.data(), file.length(), 0, true); |
704 } | 712 } |
705 | 713 |
706 } // namespace base | 714 } // namespace base |
OLD | NEW |