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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 volatile BlockHeader queue; // Empty block for linked-list head/tail. | 110 volatile BlockHeader queue; // Empty block for linked-list head/tail. |
111 }; | 111 }; |
112 | 112 |
113 // The "queue" block header is used to detect "last node" so that zero/null | 113 // The "queue" block header is used to detect "last node" so that zero/null |
114 // can be used to indicate that it hasn't been added at all. It is part of | 114 // can be used to indicate that it hasn't been added at all. It is part of |
115 // the SharedMetadata structure which itself is always located at offset zero. | 115 // the SharedMetadata structure which itself is always located at offset zero. |
116 const PersistentMemoryAllocator::Reference | 116 const PersistentMemoryAllocator::Reference |
117 PersistentMemoryAllocator::kReferenceQueue = | 117 PersistentMemoryAllocator::kReferenceQueue = |
118 offsetof(SharedMetadata, queue); | 118 offsetof(SharedMetadata, queue); |
119 | 119 |
| 120 const base::FilePath::CharType PersistentMemoryAllocator::kFileExtension[] = |
| 121 FILE_PATH_LITERAL(".pma"); |
| 122 |
120 PersistentMemoryAllocator::Iterator::Iterator( | 123 PersistentMemoryAllocator::Iterator::Iterator( |
121 const PersistentMemoryAllocator* allocator) | 124 const PersistentMemoryAllocator* allocator) |
122 : allocator_(allocator), last_record_(kReferenceQueue), record_count_(0) {} | 125 : allocator_(allocator), last_record_(kReferenceQueue), record_count_(0) {} |
123 | 126 |
124 PersistentMemoryAllocator::Iterator::Iterator( | 127 PersistentMemoryAllocator::Iterator::Iterator( |
125 const PersistentMemoryAllocator* allocator, | 128 const PersistentMemoryAllocator* allocator, |
126 Reference starting_after) | 129 Reference starting_after) |
127 : allocator_(allocator), last_record_(starting_after), record_count_(0) { | 130 : allocator_(allocator), last_record_(starting_after), record_count_(0) { |
128 // Ensure that the starting point is a valid, iterable block (meaning it can | 131 // Ensure that the starting point is a valid, iterable block (meaning it can |
129 // be read and has a non-zero "next" pointer). | 132 // be read and has a non-zero "next" pointer). |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 762 |
760 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {} | 763 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {} |
761 | 764 |
762 // static | 765 // static |
763 bool FilePersistentMemoryAllocator::IsFileAcceptable( | 766 bool FilePersistentMemoryAllocator::IsFileAcceptable( |
764 const MemoryMappedFile& file) { | 767 const MemoryMappedFile& file) { |
765 return IsMemoryAcceptable(file.data(), file.length(), 0, true); | 768 return IsMemoryAcceptable(file.data(), file.length(), 0, true); |
766 } | 769 } |
767 | 770 |
768 } // namespace base | 771 } // namespace base |
OLD | NEW |