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

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.length() == 0) {
James Cook 2013/01/09 18:57:24 nit: Chrome-style for std::string is to use zram_f
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);
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
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