OLD | NEW |
1 // Copyright 2013 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 #include "chrome/installer/util/google_update_experiment_util.h" | 5 #include "components/variations/variations_experiment_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 | 13 |
14 namespace google_update { | 14 namespace variations { |
15 | |
16 #if defined(OS_WIN) | |
17 const wchar_t kExperimentLabels[] = L"experiment_labels"; | |
18 #endif | |
19 | 15 |
20 const base::char16 kExperimentLabelSeparator = ';'; | 16 const base::char16 kExperimentLabelSeparator = ';'; |
21 | 17 |
22 } // namespace google_update | |
23 | |
24 namespace installer { | |
25 | |
26 namespace { | 18 namespace { |
27 | 19 |
28 const char* const kDays[] = | 20 const char* const kDays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; |
29 { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; | |
30 | 21 |
31 const char* const kMonths[] = | 22 const char* const kMonths[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
32 { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", | 23 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; |
33 "Oct", "Nov", "Dec"}; | |
34 | 24 |
35 } | 25 } // namespace |
36 | 26 |
37 base::string16 BuildExperimentDateString(const base::Time& current_time) { | 27 base::string16 BuildExperimentDateString(const base::Time& current_time) { |
38 // The Google Update experiment_labels timestamp format is: | 28 // The Google Update experiment_labels timestamp format is: |
39 // "DAY, DD0 MON YYYY HH0:MI0:SE0 TZ" | 29 // "DAY, DD0 MON YYYY HH0:MI0:SE0 TZ" |
40 // DAY = 3 character day of week, | 30 // DAY = 3 character day of week, |
41 // DD0 = 2 digit day of month, | 31 // DD0 = 2 digit day of month, |
42 // MON = 3 character month of year, | 32 // MON = 3 character month of year, |
43 // YYYY = 4 digit year, | 33 // YYYY = 4 digit year, |
44 // HH0 = 2 digit hour, | 34 // HH0 = 2 digit hour, |
45 // MI0 = 2 digit minute, | 35 // MI0 = 2 digit minute, |
46 // SE0 = 2 digit second, | 36 // SE0 = 2 digit second, |
47 // TZ = 3 character timezone | 37 // TZ = 3 character timezone |
48 base::Time::Exploded then = {}; | 38 base::Time::Exploded then = {}; |
49 current_time.UTCExplode(&then); | 39 current_time.UTCExplode(&then); |
50 then.year += 1; | 40 then.year += 1; |
51 DCHECK(then.HasValidValues()); | 41 DCHECK(then.HasValidValues()); |
52 | 42 |
53 return base::UTF8ToUTF16( | 43 return base::UTF8ToUTF16( |
54 base::StringPrintf("%s, %02d %s %d %02d:%02d:%02d GMT", | 44 base::StringPrintf("%s, %02d %s %d %02d:%02d:%02d GMT", |
55 kDays[then.day_of_week], | 45 kDays[then.day_of_week], |
56 then.day_of_month, | 46 then.day_of_month, |
57 kMonths[then.month - 1], | 47 kMonths[then.month - 1], |
58 then.year, | 48 then.year, |
59 then.hour, | 49 then.hour, |
60 then.minute, | 50 then.minute, |
61 then.second)); | 51 then.second)); |
62 } | 52 } |
63 | 53 |
64 } // namespace installer | 54 } // namespace variations |
65 | |
OLD | NEW |