Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1752)

Unified Diff: app/system_monitor.h

Issue 6361002: Move SystemMonitor to src/chrome/common.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/hi_res_timer_manager_win.cc ('k') | app/system_monitor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/system_monitor.h
===================================================================
--- app/system_monitor.h (revision 71446)
+++ app/system_monitor.h (working copy)
@@ -1,139 +0,0 @@
-// Copyright (c) 2010 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 APP_SYSTEM_MONITOR_H_
-#define APP_SYSTEM_MONITOR_H_
-#pragma once
-
-#include "build/build_config.h"
-
-// Windows HiRes timers drain the battery faster so we need to know the battery
-// status. This isn't true for other platforms.
-#if defined(OS_WIN)
-#define ENABLE_BATTERY_MONITORING 1
-#else
-#undef ENABLE_BATTERY_MONITORING
-#endif // !OS_WIN
-
-#include "base/observer_list_threadsafe.h"
-#if defined(ENABLE_BATTERY_MONITORING)
-#include "base/timer.h"
-#endif // defined(ENABLE_BATTERY_MONITORING)
-
-#if defined(OS_MACOSX)
-#ifdef __OBJC__
-@class SystemMonitorBridge;
-#else
-class SystemMonitorBridge;
-#endif
-#endif
-
-// Class for monitoring various system-related subsystems
-// such as power management, network status, etc.
-// TODO(mbelshe): Add support beyond just power management.
-class SystemMonitor {
- public:
- // Normalized list of power events.
- enum PowerEvent {
- POWER_STATE_EVENT, // The Power status of the system has changed.
- SUSPEND_EVENT, // The system is being suspended.
- RESUME_EVENT // The system is being resumed.
- };
-
- // Create SystemMonitor. Only one SystemMonitor instance per application
- // is allowed.
- SystemMonitor();
- ~SystemMonitor();
-
- // Get the application-wide SystemMonitor (if not present, returns NULL).
- static SystemMonitor* Get();
-
- //
- // Power-related APIs
- //
-
- // Is the computer currently on battery power.
- // Can be called on any thread.
- bool BatteryPower() const {
- // Using a lock here is not necessary for just a bool.
- return battery_in_use_;
- }
-
- // Callbacks will be called on the thread which creates the SystemMonitor.
- // During the callback, Add/RemoveObserver will block until the callbacks
- // are finished. Observers should implement quick callback functions; if
- // lengthy operations are needed, the observer should take care to invoke
- // the operation on an appropriate thread.
- class PowerObserver {
- public:
- // Notification of a change in power status of the computer, such
- // as from switching between battery and A/C power.
- virtual void OnPowerStateChange(bool on_battery_power) {}
-
- // Notification that the system is suspending.
- virtual void OnSuspend() {}
-
- // Notification that the system is resuming.
- virtual void OnResume() {}
-
- protected:
- virtual ~PowerObserver() {}
- };
-
- // Add a new observer.
- // Can be called from any thread.
- // Must not be called from within a notification callback.
- void AddObserver(PowerObserver* obs);
-
- // Remove an existing observer.
- // Can be called from any thread.
- // Must not be called from within a notification callback.
- void RemoveObserver(PowerObserver* obs);
-
-#if defined(OS_WIN)
- // Windows-specific handling of a WM_POWERBROADCAST message.
- // Embedders of this API should hook their top-level window
- // message loop and forward WM_POWERBROADCAST through this call.
- void ProcessWmPowerBroadcastMessage(int event_id);
-#endif
-
- // Cross-platform handling of a power event.
- void ProcessPowerMessage(PowerEvent event_id);
-
- private:
-#if defined(OS_MACOSX)
- void PlatformInit();
- void PlatformDestroy();
-#endif
-
- // Platform-specific method to check whether the system is currently
- // running on battery power. Returns true if running on batteries,
- // false otherwise.
- bool IsBatteryPower();
-
- // Checks the battery status and notifies observers if the battery
- // status has changed.
- void BatteryCheck();
-
- // Functions to trigger notifications.
- void NotifyPowerStateChange();
- void NotifySuspend();
- void NotifyResume();
-
- scoped_refptr<ObserverListThreadSafe<PowerObserver> > observer_list_;
- bool battery_in_use_;
- bool suspended_;
-
-#if defined(ENABLE_BATTERY_MONITORING)
- base::OneShotTimer<SystemMonitor> delayed_battery_check_;
-#endif
-
-#if defined(OS_MACOSX)
- SystemMonitorBridge* system_monitor_bridge_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
-};
-
-#endif // APP_SYSTEM_MONITOR_H_
« no previous file with comments | « app/hi_res_timer_manager_win.cc ('k') | app/system_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698