| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_VARIATIONS_VARIATIONS_UTIL_H_ | 5 #ifndef CHROME_COMMON_METRICS_VARIATIONS_VARIATIONS_UTIL_WIN_H_ |
| 6 #define CHROME_COMMON_METRICS_VARIATIONS_VARIATIONS_UTIL_H_ | 6 #define CHROME_COMMON_METRICS_VARIATIONS_VARIATIONS_UTIL_WIN_H_ |
| 7 | |
| 8 #include <vector> | |
| 9 | 7 |
| 10 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 11 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 12 #include "components/variations/variations_associated_data.h" | |
| 13 | 10 |
| 14 namespace chrome_variations { | 11 namespace chrome_variations { |
| 15 | 12 |
| 16 // Fills the supplied vector |name_group_ids| (which must be empty when called) | |
| 17 // with unique ActiveGroupIds for each Field Trial that has a chosen group. | |
| 18 // Field Trials for which a group has not been chosen yet are NOT returned in | |
| 19 // this list. | |
| 20 void GetFieldTrialActiveGroupIds(std::vector<ActiveGroupId>* name_group_ids); | |
| 21 | |
| 22 // Fills the supplied vector |output| (which must be empty when called) with | |
| 23 // unique string representations of ActiveGroupIds for each Field Trial that | |
| 24 // has a chosen group. The strings are formatted as "<TrialName>-<GroupName>", | |
| 25 // with the names as hex strings. Field Trials for which a group has not been | |
| 26 // chosen yet are NOT returned in this list. | |
| 27 void GetFieldTrialActiveGroupIdsAsStrings(std::vector<string16>* output); | |
| 28 | |
| 29 // Generates variation chunks from |variation_strings| that are suitable for | |
| 30 // crash reporting. | |
| 31 void GenerateVariationChunks(const std::vector<string16>& variation_strings, | |
| 32 std::vector<string16>* chunks); | |
| 33 | |
| 34 // Get the current set of chosen FieldTrial groups (aka variations) and send | |
| 35 // them to the child process logging module so it can save it for crash dumps. | |
| 36 void SetChildProcessLoggingVariationList(); | |
| 37 | |
| 38 // Takes the list of active groups and builds the label for the ones that have | 13 // Takes the list of active groups and builds the label for the ones that have |
| 39 // Google Update VariationID associated with them. This will return an empty | 14 // Google Update VariationID associated with them. This will return an empty |
| 40 // string if there are no such groups. | 15 // string if there are no such groups. |
| 41 string16 BuildGoogleUpdateExperimentLabel( | 16 string16 BuildGoogleUpdateExperimentLabel( |
| 42 const base::FieldTrial::ActiveGroups& active_groups); | 17 const base::FieldTrial::ActiveGroups& active_groups); |
| 43 | 18 |
| 44 // Creates a final combined experiment labels string with |variation_labels| | 19 // Creates a final combined experiment labels string with |variation_labels| |
| 45 // and |other_labels|, appropriately appending a separator based on their | 20 // and |other_labels|, appropriately appending a separator based on their |
| 46 // contents. It is assumed that |variation_labels| and |other_labels| do not | 21 // contents. It is assumed that |variation_labels| and |other_labels| do not |
| 47 // have leading or trailing separators. | 22 // have leading or trailing separators. |
| 48 string16 CombineExperimentLabels(const string16& variation_labels, | 23 string16 CombineExperimentLabels(const string16& variation_labels, |
| 49 const string16& other_labels); | 24 const string16& other_labels); |
| 50 | 25 |
| 51 // Takes the value of experiment_labels from the registry and returns a valid | 26 // Takes the value of experiment_labels from the registry and returns a valid |
| 52 // experiment_labels string value containing only the labels that are not | 27 // experiment_labels string value containing only the labels that are not |
| 53 // associated with Chrome Variations. | 28 // associated with Chrome Variations. |
| 54 string16 ExtractNonVariationLabels(const string16& labels); | 29 string16 ExtractNonVariationLabels(const string16& labels); |
| 55 | 30 |
| 56 // Expose some functions for testing. These functions just wrap functionality | |
| 57 // that is implemented above. | |
| 58 namespace testing { | |
| 59 | |
| 60 // Clears all of the mapped associations. | |
| 61 void ClearAllVariationIDs(); | |
| 62 | |
| 63 void TestGetFieldTrialActiveGroupIds( | |
| 64 const base::FieldTrial::ActiveGroups& active_groups, | |
| 65 std::vector<ActiveGroupId>* name_group_ids); | |
| 66 | |
| 67 } // namespace testing | |
| 68 | |
| 69 } // namespace chrome_variations | 31 } // namespace chrome_variations |
| 70 | 32 |
| 71 #endif // CHROME_COMMON_METRICS_VARIATIONS_VARIATIONS_UTIL_H_ | 33 #endif // CHROME_COMMON_METRICS_VARIATIONS_VARIATIONS_UTIL_WIN_H_ |
| OLD | NEW |