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

Side by Side Diff: base/metrics/field_trial_param_associator.cc

Issue 2463223002: Store field trial parameters in shared memory (Closed)
Patch Set: address comments Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/field_trial_param_associator.h" 5 #include "base/metrics/field_trial_param_associator.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 19 matching lines...) Expand all
30 if (ContainsKey(field_trial_params_, key)) 30 if (ContainsKey(field_trial_params_, key))
31 return false; 31 return false;
32 32
33 field_trial_params_[key] = params; 33 field_trial_params_[key] = params;
34 return true; 34 return true;
35 } 35 }
36 36
37 bool FieldTrialParamAssociator::GetFieldTrialParams( 37 bool FieldTrialParamAssociator::GetFieldTrialParams(
38 const std::string& trial_name, 38 const std::string& trial_name,
39 FieldTrialParams* params) { 39 FieldTrialParams* params) {
40 // We first try looking for the params in field_trial_params_.
bcwhite 2016/11/23 21:03:52 field_trial_params_ isn't accessed in the code so
lawrencewu 2016/11/23 21:49:20 Changed to say "via GetFieldTrialParamsWithoutFall
41 // If that is unsuccessful, then we try to look it up in shared memory.
bcwhite 2016/11/23 21:03:52 Lines 43-44 say: if unsuccessful then return
lawrencewu 2016/11/23 21:49:20 I cleared it up a bit to say: "If it's not there,
42 FieldTrial* field_trial = FieldTrialList::Find(trial_name);
43 if (!field_trial)
44 return false;
45
46 if (GetFieldTrialParamsWithoutFallback(trial_name, field_trial->group_name(),
47 params)) {
48 return true;
49 }
50
51 // TODO(lawrencewu): add the params to field_trial_params_ for next time.
52 return FieldTrialList::GetParamsFromSharedMemory(field_trial, params);
53 }
54
55 bool FieldTrialParamAssociator::GetFieldTrialParamsWithoutFallback(
56 const std::string& trial_name,
57 const std::string& group_name,
58 FieldTrialParams* params) {
40 AutoLock scoped_lock(lock_); 59 AutoLock scoped_lock(lock_);
41 60
42 const std::string group_name = FieldTrialList::FindFullName(trial_name);
43 const FieldTrialKey key(trial_name, group_name); 61 const FieldTrialKey key(trial_name, group_name);
44 if (!ContainsKey(field_trial_params_, key)) 62 if (!ContainsKey(field_trial_params_, key))
45 return false; 63 return false;
46 64
47 *params = field_trial_params_[key]; 65 *params = field_trial_params_[key];
48 return true; 66 return true;
49 } 67 }
50 68
51 void FieldTrialParamAssociator::ClearAllParamsForTesting() { 69 void FieldTrialParamAssociator::ClearAllParamsForTesting() {
52 AutoLock scoped_lock(lock_); 70 AutoLock scoped_lock(lock_);
53 field_trial_params_.clear(); 71 field_trial_params_.clear();
72 FieldTrialList::ClearParamsFromSharedMemoryForTesting();
73 }
74
75 void FieldTrialParamAssociator::ClearAllCachedParamsForTesting() {
76 AutoLock scoped_lock(lock_);
77 field_trial_params_.clear();
54 } 78 }
55 79
56 } // namespace base 80 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698