OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/chromeos/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 // number is stored in a file. | 773 // number is stored in a file. |
774 const FilePath kZramGroupPath("/home/chronos/.swap_exp_enrolled"); | 774 const FilePath kZramGroupPath("/home/chronos/.swap_exp_enrolled"); |
775 std::string zram_file_content; | 775 std::string zram_file_content; |
776 // If the file does not exist, the experiment has not started. | 776 // If the file does not exist, the experiment has not started. |
777 if (!file_util::ReadFileToString(kZramGroupPath, &zram_file_content)) | 777 if (!file_util::ReadFileToString(kZramGroupPath, &zram_file_content)) |
778 return; | 778 return; |
779 // The file contains a single significant character, possibly followed by | 779 // The file contains a single significant character, possibly followed by |
780 // newline. "x" means the user has opted out. "0" through "8" are the valid | 780 // newline. "x" means the user has opted out. "0" through "8" are the valid |
781 // group names. (See src/platform/init/swap-exp.conf in chromiumos repo for | 781 // group names. (See src/platform/init/swap-exp.conf in chromiumos repo for |
782 // group meanings.) | 782 // group meanings.) |
783 std::string zram_group = zram_file_content.substr(0, 1); | 783 if (zram_file_content.empty()) { |
784 if (zram_group.compare("x") == 0) | 784 LOG(WARNING) << "zram field trial: " << kZramGroupPath << " is empty"; |
785 return; | 785 return; |
786 } | |
787 char zram_group = zram_file_content[0]; | |
788 if (zram_group == 'x') | |
789 return; | |
790 if (zram_group < '0' || zram_group > '8') { | |
791 LOG(WARNING) << "zram field trial: invalid group \"" << zram_group << "\""; | |
792 return; | |
793 } | |
794 LOG(WARNING) << "zram field trial: group " << zram_group; | |
786 const base::FieldTrial::Probability kDivisor = 1; // on/off only | 795 const base::FieldTrial::Probability kDivisor = 1; // on/off only |
787 scoped_refptr<base::FieldTrial> trial = | 796 scoped_refptr<base::FieldTrial> trial = |
788 base::FieldTrialList::FactoryGetFieldTrial( | 797 base::FieldTrialList::FactoryGetFieldTrial( |
789 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); | 798 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); |
790 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to | 799 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to |
791 // all other choices. | 800 // all other choices. |
792 const char* const kGroups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; | 801 trial->AppendGroup("2GB RAM, no swap", zram_group == '0' ? 1 : 0); |
Alexei Svitkine (slow)
2013/01/09 19:22:06
Can you make the group names not have spaces and c
Luigi Semenzato
2013/01/09 19:25:31
Done.
| |
793 bool matched = false; | 802 trial->AppendGroup("2GB RAM, 2GB swap", zram_group == '1' ? 1 : 0); |
794 for (size_t i = 0; i < arraysize(kGroups); ++i) { | 803 trial->AppendGroup("2GB RAM, 3GB swap", zram_group == '2' ? 1 : 0); |
795 bool match = zram_group.compare(kGroups[i]) == 0; | 804 trial->AppendGroup("4GB RAM, no swap", zram_group == '3' ? 1 : 0); |
796 trial->AppendGroup(kGroups[i], match ? 1 : 0); | 805 trial->AppendGroup("4GB RAM, 4GB swap", zram_group == '4' ? 1 : 0); |
797 if (match) { | 806 trial->AppendGroup("4GB RAM, 6GB swap", zram_group == '5' ? 1 : 0); |
798 matched = true; | 807 trial->AppendGroup("snow, no swap", zram_group == '6' ? 1 : 0); |
799 LOG(WARNING) << "zram field trial: group " << kGroups[i]; | 808 trial->AppendGroup("snow, 1GB swap", zram_group == '7' ? 1 : 0); |
800 } | 809 trial->AppendGroup("snow, 2GB swap", zram_group == '8' ? 1 : 0); |
801 } | |
802 if (!matched) | |
803 LOG(WARNING) << "zram field trial: invalid group \"" << zram_group << "\""; | |
804 } | 810 } |
805 | 811 |
806 } // namespace chromeos | 812 } // namespace chromeos |
OLD | NEW |