summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 21:22:31 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 21:22:31 +0000
commit08110ceae09a5e148e67bebd712e7ba1840ccf42 (patch)
tree94bdbbc82317bc6f7579d552aace6becd1beaab2 /chrome
parenta61c5c9bb6524d77c30b6a18f542c0e4616ee7bc (diff)
downloadchromium_src-08110ceae09a5e148e67bebd712e7ba1840ccf42.zip
chromium_src-08110ceae09a5e148e67bebd712e7ba1840ccf42.tar.gz
chromium_src-08110ceae09a5e148e67bebd712e7ba1840ccf42.tar.bz2
Move SystemMonitor to src/ui/base/system_monitor.
Move HiResTimerManager to src/chrome/common. BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/6361002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_main.cc6
-rw-r--r--chrome/browser/browser_main.h7
-rw-r--r--chrome/browser/profiles/profile_manager.cc4
-rw-r--r--chrome/browser/profiles/profile_manager.h4
-rw-r--r--chrome/browser/profiles/profile_manager_unittest.cc6
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc6
-rw-r--r--chrome/chrome_common.gypi3
-rw-r--r--chrome/common/hi_res_timer_manager.h30
-rw-r--r--chrome/common/hi_res_timer_manager_posix.cc20
-rw-r--r--chrome/common/hi_res_timer_manager_win.cc29
-rw-r--r--chrome/nacl/nacl_main.cc8
-rw-r--r--chrome/plugin/plugin_main.cc6
-rw-r--r--chrome/renderer/renderer_main.cc6
-rw-r--r--chrome/utility/utility_main.cc6
-rw-r--r--chrome/worker/worker_main.cc6
15 files changed, 116 insertions, 31 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 961f783..64f0dd3 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -8,10 +8,8 @@
#include <string>
#include <vector>
-#include "app/hi_res_timer_manager.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "app/system_monitor.h"
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/debug/trace_event.h"
@@ -78,6 +76,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
+#include "chrome/common/hi_res_timer_manager.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/logging_chrome.h"
@@ -101,6 +100,7 @@
#include "net/spdy/spdy_session_pool.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_throttler_manager.h"
+#include "ui/base/system_monitor/system_monitor.h"
#if defined(USE_LINUX_BREAKPAD)
#include "base/linux_util.h"
@@ -469,7 +469,7 @@ void BrowserMainParts::MainMessageLoopStart() {
main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI));
// TODO(viettrungluu): should these really go before setting the thread name?
- system_monitor_.reset(new SystemMonitor);
+ system_monitor_.reset(new ui::SystemMonitor);
hi_res_timer_manager_.reset(new HighResolutionTimerManager);
network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
diff --git a/chrome/browser/browser_main.h b/chrome/browser/browser_main.h
index 9154a4c..7fd7142 100644
--- a/chrome/browser/browser_main.h
+++ b/chrome/browser/browser_main.h
@@ -17,12 +17,15 @@ class HighResolutionTimerManager;
struct MainFunctionParams;
class MessageLoop;
class MetricsService;
-class SystemMonitor;
namespace net {
class NetworkChangeNotifier;
}
+namespace ui {
+class SystemMonitor;
+}
+
// BrowserMainParts:
// This class contains different "stages" to be executed in |BrowserMain()|,
// mostly initialization. This is made into a class rather than just functions
@@ -144,7 +147,7 @@ class BrowserMainParts {
// Members initialized in |MainMessageLoopStart()| ---------------------------
scoped_ptr<MessageLoop> main_message_loop_;
- scoped_ptr<SystemMonitor> system_monitor_;
+ scoped_ptr<ui::SystemMonitor> system_monitor_;
scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_;
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
scoped_ptr<BrowserThread> main_thread_;
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 87a03ea..2bae317 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -51,7 +51,7 @@ Profile* ProfileManager::GetDefaultProfile() {
}
ProfileManager::ProfileManager() : logged_in_(false) {
- SystemMonitor::Get()->AddObserver(this);
+ ui::SystemMonitor::Get()->AddObserver(this);
#if defined(OS_CHROMEOS)
registrar_.Add(
this,
@@ -61,7 +61,7 @@ ProfileManager::ProfileManager() : logged_in_(false) {
}
ProfileManager::~ProfileManager() {
- SystemMonitor* system_monitor = SystemMonitor::Get();
+ ui::SystemMonitor* system_monitor = ui::SystemMonitor::Get();
if (system_monitor)
system_monitor->RemoveObserver(this);
diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h
index 1d6483d..d2f9281 100644
--- a/chrome/browser/profiles/profile_manager.h
+++ b/chrome/browser/profiles/profile_manager.h
@@ -10,18 +10,18 @@
#include <vector>
-#include "app/system_monitor.h"
#include "base/basictypes.h"
#include "base/message_loop.h"
#include "base/threading/non_thread_safe.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
+#include "ui/base/system_monitor/system_monitor.h"
class FilePath;
class ProfileManager : public base::NonThreadSafe,
- public SystemMonitor::PowerObserver,
+ public ui::SystemMonitor::PowerObserver,
public NotificationObserver {
public:
ProfileManager();
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 42f6d91..6f3ef1a 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -4,7 +4,6 @@
#include <string>
-#include "app/system_monitor.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -18,6 +17,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/system_monitor/system_monitor.h"
class ProfileManagerTest : public testing::Test {
protected:
@@ -75,7 +75,7 @@ TEST_F(ProfileManagerTest, CreateProfile) {
TEST_F(ProfileManagerTest, DefaultProfileDir) {
CommandLine *cl = CommandLine::ForCurrentProcess();
- SystemMonitor dummy;
+ ui::SystemMonitor dummy;
ProfileManager profile_manager;
std::string profile_dir("my_user");
@@ -91,7 +91,7 @@ TEST_F(ProfileManagerTest, DefaultProfileDir) {
// This functionality only exists on Chrome OS.
TEST_F(ProfileManagerTest, LoggedInProfileDir) {
CommandLine *cl = CommandLine::ForCurrentProcess();
- SystemMonitor dummy;
+ ui::SystemMonitor dummy;
ProfileManager profile_manager;
std::string profile_dir("my_user");
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index a21ef74..21ed2a5 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -5,7 +5,6 @@
#include <map>
#include <string>
-#include "app/system_monitor.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -36,6 +35,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/system_monitor/system_monitor.h"
using testing::_;
@@ -230,8 +230,8 @@ class TabStripModelTest : public RenderViewHostTestHarness {
std::wstring profile_path_;
std::map<TabContents*, int> foo_;
- // ProfileManager requires a SystemMonitor.
- SystemMonitor system_monitor;
+ // ProfileManager requires a ui::SystemMonitor.
+ ui::SystemMonitor system_monitor;
ProfileManager pm_;
};
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index a7cd981..869653f 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -93,6 +93,9 @@
'common/guid.h',
'common/guid_posix.cc',
'common/guid_win.cc',
+ 'common/hi_res_timer_manager_posix.cc',
+ 'common/hi_res_timer_manager_win.cc',
+ 'common/hi_res_timer_manager.h',
'common/indexed_db_key.cc',
'common/indexed_db_key.h',
'common/indexed_db_messages.cc',
diff --git a/chrome/common/hi_res_timer_manager.h b/chrome/common/hi_res_timer_manager.h
new file mode 100644
index 0000000..5610a61
--- /dev/null
+++ b/chrome/common/hi_res_timer_manager.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_HI_RES_TIMER_MANAGER_H_
+#define CHROME_COMMON_HI_RES_TIMER_MANAGER_H_
+#pragma once
+
+#include "ui/base/system_monitor/system_monitor.h"
+
+// Ensures that the Windows high resolution timer is only used
+// when not running on battery power.
+class HighResolutionTimerManager : public ui::SystemMonitor::PowerObserver {
+ public:
+ HighResolutionTimerManager();
+ virtual ~HighResolutionTimerManager();
+
+ // ui::SystemMonitor::PowerObserver:
+ virtual void OnPowerStateChange(bool on_battery_power);
+
+ private:
+ // Enable or disable the faster multimedia timer.
+ void UseHiResClock(bool use);
+
+ bool hi_res_clock_used_;
+
+ DISALLOW_COPY_AND_ASSIGN(HighResolutionTimerManager);
+};
+
+#endif // CHROME_COMMON_HI_RES_TIMER_MANAGER_H_ \ No newline at end of file
diff --git a/chrome/common/hi_res_timer_manager_posix.cc b/chrome/common/hi_res_timer_manager_posix.cc
new file mode 100644
index 0000000..fc9c1ba
--- /dev/null
+++ b/chrome/common/hi_res_timer_manager_posix.cc
@@ -0,0 +1,20 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/hi_res_timer_manager.h"
+
+// On POSIX we don't need to do anything special with the system timer.
+
+HighResolutionTimerManager::HighResolutionTimerManager()
+ : hi_res_clock_used_(false) {
+}
+
+HighResolutionTimerManager::~HighResolutionTimerManager() {
+}
+
+void HighResolutionTimerManager::OnPowerStateChange(bool on_battery_power) {
+}
+
+void HighResolutionTimerManager::UseHiResClock(bool use) {
+}
diff --git a/chrome/common/hi_res_timer_manager_win.cc b/chrome/common/hi_res_timer_manager_win.cc
new file mode 100644
index 0000000..c165222
--- /dev/null
+++ b/chrome/common/hi_res_timer_manager_win.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/hi_res_timer_manager.h"
+
+#include "base/time.h"
+
+HighResolutionTimerManager::HighResolutionTimerManager()
+ : hi_res_clock_used_(false) {
+ ui::SystemMonitor* system_monitor = ui::SystemMonitor::Get();
+ system_monitor->AddObserver(this);
+ UseHiResClock(!system_monitor->BatteryPower());
+}
+
+HighResolutionTimerManager::~HighResolutionTimerManager() {
+ ui::SystemMonitor::Get()->RemoveObserver(this);
+ UseHiResClock(false);
+}
+
+void HighResolutionTimerManager::OnPowerStateChange(bool on_battery_power) {
+ UseHiResClock(!on_battery_power);
+}
+
+void HighResolutionTimerManager::UseHiResClock(bool use) {
+ if (use == hi_res_clock_used_)
+ return;
+ base::Time::EnableHighResolutionTimer(use);
+}
diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc
index 0e63273..cb7fe26 100644
--- a/chrome/nacl/nacl_main.cc
+++ b/chrome/nacl/nacl_main.cc
@@ -8,8 +8,6 @@
#include <windows.h>
#endif
-#include "app/hi_res_timer_manager.h"
-#include "app/system_monitor.h"
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -21,12 +19,14 @@
#include "chrome/common/child_process.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/hi_res_timer_manager.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/result_codes.h"
#include "chrome/common/sandbox_policy.h"
#include "chrome/nacl/nacl_main_platform_delegate.h"
#include "chrome/nacl/nacl_thread.h"
+#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_WIN)
#include "chrome/nacl/broker_thread.h"
@@ -43,7 +43,7 @@ int NaClBrokerMain(const MainFunctionParams& parameters) {
MessageLoopForIO main_message_loop;
base::PlatformThread::SetName("CrNaClBrokerMain");
- SystemMonitor system_monitor;
+ ui::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
const CommandLine& parsed_command_line = parameters.command_line_;
@@ -111,7 +111,7 @@ int NaClMain(const MainFunctionParams& parameters) {
MessageLoopForIO main_message_loop;
base::PlatformThread::SetName("CrNaClMain");
- SystemMonitor system_monitor;
+ ui::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc
index dee171c..8417e92 100644
--- a/chrome/plugin/plugin_main.cc
+++ b/chrome/plugin/plugin_main.cc
@@ -9,8 +9,6 @@
#include <windows.h>
#endif
-#include "app/hi_res_timer_manager.h"
-#include "app/system_monitor.h"
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -20,9 +18,11 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/default_plugin.h"
#include "chrome/common/gpu_plugin.h"
+#include "chrome/common/hi_res_timer_manager.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/main_function_params.h"
#include "chrome/plugin/plugin_thread.h"
+#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_WIN)
#include "chrome/test/injection_test_dll.h"
@@ -94,7 +94,7 @@ int PluginMain(const MainFunctionParams& parameters) {
MessageLoop main_message_loop(MessageLoop::TYPE_UI);
base::PlatformThread::SetName("CrPluginMain");
- SystemMonitor system_monitor;
+ ui::SystemMonitor system_monitor;
HighResolutionTimerManager high_resolution_timer_manager;
const CommandLine& parsed_command_line = parameters.command_line_;
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index a380902..8a08d4c 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -7,8 +7,6 @@
#include <unistd.h>
#endif // OS_MACOSX
-#include "app/hi_res_timer_manager.h"
-#include "app/system_monitor.h"
#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/mac/scoped_nsautorelease_pool.h"
@@ -23,6 +21,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/hi_res_timer_manager.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/net/net_resource_provider.h"
@@ -32,6 +31,7 @@
#include "chrome/renderer/render_thread.h"
#include "grit/generated_resources.h"
#include "net/base/net_module.h"
+#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_MACOSX)
#include "base/eintr_wrapper.h"
@@ -240,7 +240,7 @@ int RendererMain(const MainFunctionParams& parameters) {
base::PlatformThread::SetName("CrRendererMain");
- SystemMonitor system_monitor;
+ ui::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
platform.PlatformInitialize();
diff --git a/chrome/utility/utility_main.cc b/chrome/utility/utility_main.cc
index 74360c8..d0159dd 100644
--- a/chrome/utility/utility_main.cc
+++ b/chrome/utility/utility_main.cc
@@ -3,8 +3,6 @@
// found in the LICENSE file.
#include "app/app_switches.h"
-#include "app/hi_res_timer_manager.h"
-#include "app/system_monitor.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -15,9 +13,11 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_l10n_util.h"
+#include "chrome/common/hi_res_timer_manager.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/main_function_params.h"
#include "chrome/utility/utility_thread.h"
+#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_WIN)
#include "chrome/common/chrome_switches.h"
@@ -31,7 +31,7 @@ int UtilityMain(const MainFunctionParams& parameters) {
MessageLoop main_message_loop;
base::PlatformThread::SetName("CrUtilityMain");
- SystemMonitor system_monitor;
+ ui::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
ChildProcess utility_process;
diff --git a/chrome/worker/worker_main.cc b/chrome/worker/worker_main.cc
index 0ba0e87..c39a4b8 100644
--- a/chrome/worker/worker_main.cc
+++ b/chrome/worker/worker_main.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "app/hi_res_timer_manager.h"
-#include "app/system_monitor.h"
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -11,9 +9,11 @@
#include "chrome/common/child_process.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/hi_res_timer_manager.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/main_function_params.h"
#include "chrome/worker/worker_thread.h"
+#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_WIN)
#include "chrome/common/sandbox_init_wrapper.h"
@@ -26,7 +26,7 @@ int WorkerMain(const MainFunctionParams& parameters) {
MessageLoop main_message_loop;
base::PlatformThread::SetName("CrWorkerMain");
- SystemMonitor system_monitor;
+ ui::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
ChildProcess worker_process;