summaryrefslogtreecommitdiffstats
path: root/chrome/browser/power_save_blocker_win.cc
blob: f7d3d8ce33e98b87d61495768bd3bb5662d30a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright (c) 2009 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/browser/power_save_blocker.h"

#include <windows.h>

#include "chrome/browser/chrome_thread.h"

// Runs on UI thread only.
void PowerSaveBlocker::ApplyBlock(bool blocking) {
  DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));

  DWORD flags = ES_CONTINUOUS;

  if (blocking)
    flags |= ES_SYSTEM_REQUIRED;

  SetThreadExecutionState(flags);
}