OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/chromeos/memory_pressure_observer_chromeos.h" | |
15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
16 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
17 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
18 #include "base/linux_util.h" | 17 #include "base/linux_util.h" |
19 #include "base/path_service.h" | 18 #include "base/path_service.h" |
20 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
21 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
23 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
24 #include "base/task_runner_util.h" | 23 #include "base/task_runner_util.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 325 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
327 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 326 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
328 // implementation. This must be done before BrowserMainLoop calls | 327 // implementation. This must be done before BrowserMainLoop calls |
329 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). | 328 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). |
330 net::NetworkChangeNotifier::SetFactory( | 329 net::NetworkChangeNotifier::SetFactory( |
331 new NetworkChangeNotifierFactoryChromeos()); | 330 new NetworkChangeNotifierFactoryChromeos()); |
332 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); | 331 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
333 } | 332 } |
334 | 333 |
335 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 334 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
336 // Instantiate the MemoryPressureObserver. | |
337 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
338 switches::kUseMemoryPressureSystemChromeOS)) { | |
339 memory_pressure_observer_.reset(new base::MemoryPressureObserverChromeOS); | |
340 } | |
341 | |
342 base::FilePath user_data_dir; | 335 base::FilePath user_data_dir; |
343 if (!base::SysInfo::IsRunningOnChromeOS() && | 336 if (!base::SysInfo::IsRunningOnChromeOS() && |
344 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 337 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
345 // Override some paths with stub locations so that cloud policy and | 338 // Override some paths with stub locations so that cloud policy and |
346 // enterprise enrollment work on desktop builds, for ease of | 339 // enterprise enrollment work on desktop builds, for ease of |
347 // development. | 340 // development. |
348 chromeos::RegisterStubPathOverrides(user_data_dir); | 341 chromeos::RegisterStubPathOverrides(user_data_dir); |
349 } | 342 } |
350 | 343 |
351 dbus_services_.reset(new internal::DBusServices(parameters())); | 344 dbus_services_.reset(new internal::DBusServices(parameters())); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 keyboard_event_rewriters_->Init(); | 694 keyboard_event_rewriters_->Init(); |
702 #endif | 695 #endif |
703 | 696 |
704 ChromeBrowserMainPartsLinux::PostBrowserStart(); | 697 ChromeBrowserMainPartsLinux::PostBrowserStart(); |
705 } | 698 } |
706 | 699 |
707 // Shut down services before the browser process, etc are destroyed. | 700 // Shut down services before the browser process, etc are destroyed. |
708 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { | 701 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { |
709 BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", true); | 702 BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", true); |
710 | 703 |
711 // Remove the MemoryPressureObserver since it is not needed anymore. | |
712 memory_pressure_observer_.reset(); | |
713 | |
714 g_browser_process->platform_part()->oom_priority_manager()->Stop(); | 704 g_browser_process->platform_part()->oom_priority_manager()->Stop(); |
715 | 705 |
716 // Early wake-up of HID device service. | 706 // Early wake-up of HID device service. |
717 InputServiceProxy::WarmUp(); | 707 InputServiceProxy::WarmUp(); |
718 | 708 |
719 // Destroy the application name notifier for Kiosk mode. | 709 // Destroy the application name notifier for Kiosk mode. |
720 KioskModeIdleAppNameNotification::Shutdown(); | 710 KioskModeIdleAppNameNotification::Shutdown(); |
721 | 711 |
722 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | 712 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
723 // stops monitoring changes from the update engine. | 713 // stops monitoring changes from the update engine. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 // Destroy DBus services immediately after threads are stopped. | 824 // Destroy DBus services immediately after threads are stopped. |
835 dbus_services_.reset(); | 825 dbus_services_.reset(); |
836 | 826 |
837 ChromeBrowserMainPartsLinux::PostDestroyThreads(); | 827 ChromeBrowserMainPartsLinux::PostDestroyThreads(); |
838 | 828 |
839 // Destroy DeviceSettingsService after g_browser_process. | 829 // Destroy DeviceSettingsService after g_browser_process. |
840 DeviceSettingsService::Shutdown(); | 830 DeviceSettingsService::Shutdown(); |
841 } | 831 } |
842 | 832 |
843 } // namespace chromeos | 833 } // namespace chromeos |
OLD | NEW |