Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1702)

Side by Side Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

Issue 11823028: Use better group names for zram field trial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@zram2
Patch Set: Use better group names for zram field trial Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.value()
785 << " is empty";
785 return; 786 return;
787 }
788 char zram_group = zram_file_content[0];
789 if (zram_group == 'x')
790 return;
791 if (zram_group < '0' || zram_group > '8') {
792 LOG(WARNING) << "zram field trial: invalid group \"" << zram_group << "\"";
793 return;
794 }
795 LOG(WARNING) << "zram field trial: group " << zram_group;
786 const base::FieldTrial::Probability kDivisor = 1; // on/off only 796 const base::FieldTrial::Probability kDivisor = 1; // on/off only
787 scoped_refptr<base::FieldTrial> trial = 797 scoped_refptr<base::FieldTrial> trial =
788 base::FieldTrialList::FactoryGetFieldTrial( 798 base::FieldTrialList::FactoryGetFieldTrial(
789 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); 799 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL);
790 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to 800 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to
791 // all other choices. 801 // all other choices.
792 const char* const kGroups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; 802 trial->AppendGroup("2GB_RAM_no_swap", zram_group == '0' ? 1 : 0);
793 bool matched = false; 803 trial->AppendGroup("2GB_RAM_2GB_swap", zram_group == '1' ? 1 : 0);
794 for (size_t i = 0; i < arraysize(kGroups); ++i) { 804 trial->AppendGroup("2GB_RAM_3GB_swap", zram_group == '2' ? 1 : 0);
795 bool match = zram_group.compare(kGroups[i]) == 0; 805 trial->AppendGroup("4GB_RAM_no_swap", zram_group == '3' ? 1 : 0);
796 trial->AppendGroup(kGroups[i], match ? 1 : 0); 806 trial->AppendGroup("4GB_RAM_4GB_swap", zram_group == '4' ? 1 : 0);
797 if (match) { 807 trial->AppendGroup("4GB_RAM_6GB_swap", zram_group == '5' ? 1 : 0);
798 matched = true; 808 trial->AppendGroup("snow_no_swap", zram_group == '6' ? 1 : 0);
799 LOG(WARNING) << "zram field trial: group " << kGroups[i]; 809 trial->AppendGroup("snow_1GB_swap", zram_group == '7' ? 1 : 0);
800 } 810 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 } 811 }
805 812
806 } // namespace chromeos 813 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698