electron/atom/browser/api/atom_api_power_save_blocker.h

58 lines
1.6 KiB
C
Raw Normal View History

2015-06-21 12:57:42 +00:00
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_POWER_SAVE_BLOCKER_H_
#define ATOM_BROWSER_API_ATOM_API_POWER_SAVE_BLOCKER_H_
2015-06-22 02:23:58 +00:00
#include <map>
2016-07-04 06:08:55 +00:00
#include <memory>
2015-06-22 02:23:58 +00:00
#include "atom/browser/api/trackable_object.h"
2016-09-06 08:24:37 +00:00
#include "device/power_save_blocker/power_save_blocker.h"
2015-06-21 12:57:42 +00:00
#include "native_mate/handle.h"
namespace mate {
class Dictionary;
}
namespace atom {
namespace api {
class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
2015-06-21 12:57:42 +00:00
public:
static mate::Handle<PowerSaveBlocker> Create(v8::Isolate* isolate);
2016-04-25 01:17:54 +00:00
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
2016-04-25 01:17:54 +00:00
2015-06-21 12:57:42 +00:00
protected:
2016-04-25 01:17:54 +00:00
explicit PowerSaveBlocker(v8::Isolate* isolate);
~PowerSaveBlocker() override;
2015-06-21 12:57:42 +00:00
private:
2015-06-22 02:23:58 +00:00
void UpdatePowerSaveBlocker();
2016-09-06 08:24:37 +00:00
int Start(device::PowerSaveBlocker::PowerSaveBlockerType type);
2015-06-22 02:23:58 +00:00
bool Stop(int id);
bool IsStarted(int id);
2015-06-21 12:57:42 +00:00
2016-09-06 08:24:37 +00:00
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
2015-06-22 02:23:58 +00:00
// Currnet blocker type used by |power_save_blocker_|
2016-09-06 08:24:37 +00:00
device::PowerSaveBlocker::PowerSaveBlockerType current_blocker_type_;
2015-06-22 02:23:58 +00:00
// Map from id to the corresponding blocker type for each request.
using PowerSaveBlockerTypeMap =
2016-09-06 08:24:37 +00:00
std::map<int, device::PowerSaveBlocker::PowerSaveBlockerType>;
2015-06-22 02:23:58 +00:00
PowerSaveBlockerTypeMap power_save_blocker_types_;
2015-06-21 12:57:42 +00:00
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_POWER_SAVE_BLOCKER_H_