Index: base/metrics/field_trial_param_associator.h |
diff --git a/base/metrics/field_trial_param_associator.h b/base/metrics/field_trial_param_associator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3fc00febdb0817d0776121c3918c3b6757dc374d |
--- /dev/null |
+++ b/base/metrics/field_trial_param_associator.h |
@@ -0,0 +1,53 @@ |
+// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
Alexei Svitkine (slow)
2016/10/28 15:39:17
Nit: No (c) for new files
lawrencewu
2016/10/28 16:54:29
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_METRICS_FIELD_TRIAL_PARAM_ASSOCIATOR_H_ |
+#define BASE_METRICS_FIELD_TRIAL_PARAM_ASSOCIATOR_H_ |
+ |
+#include <map> |
+#include <string> |
+#include <utility> |
+ |
+#include "base/base_export.h" |
+#include "base/memory/singleton.h" |
+#include "base/metrics/field_trial.h" |
Alexei Svitkine (slow)
2016/10/28 15:39:17
Is this used in the header? If not, move to the cc
lawrencewu
2016/10/28 16:54:29
Done.
|
+#include "base/synchronization/lock.h" |
+ |
+namespace base { |
+ |
+// Keeps track of the parameters of all field trials and ensures access to them |
+// is thread-safe. |
+class BASE_EXPORT FieldTrialParamAssociator { |
+ public: |
+ typedef std::pair<std::string, std::string> |
+ FieldTrialKey; // (FieldTrialName, FieldTrialGroup) |
Alexei Svitkine (slow)
2016/10/28 15:39:17
Can this be in the private section?
lawrencewu
2016/10/28 16:54:29
Done.
|
+ typedef std::map<std::string, std::string> FieldTrialParams; |
+ |
+ // Retrieve the singleton. |
+ static FieldTrialParamAssociator* GetInstance(); |
+ |
+ bool AssociateFieldTrialParams(const std::string& trial_name, |
+ const std::string& group_name, |
+ const FieldTrialParams& params); |
+ |
+ bool GetFieldTrialParams(const std::string& trial_name, |
+ FieldTrialParams* params); |
+ |
+ void ClearAllParamsForTesting(); |
Alexei Svitkine (slow)
2016/10/28 15:39:17
Please add comments above all the public functions
lawrencewu
2016/10/28 16:54:29
Done.
|
+ |
+ private: |
+ friend struct DefaultSingletonTraits<FieldTrialParamAssociator>; |
+ |
+ FieldTrialParamAssociator() {} |
+ ~FieldTrialParamAssociator() {} |
+ |
+ Lock lock_; |
+ std::map<FieldTrialKey, FieldTrialParams> field_trial_params_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FieldTrialParamAssociator); |
+}; |
+ |
+} // namespace base |
+ |
+#endif // BASE_METRICS_FIELD_TRIAL_PARAM_ASSOCIATOR_H_ |