| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ | 5 #ifndef CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ |
| 6 #define CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ | 6 #define CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/string16.h" |
| 13 #include "chrome/common/metrics/variation_ids.h" | 14 #include "chrome/common/metrics/variation_ids.h" |
| 14 | 15 |
| 15 // This namespace provides various helpers that extend the functionality around | 16 // This namespace provides various helpers that extend the functionality around |
| 16 // base::FieldTrial. | 17 // base::FieldTrial. |
| 17 // | 18 // |
| 18 // This includes a simple API used to handle getting and setting | 19 // This includes a simple API used to handle getting and setting |
| 19 // data related to Google-specific experiments in the browser. This is meant to | 20 // data related to Google-specific experiments in the browser. This is meant to |
| 20 // be an extension to the base::FieldTrial for Google-specific functionality. | 21 // be an extension to the base::FieldTrial for Google-specific functionality. |
| 21 // | 22 // |
| 22 // These calls are meant to be made directly after appending all your groups to | 23 // These calls are meant to be made directly after appending all your groups to |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 95 |
| 95 // Retrieve the chrome_variations::ID associated with a FieldTrial group. The | 96 // Retrieve the chrome_variations::ID associated with a FieldTrial group. The |
| 96 // group is denoted by |trial_name| and |group_name|. This will return | 97 // group is denoted by |trial_name| and |group_name|. This will return |
| 97 // chrome_variations::kEmptyID if there is currently no associated ID for the | 98 // chrome_variations::kEmptyID if there is currently no associated ID for the |
| 98 // named group. This API can be nicely combined with | 99 // named group. This API can be nicely combined with |
| 99 // FieldTrial::GetFieldTrialSelectedGroupIds to enumerate the | 100 // FieldTrial::GetFieldTrialSelectedGroupIds to enumerate the |
| 100 // variation IDs for all active FieldTrial groups. | 101 // variation IDs for all active FieldTrial groups. |
| 101 chrome_variations::ID GetGoogleVariationID(const std::string& trial_name, | 102 chrome_variations::ID GetGoogleVariationID(const std::string& trial_name, |
| 102 const std::string& group_name); | 103 const std::string& group_name); |
| 103 | 104 |
| 105 // Generates experiment chunks from |experiment_strings| that are suitable for |
| 106 // crash reporting. |
| 107 void GenerateExperimentChunks(const std::vector<string16>& experiment_strings, |
| 108 std::vector<string16>* chunks); |
| 109 |
| 104 // Get the current set of chosen FieldTrial groups (aka experiments) and send | 110 // Get the current set of chosen FieldTrial groups (aka experiments) and send |
| 105 // them to the child process logging module so it can save it for crash dumps. | 111 // them to the child process logging module so it can save it for crash dumps. |
| 106 void SetChildProcessLoggingExperimentList(); | 112 void SetChildProcessLoggingExperimentList(); |
| 107 | 113 |
| 108 } // namespace experiments_helper | 114 } // namespace experiments_helper |
| 109 | 115 |
| 110 // Expose some functions for testing. These functions just wrap functionality | 116 // Expose some functions for testing. These functions just wrap functionality |
| 111 // that is implemented above. | 117 // that is implemented above. |
| 112 namespace testing { | 118 namespace testing { |
| 113 | 119 |
| 114 void TestGetFieldTrialSelectedGroupIdsForSelectedGroups( | 120 void TestGetFieldTrialSelectedGroupIdsForSelectedGroups( |
| 115 const base::FieldTrial::SelectedGroups& selected_groups, | 121 const base::FieldTrial::SelectedGroups& selected_groups, |
| 116 std::vector<experiments_helper::SelectedGroupId>* name_group_ids); | 122 std::vector<experiments_helper::SelectedGroupId>* name_group_ids); |
| 117 | 123 |
| 118 uint32 TestHashName(const std::string& name); | 124 uint32 TestHashName(const std::string& name); |
| 119 | 125 |
| 120 } | 126 } // namespace testing |
| 121 | 127 |
| 122 #endif // CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ | 128 #endif // CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ |
| OLD | NEW |