Chromium Code Reviews| Index: chrome/browser/metrics/chrome_metrics_service_client.cc |
| diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc |
| index 8cd66d4db17000b03bc145324e92879ac9c0c5a2..cf3a6f0f01b5f1f7e958b21bd5285978685d754d 100644 |
| --- a/chrome/browser/metrics/chrome_metrics_service_client.cc |
| +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc |
| @@ -182,6 +182,22 @@ CreateInstallerFileMetricsProvider(bool metrics_reporting_enabled) { |
| return file_metrics_provider; |
| } |
| +void CleanUpGlobalPersistentHistogramStorage() { |
| + // 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 there is no benefit in keeping a file with no new data to be processed |
| + // during the next startup sequence. |
| + base::GlobalHistogramAllocator* allocator = |
| + base::GlobalHistogramAllocator::Get(); |
| + if (allocator) { |
|
Alexei Svitkine (slow)
2016/06/28 15:08:00
Nit: Use early returns instead.
bcwhite
2016/06/29 03:17:03
Done.
|
| + const base::FilePath& path = allocator->GetPersistentLocation(); |
| + if (!path.empty()) { |
| + base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ | |
| + base::File::FLAG_DELETE_ON_CLOSE); |
| + } |
| + } |
| +} |
| + |
| } // namespace |
| @@ -213,6 +229,7 @@ ChromeMetricsServiceClient::ChromeMetricsServiceClient( |
| ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| + CleanUpGlobalPersistentHistogramStorage(); |
| } |
| // static |