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 #ifndef BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 5 #ifndef BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <atomic> | 10 #include <atomic> |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/atomicops.h" | 13 #include "base/atomicops.h" |
14 #include "base/base_export.h" | 14 #include "base/base_export.h" |
| 15 #include "base/files/file_path.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 | 21 |
21 class HistogramBase; | 22 class HistogramBase; |
22 class MemoryMappedFile; | 23 class MemoryMappedFile; |
23 class SharedMemory; | 24 class SharedMemory; |
24 | 25 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 }; | 120 }; |
120 | 121 |
121 enum : Reference { | 122 enum : Reference { |
122 kReferenceNull = 0 // A common "null" reference value. | 123 kReferenceNull = 0 // A common "null" reference value. |
123 }; | 124 }; |
124 | 125 |
125 enum : uint32_t { | 126 enum : uint32_t { |
126 kTypeIdAny = 0 // Match any type-id inside GetAsObject(). | 127 kTypeIdAny = 0 // Match any type-id inside GetAsObject(). |
127 }; | 128 }; |
128 | 129 |
| 130 // This is the standard file extension (suitable for being passed to the |
| 131 // AddExtension() method of base::FilePath) for dumps of persistent memory. |
| 132 static const base::FilePath::CharType kFileExtension[]; |
| 133 |
129 // The allocator operates on any arbitrary block of memory. Creation and | 134 // The allocator operates on any arbitrary block of memory. Creation and |
130 // persisting or sharing of that block with another process is the | 135 // persisting or sharing of that block with another process is the |
131 // responsibility of the caller. The allocator needs to know only the | 136 // responsibility of the caller. The allocator needs to know only the |
132 // block's |base| address, the total |size| of the block, and any internal | 137 // block's |base| address, the total |size| of the block, and any internal |
133 // |page| size (zero if not paged) across which allocations should not span. | 138 // |page| size (zero if not paged) across which allocations should not span. |
134 // The |id| is an arbitrary value the caller can use to identify a | 139 // The |id| is an arbitrary value the caller can use to identify a |
135 // particular memory segment. It will only be loaded during the initial | 140 // particular memory segment. It will only be loaded during the initial |
136 // creation of the segment and can be checked by the caller for consistency. | 141 // creation of the segment and can be checked by the caller for consistency. |
137 // The |name|, if provided, is used to distinguish histograms for this | 142 // The |name|, if provided, is used to distinguish histograms for this |
138 // allocator. Only the primary owner of the segment should define this value; | 143 // allocator. Only the primary owner of the segment should define this value; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 403 |
399 private: | 404 private: |
400 std::unique_ptr<MemoryMappedFile> mapped_file_; | 405 std::unique_ptr<MemoryMappedFile> mapped_file_; |
401 | 406 |
402 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator); | 407 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator); |
403 }; | 408 }; |
404 | 409 |
405 } // namespace base | 410 } // namespace base |
406 | 411 |
407 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 412 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
OLD | NEW |