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..99d3bddec89f6dfadacee93f8344ab4ecb104f95 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,7 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { |
| void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { |
| SetupLowMemoryHeadroomFieldTrial(); |
| + SetupZramFieldTrial(); |
| } |
| void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { |
| @@ -765,4 +767,40 @@ 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_file_content; |
| + // If the file does not exist, the experiment has not started. |
| + if (!file_util::ReadFileToString(kZramGroupPath, &zram_file_content)) |
| + return; |
| + // The file contains a single significant character, possibly followed by |
| + // newline. "x" means the user has opted out. "0" through "8" are the valid |
| + // group names. (See src/platform/init/swap-exp.conf in chromiumos repo for |
| + // group meanings.) |
| + std::string zram_group = zram_file_content.substring(0, 1); |
| + if (zram_group.compare("x") == 0) |
| + return; |
| + const base::FieldTrial::Probability kDivisor = 1; // on/off only |
| + scoped_refptr<base::FieldTrial> trial = |
| + base::FieldTrialList::FactoryGetFieldTrial( |
| + "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); |
| + // 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" }; |
| + bool matched = false; |
| + for (size_t i = 0; i < arraysize(kGroups); ++i) { |
| + bool match = zram_group.compare(kGroups[i]) == 0; |
| + trial->AppendGroup(kGroups[i], match ? 1 : 0); |
| + if (match) { |
| + matched = true; |
| + LOG(WARNING) << "zram field trial: group " << kGroups[i]; |
|
stevenjb
2013/01/08 21:36:27
nit: We should avoid WARNING spam unless it's trul
James Cook
2013/01/08 21:38:47
I mentioned on an earlier pass that I would like t
stevenjb
2013/01/08 21:53:15
Will it show up on tests? We already have quite a
Luigi Semenzato
2013/01/08 21:59:01
I would also prefer to log all the time for exactl
Luigi Semenzato
2013/01/08 22:06:08
No, it won't show up on tests, unless the file /ho
James Cook
2013/01/08 22:07:18
I ran it and can confirm it doesn't log in browser
stevenjb
2013/01/08 22:11:49
Ah, I see, that makes sense. It might be slightly
stevenjb
2013/01/08 22:11:49
OK, cool, then that's fine. I wish we had a LOG(AL
|
| + } |
| + } |
| + if (!matched) |
| + LOG(WARNING) << "zram field trial: invalid group \"" << zram_group << "\""; |
| +} |
| + |
| } // namespace chromeos |