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.

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

mercurial