ipc/chromium/src/base/system_monitor_win.cc

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #include "base/system_monitor.h"
michael@0 6
michael@0 7 namespace base {
michael@0 8
michael@0 9 void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
michael@0 10 PowerEvent power_event;
michael@0 11 switch (event_id) {
michael@0 12 case PBT_APMPOWERSTATUSCHANGE: // The power status changed.
michael@0 13 power_event = POWER_STATE_EVENT;
michael@0 14 break;
michael@0 15 case PBT_APMRESUMEAUTOMATIC: // Non-user initiated resume from suspend.
michael@0 16 case PBT_APMRESUMESUSPEND: // User initiated resume from suspend.
michael@0 17 power_event = RESUME_EVENT;
michael@0 18 break;
michael@0 19 case PBT_APMSUSPEND: // System has been suspended.
michael@0 20 power_event = SUSPEND_EVENT;
michael@0 21 break;
michael@0 22 default:
michael@0 23 return;
michael@0 24
michael@0 25 // Other Power Events:
michael@0 26 // PBT_APMBATTERYLOW - removed in Vista.
michael@0 27 // PBT_APMOEMEVENT - removed in Vista.
michael@0 28 // PBT_APMQUERYSUSPEND - removed in Vista.
michael@0 29 // PBT_APMQUERYSUSPENDFAILED - removed in Vista.
michael@0 30 // PBT_APMRESUMECRITICAL - removed in Vista.
michael@0 31 // PBT_POWERSETTINGCHANGE - user changed the power settings.
michael@0 32 }
michael@0 33 ProcessPowerMessage(power_event);
michael@0 34 }
michael@0 35
michael@0 36 // Function to query the system to see if it is currently running on
michael@0 37 // battery power. Returns true if running on battery.
michael@0 38 bool SystemMonitor::IsBatteryPower() {
michael@0 39 SYSTEM_POWER_STATUS status;
michael@0 40 if (!GetSystemPowerStatus(&status)) {
michael@0 41 CHROMIUM_LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
michael@0 42 return false;
michael@0 43 }
michael@0 44 return (status.ACLineStatus == 0);
michael@0 45 }
michael@0 46
michael@0 47
michael@0 48
michael@0 49 } // namespace base

mercurial