Chromium Code Reviews| Index: chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| index 5b947a9e19b4326db91819aa26438e4bca14b706..cc04341bb28547b26dd5f5e4e3cc3989154e85dd 100644 |
| --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/callback.h" |
| #include "base/chromeos/chromeos_version.h" |
| #include "base/command_line.h" |
| +#include "base/file_util.h" |
| #include "base/lazy_instance.h" |
| #include "base/linux_util.h" |
| #include "base/message_loop.h" |
| @@ -717,6 +718,9 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { |
| void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { |
| SetupLowMemoryHeadroomFieldTrial(); |
| + if (base::chromeos::IsRunningOnChromeOS()) |
| + // Run this on ChromeOS only because it tries to access /home/chronos. |
| + SetupZramFieldTrial(); |
|
Ilya Sherman
2013/01/08 20:16:16
nit: Include curly braces for this if-stmt since i
Luigi Semenzato
2013/01/08 21:28:19
Thanks. The if has been removed.
|
| } |
| void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { |
| @@ -765,4 +769,32 @@ void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { |
| } |
| } |
| + |
| +void ChromeBrowserMainPartsChromeos::SetupZramFieldTrial() { |
| + // The dice for this experiment have been thrown at boot. The selected group |
| + // number is stored in a file. |
| + const FilePath kZramGroupPath("/home/chronos/.swap_exp_enrolled"); |
| + std::string zram_group; |
| + // If the file does not exist, the experiment has not started. If the file |
| + // exists but contains an "x", the user has a non-standard swap size and has |
| + // been opted out. |
| + if (!file_util::ReadFileToString(kZramGroupPath, &zram_group) || |
| + StartsWithASCII(zram_group, "x", true)) { |
| + return; |
| + } |
| + const base::FieldTrial::Probability kDivisor = 1; // on/off only |
| + scoped_refptr<base::FieldTrial> trial = |
| + base::FieldTrialList::FactoryGetFieldTrial( |
|
Alexei Svitkine (slow)
2013/01/08 20:30:47
Nit: Indent 4.
|
| + "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); |
|
Alexei Svitkine (slow)
2013/01/08 20:30:47
Nit: Also indent 4 from line above.
|
| + // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to |
| + // all other choices. |
| + const char* const kGroups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; |
|
Alexei Svitkine (slow)
2013/01/08 20:38:02
Note: I saw your earlier concern about whether the
Luigi Semenzato
2013/01/08 21:28:19
Good to know, thanks.
|
| + for (unsigned int i = 0; i < arraysize(kGroups); i++) { |
|
Ilya Sherman
2013/01/08 20:16:16
nit: Still ++i ;)
Luigi Semenzato
2013/01/08 21:28:19
Aw!
|
| + bool match = StartsWithASCII(zram_group, kGroups[i], true); |
|
Alexei Svitkine (slow)
2013/01/08 20:30:47
I don't know the details of how that file is creat
Alexei Svitkine (slow)
2013/01/08 20:38:02
I notice this was somewhat covered by earlier disc
Greg Spencer (Chromium)
2013/01/08 20:41:03
No, we don't run Debug builds on any channels: the
Alexei Svitkine (slow)
2013/01/08 20:44:05
DCHECKs can be enabled in release builds though, w
|
| + trial->AppendGroup(kGroups[i], match ? 1 : 0); |
| + if (match) |
| + LOG(WARNING) << "zram field trial: group " << groups[i]; |
| + } |
| +} |
| + |
| } // namespace chromeos |