Chromium Code Reviews| Index: base/metrics/persistent_histogram_allocator.h |
| diff --git a/base/metrics/persistent_histogram_allocator.h b/base/metrics/persistent_histogram_allocator.h |
| index ee1fba5f624221cc510474f75be3a6dd360cfd9b..f052d66b8db62f51e4e2efd067ac065bbdc63b1f 100644 |
| --- a/base/metrics/persistent_histogram_allocator.h |
| +++ b/base/metrics/persistent_histogram_allocator.h |
| @@ -394,11 +394,36 @@ class BASE_EXPORT GlobalHistogramAllocator |
| // Create a global allocator by memory-mapping a |file|. If the file does |
| // not exist, it will be created with the specified |size|. If the file does |
| // exist, the allocator will use and add to its contents, ignoring the passed |
| - // size in favor of the existing size. |
| - static void CreateWithFile(const FilePath& file_path, |
| + // size in favor of the existing size. Returns whether the global allocator |
| + // was set. |
| + static bool CreateWithFile(const FilePath& file_path, |
| size_t size, |
| uint64_t id, |
| StringPiece name); |
| + |
| + // Creates a new file at |active_path|. If it already exists, it will first be |
| + // moved to |base_path|. In all cases, any old file at |base_path| will be |
| + // removed. The file will be created using the given size, id, and name. |
| + // Returns whether the global allocator was set. |
| + static bool CreateWithActiveFile(const FilePath& base_path, |
| + const FilePath& active_path, |
| + size_t size, |
| + uint64_t id, |
| + StringPiece name); |
| + |
| + // Uses ConstructBaseActivePairFilePaths() to build a pair of file names which |
| + // are then used for CreateWithActiveFile(). |
|
bcwhite
2016/09/14 21:11:29
Note that |name| will be used for both the interna
scottmg
2016/09/14 22:12:30
Done.
|
| + static bool CreateWithActiveFileInDir(const FilePath& dir, |
| + size_t size, |
| + uint64_t id, |
| + StringPiece name); |
| + |
| + // Constructs a pair of names in |dir| based on name that can be used for a |
| + // base + active persistent memory mapped location for CreateWithActiveFile(). |
| + static void ConstructBaseActivePairFilePaths(const FilePath& dir, |
|
bcwhite
2016/09/14 21:11:30
How about shortening this method to just ContructF
scottmg
2016/09/14 22:12:31
Done.
|
| + StringPiece name, |
| + FilePath* out_base_path, |
| + FilePath* out_active_path); |
| #endif |
| // Create a global allocator using a block of shared |memory| of the |
| @@ -449,6 +474,14 @@ class BASE_EXPORT GlobalHistogramAllocator |
| // indicates success. |
| bool WriteToPersistentLocation(); |
| + // If there is a global metrics file being updated on disk, mark it to be |
| + // deleted when the process exits. A normal shutdown is almost complete so |
|
bcwhite
2016/09/14 21:11:30
Comment needs updating for its new location. A sh
scottmg
2016/09/14 22:12:31
Done.
|
| + // there is no benefit in keeping a file with no new data to be processed |
| + // during the next startup sequence. Deleting the file during shutdown adds an |
| + // extra disk-access or two to shutdown but eliminates the unnecessary |
| + // processing of the contents during startup only to find nothing. |
| + void DeletePersistentLocation(); |
| + |
| private: |
| friend class StatisticsRecorder; |