Index: chrome/installer/gcapi/gcapi_omaha_experiment.cc |
diff --git a/chrome/installer/gcapi/gcapi_omaha_experiment.cc b/chrome/installer/gcapi/gcapi_omaha_experiment.cc |
index ac5899fe675e27fa09c8a2b557ae75fa38633b6a..4380f047d842e7f8dc0b8a77526a1ca6b96d9d62 100644 |
--- a/chrome/installer/gcapi/gcapi_omaha_experiment.cc |
+++ b/chrome/installer/gcapi/gcapi_omaha_experiment.cc |
@@ -8,6 +8,7 @@ |
#include "base/strings/stringprintf.h" |
#include "base/time/time.h" |
#include "chrome/installer/gcapi/gcapi.h" |
+#include "chrome/installer/util/google_update_constants.h" |
#include "chrome/installer/util/google_update_experiment_util.h" |
#include "chrome/installer/util/google_update_settings.h" |
@@ -24,35 +25,60 @@ int GetCurrentRlzWeek() { |
return delta.InDays() / 7; |
} |
-bool SetLabel(const wchar_t* brand_code, const wchar_t* label, int shell_mode) { |
+bool SetExperimentLabel(const wchar_t* brand_code, |
+ const string16& label, |
+ int shell_mode) { |
if (!brand_code) { |
return false; |
} |
+ const bool system_level = shell_mode == GCAPI_INVOKED_UAC_ELEVATION; |
+ |
+ string16 experiment_labels; |
+ if (!GoogleUpdateSettings::ReadExperimentLabels(system_level, |
+ &experiment_labels)) { |
+ return false; |
+ } |
+ |
+ // First erase this label from the existing experiment labels if it exists. |
+ size_t existing_label_begin = experiment_labels.find(label + L"="); |
+ if (existing_label_begin != string16::npos) { |
+ size_t existing_label_end = |
+ experiment_labels.find(google_update::kExperimentLabelSep, |
+ existing_label_begin); |
+ // Note: if |existing_label_end == string16::npos| this will work anyways |
+ // as npos is defined as the biggest possible unsigned integer and erase |
+ // will thus, by definition, erase to the end of the string. |
+ experiment_labels.erase(existing_label_begin, |
+ existing_label_end - existing_label_begin); |
+ } |
+ |
int week_number = GetCurrentRlzWeek(); |
if (week_number < 0 || week_number > 999) |
week_number = 999; |
- string16 experiment_labels; |
- base::SStringPrintf(&experiment_labels, |
+ string16 gcapi_experiment_label; |
+ base::SStringPrintf(&gcapi_experiment_label, |
L"%ls=%ls_%d|%ls", |
- label, |
+ label.c_str(), |
brand_code, |
week_number, |
installer::BuildExperimentDateString().c_str()); |
- return GoogleUpdateSettings::SetExperimentLabels( |
- shell_mode == GCAPI_INVOKED_UAC_ELEVATION, |
- experiment_labels); |
+ experiment_labels.append(google_update::kExperimentLabelSep); |
+ experiment_labels.append(gcapi_experiment_label); |
+ |
+ return GoogleUpdateSettings::SetExperimentLabels(system_level, |
+ experiment_labels); |
} |
} // namespace |
bool SetReactivationExperimentLabels(const wchar_t* brand_code, |
int shell_mode) { |
- return SetLabel(brand_code, L"reacbrand", shell_mode); |
+ return SetExperimentLabel(brand_code, L"reacbrand", shell_mode); |
} |
bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) { |
- return SetLabel(brand_code, L"relaunchbrand", shell_mode); |
+ return SetExperimentLabel(brand_code, L"relaunchbrand", shell_mode); |
} |