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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 } | 767 } |
768 } | 768 } |
769 | 769 |
770 | 770 |
771 void ChromeBrowserMainPartsChromeos::SetupZramFieldTrial() { | 771 void ChromeBrowserMainPartsChromeos::SetupZramFieldTrial() { |
772 // The dice for this experiment have been thrown at boot. The selected group | 772 // The dice for this experiment have been thrown at boot. The selected group |
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)) |
James Cook
2013/01/09 18:17:17
Does this need a check for zram_file_content.empty
Luigi Semenzato
2013/01/09 18:52:43
Ah, I was assuming empty file == null-terminated e
| |
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 char zram_group = zram_file_content[0]; |
Alexei Svitkine (slow)
2013/01/09 19:00:36
Can you check that !zram_file_content.empty() some
Alexei Svitkine (slow)
2013/01/09 19:01:24
Sorry, I wrote this before you addressed James' co
| |
784 if (zram_group.compare("x") == 0) | 784 if (zram_group == 'x') |
785 return; | 785 return; |
786 if (zram_group < '0' || zram_group > '8') { | |
787 LOG(WARNING) << "zram field trial: invalid group \"" << zram_group << "\""; | |
788 return; | |
789 } | |
790 LOG(WARNING) << "zram field trial: group " << zram_group; | |
Alexei Svitkine (slow)
2013/01/09 19:00:36
field_trial.cc has VLOGs that can tell you this al
Luigi Semenzato
2013/01/09 19:15:49
We discussed this in the previous review. That's
| |
786 const base::FieldTrial::Probability kDivisor = 1; // on/off only | 791 const base::FieldTrial::Probability kDivisor = 1; // on/off only |
787 scoped_refptr<base::FieldTrial> trial = | 792 scoped_refptr<base::FieldTrial> trial = |
788 base::FieldTrialList::FactoryGetFieldTrial( | 793 base::FieldTrialList::FactoryGetFieldTrial( |
789 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); | 794 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); |
790 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to | 795 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to |
791 // all other choices. | 796 // all other choices. |
792 const char* const kGroups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; | 797 trial->AppendGroup("2GB RAM, no swap", zram_group == '0' ? 1 : 0); |
793 bool matched = false; | 798 trial->AppendGroup("2GB RAM, 2GB swap", zram_group == '1' ? 1 : 0); |
794 for (size_t i = 0; i < arraysize(kGroups); ++i) { | 799 trial->AppendGroup("2GB RAM, 3GB swap", zram_group == '2' ? 1 : 0); |
795 bool match = zram_group.compare(kGroups[i]) == 0; | 800 trial->AppendGroup("4GB RAM, no swap", zram_group == '3' ? 1 : 0); |
796 trial->AppendGroup(kGroups[i], match ? 1 : 0); | 801 trial->AppendGroup("4GB RAM, 4GB swap", zram_group == '4' ? 1 : 0); |
797 if (match) { | 802 trial->AppendGroup("4GB RAM, 6GB swap", zram_group == '5' ? 1 : 0); |
798 matched = true; | 803 trial->AppendGroup("snow, no swap", zram_group == '6' ? 1 : 0); |
799 LOG(WARNING) << "zram field trial: group " << kGroups[i]; | 804 trial->AppendGroup("snow, 1GB swap", zram_group == '7' ? 1 : 0); |
800 } | 805 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 } | 806 } |
805 | 807 |
806 } // namespace chromeos | 808 } // namespace chromeos |
OLD | NEW |