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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 | 706 |
706 // Let the UserManager unregister itself as an observer of the CrosSettings | 707 // Let the UserManager unregister itself as an observer of the CrosSettings |
707 // singleton before it is destroyed. | 708 // singleton before it is destroyed. |
708 UserManager::Get()->Shutdown(); | 709 UserManager::Get()->Shutdown(); |
709 | 710 |
710 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); | 711 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); |
711 } | 712 } |
712 | 713 |
713 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { | 714 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { |
714 SetupLowMemoryHeadroomFieldTrial(); | 715 SetupLowMemoryHeadroomFieldTrial(); |
716 SetupZramFieldTrial(); | |
715 } | 717 } |
716 | 718 |
717 void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { | 719 void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { |
718 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 720 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
719 // Only enable this experiment on Canary and Dev, since it's possible | 721 // Only enable this experiment on Canary and Dev, since it's possible |
720 // that this will make the machine unstable. | 722 // that this will make the machine unstable. |
721 // Note that to have this code execute in a developer build, | 723 // Note that to have this code execute in a developer build, |
722 // then chrome::VersionInfo::CHANNEL_UNKNOWN needs to be added here. | 724 // then chrome::VersionInfo::CHANNEL_UNKNOWN needs to be added here. |
723 if (channel == chrome::VersionInfo::CHANNEL_CANARY || | 725 if (channel == chrome::VersionInfo::CHANNEL_CANARY || |
724 channel == chrome::VersionInfo::CHANNEL_DEV) { | 726 channel == chrome::VersionInfo::CHANNEL_DEV) { |
(...skipping 28 matching lines...) Expand all Loading... | |
753 LowMemoryObserver::SetLowMemoryMargin(100); | 755 LowMemoryObserver::SetLowMemoryMargin(100); |
754 } else if (trial->group() == margin_200mb) { | 756 } else if (trial->group() == margin_200mb) { |
755 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; | 757 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; |
756 LowMemoryObserver::SetLowMemoryMargin(200); | 758 LowMemoryObserver::SetLowMemoryMargin(200); |
757 } else { | 759 } else { |
758 LOG(WARNING) << "low_mem: Part of 'default' experiment"; | 760 LOG(WARNING) << "low_mem: Part of 'default' experiment"; |
759 } | 761 } |
760 } | 762 } |
761 } | 763 } |
762 | 764 |
765 | |
766 void ChromeBrowserMainPartsChromeos::SetupZramFieldTrial() { | |
767 // The dice for this experiment has been thrown at boot. The selected group | |
Ilya Sherman
2013/01/08 02:19:04
nit: either "has" -> "have" or "dice" -> "die"
Luigi Semenzato
2013/01/08 18:17:57
Both forms (die and dice) are used for the singula
| |
768 // number is stored in a file. | |
769 const FilePath kZramGroupPath("/home/chronos/.swap_exp_enrolled"); | |
James Cook
2013/01/08 05:07:43
We frequently run a linux_chromeos build on Ubuntu
Luigi Semenzato
2013/01/08 18:17:57
If the file does not exist, the experiment is not
James Cook
2013/01/08 19:03:44
I'm afraid this might cause NFS to attempt to moun
Luigi Semenzato
2013/01/08 21:28:18
We discussed this offline and decided to leave as
| |
770 std::string zram_group; | |
771 // If the file does not exist, the experiment has not started. If the file | |
772 // exists but contains an "x", the user has a non-standard swap size and has | |
773 // been opted out. | |
774 if (!file_util::ReadFileToString(kZramGroupPath, &zram_group) || | |
James Cook
2013/01/08 05:07:43
We should run this in a Debug build to make sure w
Luigi Semenzato
2013/01/08 18:17:57
OK, thanks.
I don't even know if the file thread
James Cook
2013/01/08 19:03:44
If the file thread isn't created yet, this should
Luigi Semenzato
2013/01/08 21:28:18
James tested this and no assertion is produced.
| |
775 StartsWithASCII(zram_group, "x", true)) { | |
776 return; | |
777 } | |
778 const base::FieldTrial::Probability kDivisor = 1; // on/off only | |
779 scoped_refptr<base::FieldTrial> trial = | |
780 base::FieldTrialList::FactoryGetFieldTrial( | |
781 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); | |
782 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to | |
783 // all other choices. | |
784 const char *groups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; | |
Ilya Sherman
2013/01/08 02:19:04
nit: "const char* const kGroups[] = ..."
Ilya Sherman
2013/01/08 02:19:04
Is 9 intentionally omitted? What do each of these
Luigi Semenzato
2013/01/08 18:17:57
OK
Luigi Semenzato
2013/01/08 18:17:57
Yes, there are only 9 groups (0-8).
Should the gr
Ilya Sherman
2013/01/08 20:16:16
It's always nice when names are self-documenting.
Luigi Semenzato
2013/01/08 21:28:18
OK. I was about to change the names, but then asv
| |
785 for (unsigned int i = 0; i < sizeof(groups) / sizeof(groups[0]); i++) { | |
Ilya Sherman
2013/01/08 02:19:04
nit: Please use the arraysize macro here.
Ilya Sherman
2013/01/08 02:19:04
nit: "unsigned int" -> "size_t"
Ilya Sherman
2013/01/08 02:19:04
nit: "i++" -> "++i"
Luigi Semenzato
2013/01/08 18:17:57
OK
Luigi Semenzato
2013/01/08 18:17:57
Are you sure? A size divided by a size is a dimen
Luigi Semenzato
2013/01/08 18:17:57
OK
Ilya Sherman
2013/01/08 20:16:16
According to [ http://dev.chromium.org/developers/
Luigi Semenzato
2013/01/08 21:28:18
Thank you for setting me straight on this.
| |
786 bool match = StartsWithASCII(zram_group, groups[i], true); | |
Ilya Sherman
2013/01/08 02:19:04
Why are you checking for a prefix, rather than dir
Luigi Semenzato
2013/01/08 18:17:57
Because I don't want to have to worry whether the
Ilya Sherman
2013/01/08 20:16:16
IMO it would be better to trim off any whitespace,
| |
787 (void) trial->AppendGroup(groups[i], match ? 1 : 0); | |
Ilya Sherman
2013/01/08 02:19:04
nit: Remove the "(void)"
Luigi Semenzato
2013/01/08 18:17:57
OK. I thought it may help to indicate I am aware
James Cook
2013/01/08 19:03:44
I think Chrome-style is to leave it out.
| |
788 if (match) { | |
789 LOG(WARNING) << "zram field trial: group " << groups[i]; | |
Ilya Sherman
2013/01/08 02:19:04
nit: Can this be a DVLOG(1)?
James Cook
2013/01/08 05:07:43
Actually, I'd be OK with leaving this in as a warn
Luigi Semenzato
2013/01/08 18:17:57
Yes, it's only one line and I would prefer to alwa
Ilya Sherman
2013/01/08 20:16:16
FWIW, the list of running field trials is also ava
Luigi Semenzato
2013/01/08 21:28:18
Good to know, thanks, but if you don't mind I'd le
| |
790 } | |
Ilya Sherman
2013/01/08 02:19:04
nit: No need for curly braces since this is a 1-li
Luigi Semenzato
2013/01/08 18:17:57
OK
| |
791 } | |
792 } | |
793 | |
763 } // namespace chromeos | 794 } // namespace chromeos |
OLD | NEW |