summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 07:04:06 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 07:04:06 +0000
commit69803a4f13f3eb26b982e82493672367e984907a (patch)
tree7129dda29bb0b45ae287e3d0b8d6c34e83ae98cc
parentc7e136fc8a564f1a30ef6214e4f2b5d598cfbe94 (diff)
downloadchromium_src-69803a4f13f3eb26b982e82493672367e984907a.zip
chromium_src-69803a4f13f3eb26b982e82493672367e984907a.tar.gz
chromium_src-69803a4f13f3eb26b982e82493672367e984907a.tar.bz2
Move SystemMonitor to base/.
I plan to use SystemMonitor in net/. Fix up the Mac implementation not to use Cocoa APIs since @interface is not allowed in base. BUG=none TEST=none Review URL: http://codereview.chromium.org/7015017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85732 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/app.gyp1
-rw-r--r--app/app_base.gypi5
-rw-r--r--base/base.gyp2
-rw-r--r--base/base.gypi5
-rw-r--r--base/system_monitor/system_monitor.cc (renamed from ui/base/system_monitor/system_monitor.cc)6
-rw-r--r--base/system_monitor/system_monitor.h (renamed from ui/base/system_monitor/system_monitor.h)23
-rw-r--r--base/system_monitor/system_monitor_mac.mm78
-rw-r--r--base/system_monitor/system_monitor_posix.cc (renamed from ui/base/system_monitor/system_monitor_posix.cc)6
-rw-r--r--base/system_monitor/system_monitor_unittest.cc (renamed from ui/base/system_monitor/system_monitor_unittest.cc)6
-rw-r--r--base/system_monitor/system_monitor_win.cc (renamed from ui/base/system_monitor/system_monitor_win.cc)6
-rw-r--r--chrome/browser/browser_main.cc4
-rw-r--r--chrome/browser/browser_main.h10
-rw-r--r--chrome/browser/extensions/extension_event_router_forwarder_unittest.cc4
-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.cc4
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc6
-rw-r--r--chrome/nacl/nacl_main.cc6
-rw-r--r--chrome/utility/utility_main.cc4
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc3
-rw-r--r--content/common/hi_res_timer_manager.h6
-rw-r--r--content/common/hi_res_timer_manager_win.cc4
-rw-r--r--content/plugin/plugin_main.cc6
-rw-r--r--content/renderer/renderer_main.cc4
-rw-r--r--content/worker/worker_main.cc4
-rw-r--r--ui/base/system_monitor/system_monitor_mac.mm67
-rw-r--r--ui/views/widget/native_widget_win.cc2
-rw-r--r--views/widget/widget_win.cc4
28 files changed, 147 insertions, 137 deletions
diff --git a/app/app.gyp b/app/app.gyp
index 955a6d6..e639728 100644
--- a/app/app.gyp
+++ b/app/app.gyp
@@ -41,7 +41,6 @@
'../ui/base/models/tree_node_model_unittest.cc',
'../ui/base/resource/data_pack_unittest.cc',
'../ui/base/resource/resource_bundle_unittest.cc',
- '../ui/base/system_monitor/system_monitor_unittest.cc',
'../ui/base/test/data/resource.h',
'../ui/base/text/text_elider_unittest.cc',
'../ui/base/view_prop_unittest.cc',
diff --git a/app/app_base.gypi b/app/app_base.gypi
index 82c3962..a52e391 100644
--- a/app/app_base.gypi
+++ b/app/app_base.gypi
@@ -18,11 +18,6 @@
'../ui/base/models/tree_model.h',
'../ui/base/models/tree_node_iterator.h',
'../ui/base/models/tree_node_model.h',
- '../ui/base/system_monitor/system_monitor.cc',
- '../ui/base/system_monitor/system_monitor.h',
- '../ui/base/system_monitor/system_monitor_mac.mm',
- '../ui/base/system_monitor/system_monitor_posix.cc',
- '../ui/base/system_monitor/system_monitor_win.cc',
'../ui/base/ui_base_paths.h',
'../ui/base/ui_base_paths.cc',
'../ui/base/ui_base_switches.h',
diff --git a/base/base.gyp b/base/base.gyp
index 8514894..68974f5 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -186,6 +186,7 @@
'sys_info_unittest.cc',
'sys_string_conversions_mac_unittest.mm',
'sys_string_conversions_unittest.cc',
+ 'system_monitor/system_monitor_unittest.cc',
'task_queue_unittest.cc',
'task_unittest.cc',
'template_util_unittest.cc',
@@ -283,7 +284,6 @@
['exclude', '^win/'],
],
'sources!': [
- 'system_monitor_unittest.cc',
'time_win_unittest.cc',
'trace_event_win_unittest.cc',
'win_util_unittest.cc',
diff --git a/base/base.gypi b/base/base.gypi
index 56da313..25060bb 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -243,6 +243,11 @@
'synchronization/waitable_event_watcher_posix.cc',
'synchronization/waitable_event_watcher_win.cc',
'synchronization/waitable_event_win.cc',
+ 'system_monitor/system_monitor.cc',
+ 'system_monitor/system_monitor.h',
+ 'system_monitor/system_monitor_mac.mm',
+ 'system_monitor/system_monitor_posix.cc',
+ 'system_monitor/system_monitor_win.cc',
'sys_info.h',
'sys_info_chromeos.cc',
'sys_info_freebsd.cc',
diff --git a/ui/base/system_monitor/system_monitor.cc b/base/system_monitor/system_monitor.cc
index 80110cb..7b1349c 100644
--- a/ui/base/system_monitor/system_monitor.cc
+++ b/base/system_monitor/system_monitor.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/system_monitor/system_monitor.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/time.h"
-namespace ui {
+namespace base {
static SystemMonitor* g_system_monitor = NULL;
@@ -105,4 +105,4 @@ void SystemMonitor::BatteryCheck() {
ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
}
-} // namespace ui
+} // namespace base
diff --git a/ui/base/system_monitor/system_monitor.h b/base/system_monitor/system_monitor.h
index b1e26cf..e552b26 100644
--- a/ui/base/system_monitor/system_monitor.h
+++ b/base/system_monitor/system_monitor.h
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
-#define UI_BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
+#ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
+#define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
#pragma once
+#include "base/basictypes.h"
#include "build/build_config.h"
// Windows HiRes timers drain the battery faster so we need to know the battery
@@ -22,14 +23,11 @@
#endif // defined(ENABLE_BATTERY_MONITORING)
#if defined(OS_MACOSX)
-#ifdef __OBJC__
-@class SystemMonitorBridge;
-#else
-class SystemMonitorBridge;
-#endif
-#endif
+#include <IOKit/pwr_mgt/IOPMLib.h>
+#include <IOKit/IOMessage.h>
+#endif // OS_MACOSX
-namespace ui {
+namespace base {
// Class for monitoring various system-related subsystems
// such as power management, network status, etc.
@@ -132,12 +130,13 @@ class SystemMonitor {
#endif
#if defined(OS_MACOSX)
- SystemMonitorBridge* system_monitor_bridge_;
+ IONotificationPortRef notification_port_ref_;
+ io_object_t notifier_object_;
#endif
DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
};
-} // namespace ui
+} // namespace base
-#endif // UI_BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
+#endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
diff --git a/base/system_monitor/system_monitor_mac.mm b/base/system_monitor/system_monitor_mac.mm
new file mode 100644
index 0000000..8611613
--- /dev/null
+++ b/base/system_monitor/system_monitor_mac.mm
@@ -0,0 +1,78 @@
+// 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.
+
+// Implementation based on sample code from
+// http://developer.apple.com/library/mac/#qa/qa1340/_index.html.
+
+#include "base/system_monitor/system_monitor.h"
+
+#include <IOKit/pwr_mgt/IOPMLib.h>
+#include <IOKit/IOMessage.h>
+
+namespace base {
+
+namespace {
+
+io_connect_t g_system_power_io_port = 0;
+
+void SystemPowerEventCallback(void* system_monitor,
+ io_service_t service,
+ natural_t message_type,
+ void* message_argument) {
+ DCHECK(system_monitor);
+ SystemMonitor* sys_monitor = reinterpret_cast<SystemMonitor*>(system_monitor);
+ switch (message_type) {
+ case kIOMessageSystemWillSleep:
+ sys_monitor->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT);
+ IOAllowPowerChange(g_system_power_io_port,
+ reinterpret_cast<int>(message_argument));
+ break;
+
+ case kIOMessageSystemWillPowerOn:
+ sys_monitor->ProcessPowerMessage(SystemMonitor::RESUME_EVENT);
+ break;
+ }
+}
+
+} // namespace
+
+void SystemMonitor::PlatformInit() {
+ DCHECK_EQ(g_system_power_io_port, 0u);
+
+ // Notification port allocated by IORegisterForSystemPower.
+
+ g_system_power_io_port = IORegisterForSystemPower(
+ this, &notification_port_ref_, SystemPowerEventCallback,
+ &notifier_object_);
+ DCHECK_NE(g_system_power_io_port, 0u);
+
+ // Add the notification port to the application runloop
+ CFRunLoopAddSource(CFRunLoopGetCurrent(),
+ IONotificationPortGetRunLoopSource(notification_port_ref_),
+ kCFRunLoopCommonModes);
+}
+
+void SystemMonitor::PlatformDestroy() {
+ DCHECK_NE(g_system_power_io_port, 0u);
+
+ // Remove the sleep notification port from the application runloop
+ CFRunLoopRemoveSource(
+ CFRunLoopGetCurrent(),
+ IONotificationPortGetRunLoopSource(notification_port_ref_),
+ kCFRunLoopCommonModes);
+
+ // Deregister for system sleep notifications
+ IODeregisterForSystemPower(&notifier_object_);
+
+ // IORegisterForSystemPower implicitly opens the Root Power Domain IOService,
+ // so we close it here.
+ IOServiceClose(g_system_power_io_port);
+
+ g_system_power_io_port = 0;
+
+ // Destroy the notification port allocated by IORegisterForSystemPower.
+ IONotificationPortDestroy(notification_port_ref_);
+}
+
+} // namespace base
diff --git a/ui/base/system_monitor/system_monitor_posix.cc b/base/system_monitor/system_monitor_posix.cc
index ddd0fe0..6cf01bf 100644
--- a/ui/base/system_monitor/system_monitor_posix.cc
+++ b/base/system_monitor/system_monitor_posix.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/system_monitor/system_monitor.h"
+#include "base/system_monitor/system_monitor.h"
-namespace ui {
+namespace base {
bool SystemMonitor::IsBatteryPower() {
NOTIMPLEMENTED();
return false;
}
-} // namespace ui
+} // namespace base
diff --git a/ui/base/system_monitor/system_monitor_unittest.cc b/base/system_monitor/system_monitor_unittest.cc
index 28b2cbf..9517247 100644
--- a/ui/base/system_monitor/system_monitor_unittest.cc
+++ b/base/system_monitor/system_monitor_unittest.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/system_monitor/system_monitor.h"
+#include "base/system_monitor/system_monitor.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace ui {
+namespace base {
class PowerTest : public SystemMonitor::PowerObserver {
public:
@@ -88,4 +88,4 @@ TEST(SystemMonitor, PowerNotifications) {
EXPECT_EQ(test[0].resumes(), 1);
}
-} // namespace ui
+} // namespace base
diff --git a/ui/base/system_monitor/system_monitor_win.cc b/base/system_monitor/system_monitor_win.cc
index df8aabf..84f2b2e 100644
--- a/ui/base/system_monitor/system_monitor_win.cc
+++ b/base/system_monitor/system_monitor_win.cc
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/system_monitor/system_monitor.h"
+#include "base/system_monitor/system_monitor.h"
-namespace ui {
+namespace base {
void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
PowerEvent power_event;
@@ -47,4 +47,4 @@ bool SystemMonitor::IsBatteryPower() {
return (status.ACLineStatus == 0);
}
-} // namespace ui
+} // namespace base
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 57d3618..6f2948e 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -24,6 +24,7 @@
#include "base/string_split.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
@@ -109,7 +110,6 @@
#include "net/url_request/url_request_throttler_manager.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/system_monitor/system_monitor.h"
#include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_switches.h"
@@ -527,7 +527,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 ui::SystemMonitor);
+ system_monitor_.reset(new base::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 a867e20..09153db 100644
--- a/chrome/browser/browser_main.h
+++ b/chrome/browser/browser_main.h
@@ -20,12 +20,12 @@ class MessageLoop;
class MetricsService;
class PrefService;
-namespace net {
-class NetworkChangeNotifier;
+namespace base {
+class SystemMonitor;
}
-namespace ui {
-class SystemMonitor;
+namespace net {
+class NetworkChangeNotifier;
}
// BrowserMainParts:
@@ -166,7 +166,7 @@ class BrowserMainParts {
// Members initialized in |MainMessageLoopStart()| ---------------------------
scoped_ptr<MessageLoop> main_message_loop_;
- scoped_ptr<ui::SystemMonitor> system_monitor_;
+ scoped_ptr<base::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/extensions/extension_event_router_forwarder_unittest.cc b/chrome/browser/extensions/extension_event_router_forwarder_unittest.cc
index 7d82ea5..ff5f5da 100644
--- a/chrome/browser/extensions/extension_event_router_forwarder_unittest.cc
+++ b/chrome/browser/extensions/extension_event_router_forwarder_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/extension_event_router_forwarder.h"
#include "base/message_loop.h"
+#include "base/system_monitor/system_monitor.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/testing_browser_process_test.h"
#include "chrome/test/testing_profile.h"
@@ -13,7 +14,6 @@
#include "googleurl/src/gurl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/system_monitor/system_monitor.h"
namespace {
@@ -66,7 +66,7 @@ class ExtensionEventRouterForwarderTest : public TestingBrowserProcessTest {
MessageLoopForUI message_loop_;
BrowserThread ui_thread_;
BrowserThread io_thread_;
- ui::SystemMonitor dummy;
+ base::SystemMonitor dummy;
// Profiles are weak pointers, owned by ProfileManager in |browser_process_|.
TestingProfile* profile1_;
TestingProfile* profile2_;
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index cee0265..dbd03de 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -111,7 +111,7 @@ Profile* ProfileManager::GetDefaultProfile() {
}
ProfileManager::ProfileManager() : logged_in_(false) {
- ui::SystemMonitor::Get()->AddObserver(this);
+ base::SystemMonitor::Get()->AddObserver(this);
BrowserList::AddObserver(this);
#if defined(OS_CHROMEOS)
registrar_.Add(
@@ -122,7 +122,7 @@ ProfileManager::ProfileManager() : logged_in_(false) {
}
ProfileManager::~ProfileManager() {
- ui::SystemMonitor* system_monitor = ui::SystemMonitor::Get();
+ base::SystemMonitor* system_monitor = base::SystemMonitor::Get();
if (system_monitor)
system_monitor->RemoveObserver(this);
BrowserList::RemoveObserver(this);
diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h
index 3c2c8e7..de656d6 100644
--- a/chrome/browser/profiles/profile_manager.h
+++ b/chrome/browser/profiles/profile_manager.h
@@ -17,12 +17,12 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/threading/non_thread_safe.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
-#include "ui/base/system_monitor/system_monitor.h"
class FilePath;
class NewProfileLauncher;
@@ -39,7 +39,7 @@ class ProfileManagerObserver {
};
class ProfileManager : public base::NonThreadSafe,
- public ui::SystemMonitor::PowerObserver,
+ public base::SystemMonitor::PowerObserver,
public BrowserList::Observer,
public NotificationObserver,
public Profile::Delegate {
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 541fd59..54bcbc9 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -8,6 +8,7 @@
#include "base/memory/scoped_temp_dir.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/values.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/profiles/profile.h"
@@ -22,7 +23,6 @@
#include "content/common/notification_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/system_monitor/system_monitor.h"
namespace {
// This global variable is used to check that value returned to different
@@ -61,7 +61,7 @@ class ProfileManagerTest : public TestingBrowserProcessTest {
BrowserThread ui_thread_;
BrowserThread file_thread_;
- ui::SystemMonitor system_monitor_dummy_;
+ base::SystemMonitor system_monitor_dummy_;
// Also will test profile deletion.
scoped_ptr<ProfileManager> profile_manager_;
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index fc1c941..3077f8c 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -13,6 +13,7 @@
#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "base/string_util.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_tab_helper.h"
@@ -37,7 +38,6 @@
#include "content/common/notification_source.h"
#include "content/common/property_bag.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/system_monitor/system_monitor.h"
using testing::_;
@@ -262,8 +262,8 @@ class TabStripModelTest : public RenderViewHostTestHarness {
std::wstring profile_path_;
std::map<TabContents*, int> foo_;
- // ProfileManager requires a ui::SystemMonitor.
- ui::SystemMonitor system_monitor;
+ // ProfileManager requires a base::SystemMonitor.
+ base::SystemMonitor system_monitor;
ProfileManager pm_;
};
diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc
index 51c57b8..f2e0cbf 100644
--- a/chrome/nacl/nacl_main.cc
+++ b/chrome/nacl/nacl_main.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/string_util.h"
+#include "base/system_monitor/system_monitor.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
@@ -21,7 +22,6 @@
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
#include "content/common/result_codes.h"
-#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_WIN)
#include "chrome/nacl/broker_thread.h"
@@ -37,7 +37,7 @@ int NaClBrokerMain(const MainFunctionParams& parameters) {
MessageLoopForIO main_message_loop;
base::PlatformThread::SetName("CrNaClBrokerMain");
- ui::SystemMonitor system_monitor;
+ base::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
const CommandLine& parsed_command_line = parameters.command_line_;
@@ -101,7 +101,7 @@ int NaClMain(const MainFunctionParams& parameters) {
MessageLoopForIO main_message_loop;
base::PlatformThread::SetName("CrNaClMain");
- ui::SystemMonitor system_monitor;
+ base::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
diff --git a/chrome/utility/utility_main.cc b/chrome/utility/utility_main.cc
index 9d4a63d..d4647f0 100644
--- a/chrome/utility/utility_main.cc
+++ b/chrome/utility/utility_main.cc
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/message_loop.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/threading/platform_thread.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_l10n_util.h"
@@ -11,7 +12,6 @@
#include "content/common/child_process.h"
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
-#include "ui/base/system_monitor/system_monitor.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_WIN)
@@ -28,7 +28,7 @@ int UtilityMain(const MainFunctionParams& parameters) {
MessageLoop main_message_loop;
base::PlatformThread::SetName("CrUtilityMain");
- ui::SystemMonitor system_monitor;
+ base::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
ChildProcess utility_process;
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index 08127b9..20e5dea 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -19,6 +19,7 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/win/scoped_comptr.h"
@@ -208,7 +209,7 @@ FakeExternalTab::~FakeExternalTab() {
void FakeExternalTab::Initialize() {
DCHECK(g_browser_process == NULL);
- ui::SystemMonitor system_monitor;
+ base::SystemMonitor system_monitor;
icu_util::Initialize();
diff --git a/content/common/hi_res_timer_manager.h b/content/common/hi_res_timer_manager.h
index af522cd..5c3ae38 100644
--- a/content/common/hi_res_timer_manager.h
+++ b/content/common/hi_res_timer_manager.h
@@ -6,16 +6,16 @@
#define CONTENT_COMMON_HI_RES_TIMER_MANAGER_H_
#pragma once
-#include "ui/base/system_monitor/system_monitor.h"
+#include "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 {
+class HighResolutionTimerManager : public base::SystemMonitor::PowerObserver {
public:
HighResolutionTimerManager();
virtual ~HighResolutionTimerManager();
- // ui::SystemMonitor::PowerObserver:
+ // base::SystemMonitor::PowerObserver:
virtual void OnPowerStateChange(bool on_battery_power);
// Returns true if the hi resolution clock could be used right now.
diff --git a/content/common/hi_res_timer_manager_win.cc b/content/common/hi_res_timer_manager_win.cc
index d41c4bd..45f22ba 100644
--- a/content/common/hi_res_timer_manager_win.cc
+++ b/content/common/hi_res_timer_manager_win.cc
@@ -8,13 +8,13 @@
HighResolutionTimerManager::HighResolutionTimerManager()
: hi_res_clock_available_(false) {
- ui::SystemMonitor* system_monitor = ui::SystemMonitor::Get();
+ base::SystemMonitor* system_monitor = base::SystemMonitor::Get();
system_monitor->AddObserver(this);
UseHiResClock(!system_monitor->BatteryPower());
}
HighResolutionTimerManager::~HighResolutionTimerManager() {
- ui::SystemMonitor::Get()->RemoveObserver(this);
+ base::SystemMonitor::Get()->RemoveObserver(this);
UseHiResClock(false);
}
diff --git a/content/plugin/plugin_main.cc b/content/plugin/plugin_main.cc
index fef3e95..2dea5e6 100644
--- a/content/plugin/plugin_main.cc
+++ b/content/plugin/plugin_main.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -12,13 +12,13 @@
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/string_util.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/threading/platform_thread.h"
#include "content/common/child_process.h"
#include "content/common/content_switches.h"
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
#include "content/plugin/plugin_thread.h"
-#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_WIN)
#include "content/common/injection_test_dll.h"
@@ -86,7 +86,7 @@ int PluginMain(const MainFunctionParams& parameters) {
MessageLoop main_message_loop(MessageLoop::TYPE_UI);
base::PlatformThread::SetName("CrPluginMain");
- ui::SystemMonitor system_monitor;
+ base::SystemMonitor system_monitor;
HighResolutionTimerManager high_resolution_timer_manager;
const CommandLine& parsed_command_line = parameters.command_line_;
diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc
index 36c73ba..2551e14 100644
--- a/content/renderer/renderer_main.cc
+++ b/content/renderer/renderer_main.cc
@@ -19,6 +19,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/string_util.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "content/common/content_counters.h"
@@ -29,7 +30,6 @@
#include "content/renderer/render_process_impl.h"
#include "content/renderer/render_thread.h"
#include "content/renderer/renderer_main_platform_delegate.h"
-#include "ui/base/system_monitor/system_monitor.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_MACOSX)
@@ -176,7 +176,7 @@ int RendererMain(const MainFunctionParams& parameters) {
base::PlatformThread::SetName("CrRendererMain");
- ui::SystemMonitor system_monitor;
+ base::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
platform.PlatformInitialize();
diff --git a/content/worker/worker_main.cc b/content/worker/worker_main.cc
index 6ec0263..88acc21 100644
--- a/content/worker/worker_main.cc
+++ b/content/worker/worker_main.cc
@@ -6,12 +6,12 @@
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/string_util.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/threading/platform_thread.h"
#include "content/common/child_process.h"
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
#include "content/worker/worker_thread.h"
-#include "ui/base/system_monitor/system_monitor.h"
#if defined(OS_WIN)
#include "content/common/sandbox_init_wrapper.h"
@@ -24,7 +24,7 @@ int WorkerMain(const MainFunctionParams& parameters) {
MessageLoop main_message_loop;
base::PlatformThread::SetName("CrWorkerMain");
- ui::SystemMonitor system_monitor;
+ base::SystemMonitor system_monitor;
HighResolutionTimerManager hi_res_timer_manager;
ChildProcess worker_process;
diff --git a/ui/base/system_monitor/system_monitor_mac.mm b/ui/base/system_monitor/system_monitor_mac.mm
deleted file mode 100644
index ffcb2a2..0000000
--- a/ui/base/system_monitor/system_monitor_mac.mm
+++ /dev/null
@@ -1,67 +0,0 @@
-// 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 "ui/base/system_monitor/system_monitor.h"
-
-#import <AppKit/AppKit.h>
-
-@interface SystemMonitorBridge : NSObject {
- @private
- ui::SystemMonitor* systemMonitor_; // weak
-}
-
-- (id)initWithSystemMonitor:(ui::SystemMonitor*)monitor;
-- (void)computerDidSleep:(NSNotification*)notification;
-- (void)computerDidWake:(NSNotification*)notification;
-
-@end
-
-@implementation SystemMonitorBridge
-
-- (id)initWithSystemMonitor:(ui::SystemMonitor*)monitor {
- self = [super init];
- if (self) {
- systemMonitor_ = monitor;
-
- // See QA1340
- // <http://developer.apple.com/library/mac/#qa/qa2004/qa1340.html> for more
- // details.
- [[[NSWorkspace sharedWorkspace] notificationCenter]
- addObserver:self
- selector:@selector(computerDidSleep:)
- name:NSWorkspaceWillSleepNotification
- object:nil];
- [[[NSWorkspace sharedWorkspace] notificationCenter]
- addObserver:self
- selector:@selector(computerDidWake:)
- name:NSWorkspaceDidWakeNotification
- object:nil];
- }
- return self;
-}
-
-- (void)dealloc {
- [[[NSWorkspace sharedWorkspace] notificationCenter]
- removeObserver:self];
- [super dealloc];
-}
-
-- (void)computerDidSleep:(NSNotification*)notification {
- systemMonitor_->ProcessPowerMessage(ui::SystemMonitor::SUSPEND_EVENT);
-}
-
-- (void)computerDidWake:(NSNotification*)notification {
- systemMonitor_->ProcessPowerMessage(ui::SystemMonitor::RESUME_EVENT);
-}
-
-@end
-
-void ui::SystemMonitor::PlatformInit() {
- system_monitor_bridge_ =
- [[SystemMonitorBridge alloc] initWithSystemMonitor:this];
-}
-
-void ui::SystemMonitor::PlatformDestroy() {
- [system_monitor_bridge_ release];
-}
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index 8a5ad92..4247547 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -5,7 +5,7 @@
#include "ui/views/widget/native_widget_win.h"
#include "base/memory/scoped_ptr.h"
-#include "ui/base/system_monitor/system_monitor.h"
+#include "base/system_monitor/system_monitor.h"
#include "ui/base/view_prop.h"
#include "ui/base/win/hwnd_util.h"
#include "ui/gfx/canvas_skia.h"
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 460fa5d..65e2e77 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -7,6 +7,7 @@
#include <dwmapi.h>
#include "base/string_util.h"
+#include "base/system_monitor/system_monitor.h"
#include "base/win/windows_version.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drag_source.h"
@@ -14,7 +15,6 @@
#include "ui/base/dragdrop/os_exchange_data_provider_win.h"
#include "ui/base/keycodes/keyboard_code_conversion_win.h"
#include "ui/base/l10n/l10n_util_win.h"
-#include "ui/base/system_monitor/system_monitor.h"
#include "ui/base/theme_provider.h"
#include "ui/base/view_prop.h"
#include "ui/base/win/hwnd_util.h"
@@ -859,7 +859,7 @@ void WidgetWin::OnPaint(HDC dc) {
}
LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) {
- ui::SystemMonitor* monitor = ui::SystemMonitor::Get();
+ base::SystemMonitor* monitor = base::SystemMonitor::Get();
if (monitor)
monitor->ProcessWmPowerBroadcastMessage(power_event);
SetMsgHandled(FALSE);