OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_HISTOGRAM_PERSISTENCE_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ |
6 #define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ | 6 #define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 scoped_ptr<PersistentHistogramAllocator> allocator); | 109 scoped_ptr<PersistentHistogramAllocator> allocator); |
110 static PersistentHistogramAllocator* GetGlobalAllocator(); | 110 static PersistentHistogramAllocator* GetGlobalAllocator(); |
111 | 111 |
112 // This access to the persistent allocator is only for testing; it extracts | 112 // This access to the persistent allocator is only for testing; it extracts |
113 // the current allocator completely. This allows easy creation of histograms | 113 // the current allocator completely. This allows easy creation of histograms |
114 // within persistent memory segments which can then be extracted and used | 114 // within persistent memory segments which can then be extracted and used |
115 // in other ways. | 115 // in other ways. |
116 static scoped_ptr<PersistentHistogramAllocator> | 116 static scoped_ptr<PersistentHistogramAllocator> |
117 ReleaseGlobalAllocatorForTesting(); | 117 ReleaseGlobalAllocatorForTesting(); |
118 | 118 |
119 // These helper methods perform SetGlobalAllocator() calls with allocators | 119 // Create a global allocator using the passed-in memory |base|, |size|, and |
120 // of the specified type and parameters. | 120 // other parameters. Ownership of the memory segment remains with the caller. |
121 static void CreateGlobalAllocatorOnPersistentMemory( | 121 static void CreateGlobalAllocatorOnPersistentMemory( |
122 void* base, | 122 void* base, |
123 size_t size, | 123 size_t size, |
124 size_t page_size, | 124 size_t page_size, |
125 uint64_t id, | 125 uint64_t id, |
126 StringPiece name); | 126 StringPiece name); |
| 127 |
| 128 // Create a global allocator using an internal block of memory of the |
| 129 // specified |size| taken from the heap. |
127 static void CreateGlobalAllocatorOnLocalMemory( | 130 static void CreateGlobalAllocatorOnLocalMemory( |
128 size_t size, | 131 size_t size, |
129 uint64_t id, | 132 uint64_t id, |
130 StringPiece name); | 133 StringPiece name); |
| 134 |
| 135 // Create a global allocator using a block of shared |memory| of the |
| 136 // specified |size|. The allocator takes ownership of the shared memory |
| 137 // and releases it upon destruction, though the memory will continue to |
| 138 // live if other processes have access to it. |
131 static void CreateGlobalAllocatorOnSharedMemory( | 139 static void CreateGlobalAllocatorOnSharedMemory( |
| 140 scoped_ptr<SharedMemory> memory, |
132 size_t size, | 141 size_t size, |
133 const SharedMemoryHandle& handle); | 142 uint64_t id, |
| 143 StringPiece name); |
| 144 |
| 145 // Create a global allocator using a block of shared memory accessed |
| 146 // through the given |handle| and |size|. The allocator takes ownership |
| 147 // of the handle and closes it upon destruction, though the memory will |
| 148 // continue to live if other processes have access to it. |
| 149 static void CreateGlobalAllocatorOnSharedMemoryHandle( |
| 150 const SharedMemoryHandle& handle, |
| 151 size_t size); |
134 | 152 |
135 // Import new histograms from the global PersistentHistogramAllocator. It's | 153 // Import new histograms from the global PersistentHistogramAllocator. It's |
136 // possible for other processes to create histograms in the active memory | 154 // possible for other processes to create histograms in the active memory |
137 // segment; this adds those to the internal list of known histograms to | 155 // segment; this adds those to the internal list of known histograms to |
138 // avoid creating duplicates that would have to be merged during reporting. | 156 // avoid creating duplicates that would have to be merged during reporting. |
139 // Every call to this method resumes from the last entry it saw; it costs | 157 // Every call to this method resumes from the last entry it saw; it costs |
140 // nothing if nothing new has been added. | 158 // nothing if nothing new has been added. |
141 static void ImportGlobalHistograms(); | 159 static void ImportGlobalHistograms(); |
142 | 160 |
143 // Histogram containing creation results. Visible for testing. | 161 // Histogram containing creation results. Visible for testing. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // A reference to the last-created histogram in the allocator, used to avoid | 221 // A reference to the last-created histogram in the allocator, used to avoid |
204 // trying to import what was just created. | 222 // trying to import what was just created. |
205 subtle::AtomicWord last_created_ = 0; | 223 subtle::AtomicWord last_created_ = 0; |
206 | 224 |
207 DISALLOW_COPY_AND_ASSIGN(PersistentHistogramAllocator); | 225 DISALLOW_COPY_AND_ASSIGN(PersistentHistogramAllocator); |
208 }; | 226 }; |
209 | 227 |
210 } // namespace base | 228 } // namespace base |
211 | 229 |
212 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ | 230 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ |
OLD | NEW |