Chromium Code Reviews| Index: content/browser/browser_main_runner.cc |
| diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc |
| index 96a3454f1499edbb0211afbcdb1ba8024cb6e2bc..857824a4eeb0a95280e66bce5aa2815a2cd8719a 100644 |
| --- a/content/browser/browser_main_runner.cc |
| +++ b/content/browser/browser_main_runner.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/macros.h" |
| #include "base/metrics/histogram.h" |
| #include "base/metrics/histogram_macros.h" |
| +#include "base/metrics/persistent_histogram_allocator.h" |
| #include "base/metrics/statistics_recorder.h" |
| #include "base/profiler/scoped_profile.h" |
| #include "base/profiler/scoped_tracker.h" |
| @@ -60,6 +61,15 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { |
| } |
| int Initialize(const MainFunctionParams& parameters) override { |
| + // Create persistent/shared memory and allow histograms to be stored in it. |
| + // Memory that is not actualy used won't be physically mapped by the system. |
| + // BrowserMetrics usage peaked around 95% of 2MiB as of 2016-02-20. |
|
Ilya Sherman
2016/04/25 19:48:41
nit: "95% of 2MiB" is confusing -- it kind of soun
bcwhite
2016/04/25 20:37:17
That is what it means. Better to just say "1.9MiB
|
| + base::GlobalHistogramAllocator::CreateWithLocalMemory( |
| + 3 << 20, // 3 MiB |
| + 0x935DDD43, // SHA1(BrowserMetrics) |
| + "BrowserMetrics"); |
| + base::GlobalHistogramAllocator::Disable(); // Enabled by experiment only. |
| + |
| SCOPED_UMA_HISTOGRAM_LONG_TIMER( |
| "Startup.BrowserMainRunnerImplInitializeLongTime"); |
| @@ -224,6 +234,13 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { |
| notification_service_.reset(NULL); |
| + // Dump all the persistent metrics to a file for upload during the next |
| + // run of the browser. |
| + base::GlobalHistogramAllocator* allocator = |
| + base::GlobalHistogramAllocator::Get(); |
| + if (allocator) |
|
Ilya Sherman
2016/04/25 19:48:41
Under what circumstances can the allocator be null
bcwhite
2016/04/25 20:37:17
It will be null if the allocator has been disabled
Ilya Sherman
2016/04/25 21:12:11
Yikes, that is so confusing that it confused me ev
bcwhite
2016/04/26 13:32:30
Acknowledged.
|
| + allocator->WriteToPersistentLocation(); |
| + |
| is_shutdown_ = true; |
| } |
| } |