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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/chromeos/chromeos_version.h" | 13 #include "base/chromeos/chromeos_version.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" |
15 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
16 #include "base/linux_util.h" | 17 #include "base/linux_util.h" |
17 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
18 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
19 #include "base/string_split.h" | 20 #include "base/string_split.h" |
20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 22 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
22 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
23 #include "chrome/browser/chromeos/audio/audio_handler.h" | 24 #include "chrome/browser/chromeos/audio/audio_handler.h" |
24 #include "chrome/browser/chromeos/boot_times_loader.h" | 25 #include "chrome/browser/chromeos/boot_times_loader.h" |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 711 |
711 // Let the UserManager unregister itself as an observer of the CrosSettings | 712 // Let the UserManager unregister itself as an observer of the CrosSettings |
712 // singleton before it is destroyed. | 713 // singleton before it is destroyed. |
713 UserManager::Get()->Shutdown(); | 714 UserManager::Get()->Shutdown(); |
714 | 715 |
715 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); | 716 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); |
716 } | 717 } |
717 | 718 |
718 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { | 719 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { |
719 SetupLowMemoryHeadroomFieldTrial(); | 720 SetupLowMemoryHeadroomFieldTrial(); |
| 721 SetupZramFieldTrial(); |
720 } | 722 } |
721 | 723 |
722 void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { | 724 void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { |
723 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 725 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
724 // Only enable this experiment on Canary and Dev, since it's possible | 726 // Only enable this experiment on Canary and Dev, since it's possible |
725 // that this will make the machine unstable. | 727 // that this will make the machine unstable. |
726 // Note that to have this code execute in a developer build, | 728 // Note that to have this code execute in a developer build, |
727 // then chrome::VersionInfo::CHANNEL_UNKNOWN needs to be added here. | 729 // then chrome::VersionInfo::CHANNEL_UNKNOWN needs to be added here. |
728 if (channel == chrome::VersionInfo::CHANNEL_CANARY || | 730 if (channel == chrome::VersionInfo::CHANNEL_CANARY || |
729 channel == chrome::VersionInfo::CHANNEL_DEV) { | 731 channel == chrome::VersionInfo::CHANNEL_DEV) { |
(...skipping 28 matching lines...) Expand all Loading... |
758 LowMemoryObserver::SetLowMemoryMargin(100); | 760 LowMemoryObserver::SetLowMemoryMargin(100); |
759 } else if (trial->group() == margin_200mb) { | 761 } else if (trial->group() == margin_200mb) { |
760 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; | 762 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; |
761 LowMemoryObserver::SetLowMemoryMargin(200); | 763 LowMemoryObserver::SetLowMemoryMargin(200); |
762 } else { | 764 } else { |
763 LOG(WARNING) << "low_mem: Part of 'default' experiment"; | 765 LOG(WARNING) << "low_mem: Part of 'default' experiment"; |
764 } | 766 } |
765 } | 767 } |
766 } | 768 } |
767 | 769 |
| 770 |
| 771 void ChromeBrowserMainPartsChromeos::SetupZramFieldTrial() { |
| 772 // The dice for this experiment have been thrown at boot. The selected group |
| 773 // number is stored in a file. |
| 774 const FilePath kZramGroupPath("/home/chronos/.swap_exp_enrolled"); |
| 775 std::string zram_file_content; |
| 776 // If the file does not exist, the experiment has not started. |
| 777 if (!file_util::ReadFileToString(kZramGroupPath, &zram_file_content)) |
| 778 return; |
| 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 |
| 781 // group names. (See src/platform/init/swap-exp.conf in chromiumos repo for |
| 782 // group meanings.) |
| 783 std::string zram_group = zram_file_content.substr(0, 1); |
| 784 if (zram_group.compare("x") == 0) |
| 785 return; |
| 786 const base::FieldTrial::Probability kDivisor = 1; // on/off only |
| 787 scoped_refptr<base::FieldTrial> trial = |
| 788 base::FieldTrialList::FactoryGetFieldTrial( |
| 789 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); |
| 790 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to |
| 791 // all other choices. |
| 792 const char* const kGroups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; |
| 793 bool matched = false; |
| 794 for (size_t i = 0; i < arraysize(kGroups); ++i) { |
| 795 bool match = zram_group.compare(kGroups[i]) == 0; |
| 796 trial->AppendGroup(kGroups[i], match ? 1 : 0); |
| 797 if (match) { |
| 798 matched = true; |
| 799 LOG(WARNING) << "zram field trial: group " << kGroups[i]; |
| 800 } |
| 801 } |
| 802 if (!matched) |
| 803 LOG(WARNING) << "zram field trial: invalid group \"" << zram_group << "\""; |
| 804 } |
| 805 |
768 } // namespace chromeos | 806 } // namespace chromeos |
OLD | NEW |