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

Unified Diff: base/metrics/field_trial.cc

Issue 2504163005: Fix getting initially active trials with shared memory. (Closed)
Patch Set: Created 4 years, 1 month 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/common/variations/child_process_field_trial_syncer.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 8ec56b8a59e340763a371c38a921ce779d11f4dc..b1206f7f133c34bc33be3af43faf8382a6d83430 100644
--- a/base/metrics/field_trial.cc
+++ b/base/metrics/field_trial.cc
@@ -625,6 +625,40 @@ void FieldTrialList::GetActiveFieldTrialGroupsFromString(
}
// static
+void FieldTrialList::GetInitiallyActiveFieldTrials(
+ const base::CommandLine& command_line,
+ FieldTrial::ActiveGroups* active_groups) {
+ DCHECK(global_->create_trials_from_command_line_called_);
lawrencewu 2016/11/18 16:33:10 This function is called or can be called before Cr
Alexei Svitkine (slow) 2016/11/18 16:35:47 If it's called before it, then the field_trial_all
+
+ if (!global_->field_trial_allocator_) {
+ GetActiveFieldTrialGroupsFromString(
+ command_line.GetSwitchValueASCII(switches::kForceFieldTrials),
+ active_groups);
+ return;
+ }
+
+ SharedPersistentMemoryAllocator* allocator =
+ global_->field_trial_allocator_.get();
+ PersistentMemoryAllocator::Iterator mem_iter(allocator);
+ SharedPersistentMemoryAllocator::Reference ref;
+ while ((ref = mem_iter.GetNextOfType(kFieldTrialType)) !=
+ SharedPersistentMemoryAllocator::kReferenceNull) {
+ const FieldTrialEntry* entry =
+ allocator->GetAsObject<const FieldTrialEntry>(ref, kFieldTrialType);
+
+ StringPiece trial_name;
+ StringPiece group_name;
+ if (entry->activated &&
+ entry->GetTrialAndGroupName(&trial_name, &group_name)) {
+ FieldTrial::ActiveGroup group;
+ group.trial_name = trial_name.as_string();
+ group.group_name = group_name.as_string();
+ active_groups->push_back(group);
bcwhite 2016/11/21 15:56:22 push_back(std::move(group))
Alexei Svitkine (slow) 2016/11/21 20:47:11 Done.
+ }
+ }
+}
+
+// static
bool FieldTrialList::CreateTrialsFromString(
const std::string& trials_string,
const std::set<std::string>& ignored_trial_names) {
@@ -660,7 +694,7 @@ bool FieldTrialList::CreateTrialsFromString(
void FieldTrialList::CreateTrialsFromCommandLine(
const CommandLine& cmd_line,
const char* field_trial_handle_switch) {
- DCHECK(global_);
+ global_->create_trials_from_command_line_called_ = true;
#if defined(OS_WIN) && !defined(OS_NACL)
if (cmd_line.HasSwitch(field_trial_handle_switch)) {
« no previous file with comments | « base/metrics/field_trial.h ('k') | chrome/common/variations/child_process_field_trial_syncer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698