Index: base/metrics/persistent_histogram_allocator.h |
diff --git a/base/metrics/persistent_histogram_allocator.h b/base/metrics/persistent_histogram_allocator.h |
index 7f46dc9664bd6a45d3c010f8cebd100e9ddce25a..3db91985d0c5cc419d0f1204593f65daf3aaae4b 100644 |
--- a/base/metrics/persistent_histogram_allocator.h |
+++ b/base/metrics/persistent_histogram_allocator.h |
@@ -389,18 +389,46 @@ class BASE_EXPORT GlobalHistogramAllocator |
// while operating single-threaded so there are no race-conditions. |
static void Set(std::unique_ptr<GlobalHistogramAllocator> allocator); |
- // Gets a pointer to the global histogram allocator. |
+ // Enables the global persistent allocator. Existing histograms will not be |
+ // affected; only newly created ones will go into the allocator. |
+ static void Enable(); |
+ |
+ // Disables the global persistent allocator. Existing histograms will not be |
+ // affected; newly created histograms will be allocated from the heap. |
+ static void Disable(); |
Ilya Sherman
2016/04/25 19:48:40
Rather than having both an Enable() and a Disable(
bcwhite
2016/04/25 20:37:17
The default is "enabled" because that is the norma
Ilya Sherman
2016/04/25 21:12:11
Sorry, I don't follow. How is the experiment a sp
bcwhite
2016/04/26 13:32:30
See discussion in persistent_histogram_allocator.c
Ilya Sherman
2016/04/26 20:01:24
Okay, yeah, I see your point. Thanks.
|
+ |
+ // Returns whether a global allocator is enabled. This will return false if |
+ // none has been set. |
+ static bool IsEnabled(); |
Ilya Sherman
2016/04/25 19:48:40
This method appears to be unused.
bcwhite
2016/04/25 20:37:17
I was using it... Code must have changed. Still,
Ilya Sherman
2016/04/25 21:12:11
I strongly disagree that it's worthwhile to land d
bcwhite
2016/04/26 13:32:30
Done.
|
+ |
+ // Gets a pointer to an enabled global histogram allocator. If a global |
+ // allocator exists but is disabled, this will return null. |
static GlobalHistogramAllocator* Get(); |
+ // Gets a pointer to a global histogram allocator if one exists, even if |
+ // that allocator is disabled. |
+ static GlobalHistogramAllocator* GetEvenIfDisabled(); |
Ilya Sherman
2016/04/25 19:48:40
IMO this method is not needed. Get() should alway
bcwhite
2016/04/25 20:37:17
Get() always returns an active allocator. Existin
Ilya Sherman
2016/04/25 21:12:11
IMO this is a poor design pattern, and I'd much ra
bcwhite
2016/04/26 13:32:30
The whole GlobalHistogramAllocator is already sepa
|
+ |
// This access to the persistent allocator is only for testing; it extracts |
- // the current allocator completely. This allows easy creation of histograms |
- // within persistent memory segments which can then be extracted and used |
- // in other ways. |
+ // the current allocator completely regardless whether it is enabled or not. |
+ // This allows easy creation of histograms within persistent memory segments |
+ // which can then be extracted and used in other ways. |
static std::unique_ptr<GlobalHistogramAllocator> ReleaseForTesting(); |
+ // Stores a pathname to which the contents of this allocator should be saved |
+ // in order to persist the data for a later use. |
+ void SetPersistentLocation(const FilePath& location); |
+ |
+ // Writes the internal data to a previously set location. This is generally |
+ // called when a process is exiting from a section of code that may not know |
+ // the filesystem. The data is written in an atomic manner. The return value |
+ // indicates success. |
+ bool WriteToPersistentLocation(); |
+ |
private: |
friend class StatisticsRecorder; |
+ // Creates a new global histogram allocator. It will be enabled by default. |
explicit GlobalHistogramAllocator( |
std::unique_ptr<PersistentMemoryAllocator> memory); |
@@ -416,6 +444,9 @@ class BASE_EXPORT GlobalHistogramAllocator |
// iterator to continue the work. |
Iterator import_iterator_; |
+ // The location to which the data should be persisted. |
+ FilePath persistent_location_; |
+ |
DISALLOW_COPY_AND_ASSIGN(GlobalHistogramAllocator); |
}; |