Chromium Code Reviews| Index: chrome/browser/chrome_browser_field_trials.cc |
| diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc |
| index 3d8ea8bd6e93ed2367f84fa86d673f2aaf85a9ce..8d6b013ffd971c6a1285d49e9f5f56453bb3bb94 100644 |
| --- a/chrome/browser/chrome_browser_field_trials.cc |
| +++ b/chrome/browser/chrome_browser_field_trials.cc |
| @@ -61,18 +61,38 @@ void InstantiatePersistentHistograms() { |
| if (!base::PathService::Get(chrome::DIR_USER_DATA, &metrics_dir)) |
| return; |
| - base::FilePath metrics_file; |
| - base::FilePath active_file; |
| - base::FilePath spare_file; |
| + // Remove any existing file from its legacy location. |
| + // TODO(bcwhite): Remove this block of code in M62 or later. |
| + base::FilePath legacy_file; |
| base::GlobalHistogramAllocator::ConstructFilePaths( |
| metrics_dir, ChromeMetricsServiceClient::kBrowserMetricsName, |
| - &metrics_file, &active_file, &spare_file); |
| + &legacy_file, nullptr, nullptr); |
| + base::PostTaskWithTraits( |
| + FROM_HERE, |
| + {base::MayBlock(), base::TaskPriority::BACKGROUND, |
| + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}, |
| + base::BindOnce(base::IgnoreResult(&base::DeleteFile), |
| + base::Passed(&legacy_file), /*recursive=*/false)); |
| + |
| + // Create a directory for storing completed metrics files. Files in this |
| + // directory must have embedded system profiles. If the directory can't be |
| + // created, the file will just be deleted below. |
| + base::FilePath upload_dir = |
| + metrics_dir.AppendASCII(ChromeMetricsServiceClient::kBrowserMetricsName); |
| + base::CreateDirectory(upload_dir); |
| + |
| + base::FilePath upload_file; |
| + base::FilePath active_file; |
| + base::FilePath spare_file; |
| + base::GlobalHistogramAllocator::ConstructFilePathsForUploadDir( |
| + metrics_dir, upload_dir, ChromeMetricsServiceClient::kBrowserMetricsName, |
|
Alexei Svitkine (slow)
2017/06/28 17:30:35
Can you add a comment about expected file location
bcwhite
2017/06/28 18:52:08
Done.
|
| + &upload_file, &active_file, &spare_file); |
| // Move any existing "active" file to the final name from which it will be |
| // read when reporting initial stability metrics. If there is no file to |
| // move, remove any old, existing file from before the previous session. |
| - if (!base::ReplaceFile(active_file, metrics_file, nullptr)) |
| - base::DeleteFile(metrics_file, /*recursive=*/false); |
| + if (!base::ReplaceFile(active_file, upload_file, nullptr)) |
| + base::DeleteFile(active_file, /*recursive=*/false); |
| // This is used to report results to an UMA histogram. |
| enum InitResult { |