Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3208)

Unified Diff: chrome/browser/chrome_browser_field_trials.cc

Issue 1425533011: Support "shared" histograms between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: moved Create-Result histogram to private space and added to histograms.xml Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/statistics_recorder_unittest.cc ('k') | chrome/service/service_ipc_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b4654735a5fb528a597e6c3163cc8370ad99c522..59d88f0ab07400224933842123c5e5b17c56fa02 100644
--- a/chrome/browser/chrome_browser_field_trials.cc
+++ b/chrome/browser/chrome_browser_field_trials.cc
@@ -7,7 +7,10 @@
#include <string>
#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
+#include "base/metrics/histogram_base.h"
+#include "base/metrics/histogram_persistence.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
@@ -20,6 +23,26 @@
#include "chrome/browser/chrome_browser_field_trials_desktop.h"
#endif
+namespace {
+
+// Check for feature enabling the use of persistent histogram storage and
+// create an appropriate allocator for such if so.
+void InstantiatePersistentHistograms() {
+ if (base::FeatureList::IsEnabled(base::kPersistentHistogramsFeature)) {
+ const std::string allocator_name("BrowserMetricsAllocator");
+ // Create persistent/shared memory and allow histograms to be stored in it.
+ // TODO(bcwhite): Update this with correct allocator and memory size.
+ base::SetPersistentHistogramMemoryAllocator(
+ new base::LocalPersistentMemoryAllocator(1 << 20, // 1 MiB
+ 0x4D5B9953, // SHA1(B..M..A..)
+ allocator_name));
+ base::GetPersistentHistogramMemoryAllocator()->CreateTrackingHistograms(
+ allocator_name);
+ }
+}
+
+} // namespace
+
ChromeBrowserFieldTrials::ChromeBrowserFieldTrials(
const base::CommandLine& parsed_command_line)
: parsed_command_line_(parsed_command_line) {
@@ -40,6 +63,8 @@ void ChromeBrowserFieldTrials::SetupFieldTrials() {
}
void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
+ // Persistent histograms must be enabled as soon as possible.
+ InstantiatePersistentHistograms();
// The following trials are used from renderer process.
// Mark here so they will be sync-ed.
base::FieldTrialList::FindValue("DisplayList2dCanvas");
« no previous file with comments | « base/metrics/statistics_recorder_unittest.cc ('k') | chrome/service/service_ipc_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698