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

Unified Diff: base/metrics/field_trial.cc

Issue 1897493002: Even more instrumentation to diagnose an Android render crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more comments. Created 4 years, 8 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/field_trial.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial.cc
diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc
index 78862fa683520bc5d96764e093d7fce54386e12a..4d4fdcebde56b38bec2acb8a44679c61d3bd65aa 100644
--- a/base/metrics/field_trial.cc
+++ b/base/metrics/field_trial.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/build_time.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/strings/string_util.h"
@@ -115,6 +116,17 @@ void CheckTrialGroup(const std::string& trial_name,
}
}
+// A second copy of FieldTrialList::seen_states_ that is meant to outlive the
+// FieldTrialList object to determine if the inconsistency happens because there
+// might be multiple FieldTrialList objects.
+// TODO(asvitkine): Remove when crbug.com/359406 is resolved.
+base::LazyInstance<std::map<std::string, std::string>>::Leaky g_seen_states =
+ LAZY_INSTANCE_INITIALIZER;
+
+// Tracks whether |g_seen_states| is used. Defaults to false, because unit tests
+// will create multiple FieldTrialList instances.
+bool g_use_global_check_states = false;
+
} // namespace
// statics
@@ -338,6 +350,12 @@ FieldTrialList::~FieldTrialList() {
}
// static
+void FieldTrialList::EnableGlobalStateChecks() {
+ CHECK(!g_use_global_check_states);
+ g_use_global_check_states = true;
+}
+
+// static
FieldTrial* FieldTrialList::FactoryGetFieldTrial(
const std::string& trial_name,
FieldTrial::Probability total_probability,
@@ -489,8 +507,13 @@ void FieldTrialList::AllStatesToString(std::string* output) {
trial.group_name.AppendToString(output);
output->append(1, kPersistentStringSeparator);
+ // TODO(asvitkine): Remove these when http://crbug.com/359406 is fixed.
CheckTrialGroup(trial.trial_name.as_string(), trial.group_name.as_string(),
&global_->seen_states_);
+ if (g_use_global_check_states) {
+ CheckTrialGroup(trial.trial_name.as_string(),
+ trial.group_name.as_string(), &g_seen_states.Get());
+ }
}
}
@@ -615,10 +638,15 @@ void FieldTrialList::NotifyFieldTrialGroupSelection(FieldTrial* field_trial) {
if (!field_trial->enable_field_trial_)
return;
+ // TODO(asvitkine): Remove this block when http://crbug.com/359406 is fixed.
{
AutoLock auto_lock(global_->lock_);
CheckTrialGroup(field_trial->trial_name(),
field_trial->group_name_internal(), &global_->seen_states_);
+ if (g_use_global_check_states) {
+ CheckTrialGroup(field_trial->trial_name(),
+ field_trial->group_name_internal(), &g_seen_states.Get());
+ }
}
global_->observer_list_->Notify(
FROM_HERE, &FieldTrialList::Observer::OnFieldTrialGroupFinalized,
« no previous file with comments | « base/metrics/field_trial.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698