Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: base/metrics/persistent_histogram_allocator.h

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed some review comments by Ilya Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bdd64fb044ecdd1019f738c5991f1794979ca8ae 100644
--- a/base/metrics/persistent_histogram_allocator.h
+++ b/base/metrics/persistent_histogram_allocator.h
@@ -389,18 +389,42 @@ 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();
+
+ // 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/26 20:01:24 Looking at the uses, it looks like you could repla
bcwhite 2016/04/26 21:04:26 The name can't be a constant here because the name
+
// 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 +440,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);
};
« no previous file with comments | « no previous file | base/metrics/persistent_histogram_allocator.cc » ('j') | base/metrics/persistent_histogram_allocator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698