Commit b86102f2 authored by Michael Bai's avatar Michael Bai Committed by Commit Bot

WebView: Enable the persistent histogram by LocalMemory to be default.

- Add a new parameter default_local_memory in
InstantiatePersistentHistograms()
- Set it true for WebView.
- Plan to merge this patch to M86.

Bug: 1090682
Change-Id: I218c9960c9cb72e184e36f78e97096a8f6691759
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411706
Commit-Queue: Michael Bai <michaelbai@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807583}
parent 92717ab3
......@@ -12,11 +12,10 @@
void AwFieldTrials::SetupFieldTrials() {
// https://crbug.com/1093420: enable for persistent metrics.
if (base::FeatureList::IsEnabled(base::kPersistentHistogramsFeature)) {
// Persistent histograms must be enabled as soon as possible.
base::FilePath metrics_dir;
if (base::PathService::Get(base::DIR_ANDROID_APP_DATA, &metrics_dir)) {
InstantiatePersistentHistograms(metrics_dir);
}
// Persistent histograms must be enabled as soon as possible.
base::FilePath metrics_dir;
if (base::PathService::Get(base::DIR_ANDROID_APP_DATA, &metrics_dir)) {
InstantiatePersistentHistograms(metrics_dir,
/*default_local_memory=*/true);
}
}
......@@ -84,7 +84,8 @@ const char kBrowserMetricsName[] = "BrowserMetrics";
// Check for feature enabling the use of persistent histogram storage and
// enable the global allocator if so.
void InstantiatePersistentHistograms(const base::FilePath& metrics_dir) {
void InstantiatePersistentHistograms(const base::FilePath& metrics_dir,
bool default_local_memory) {
// 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.
......@@ -148,7 +149,7 @@ void InstantiatePersistentHistograms(const base::FilePath& metrics_dir) {
storage = kLocalMemory;
// Create a global histogram allocator using the desired storage type.
if (storage.empty() || storage == kMappedFile) {
if (storage == kMappedFile || (storage.empty() && !default_local_memory)) {
if (!base::PathExists(upload_dir)) {
// Handle failure to create the directory.
result = kNoUploadDir;
......@@ -177,7 +178,8 @@ void InstantiatePersistentHistograms(const base::FilePath& metrics_dir) {
&base::GlobalHistogramAllocator::CreateSpareFile),
std::move(spare_file), kAllocSize),
base::TimeDelta::FromSeconds(kSpareFileCreateDelaySeconds));
} else if (storage == kLocalMemory) {
} else if (storage == kLocalMemory ||
(default_local_memory && storage.empty())) {
// Use local memory for storage even though it will not persist across
// an unclean shutdown. This sets the result but the actual creation is
// done below.
......
......@@ -15,6 +15,7 @@
extern const char kBrowserMetricsName[];
// Do all the checking and work necessary to enable persistent histograms.
void InstantiatePersistentHistograms(const base::FilePath& metrics_dir);
void InstantiatePersistentHistograms(const base::FilePath& metrics_dir,
bool default_local_memory = false);
#endif // COMPONENTS_METRICS_PERSISTENT_HISTOGRAMS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment