#include "services/device/battery/battery_status_manager_linux.h"
#include <stddef.h>
#include <stdint.h>
#include <limits>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/message_loop/message_pump_type.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "base/values.h"
#include "base/version.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "dbus/property.h"
#include "dbus/values_util.h"
#include "services/device/battery/battery_status_manager_linux-inl.h"
namespace device {
namespace {
const char kBatteryNotifierThreadName[] = …;
class UPowerProperties : public dbus::PropertySet { … };
UPowerProperties::UPowerProperties(dbus::ObjectProxy* object_proxy,
const PropertyChangedCallback callback)
: … { … }
UPowerProperties::~UPowerProperties() { … }
base::Version UPowerProperties::daemon_version() { … }
class UPowerObject { … };
UPowerObject::UPowerObject(
dbus::Bus* dbus,
const PropertyChangedCallback property_changed_callback)
: … { … }
UPowerObject::~UPowerObject() { … }
std::vector<dbus::ObjectPath> UPowerObject::EnumerateDevices() { … }
dbus::ObjectPath UPowerObject::GetDisplayDevice() { … }
class BatteryProperties : public dbus::PropertySet { … };
BatteryProperties::BatteryProperties(dbus::ObjectProxy* object_proxy,
const PropertyChangedCallback callback)
: … { … }
BatteryProperties::~BatteryProperties() { … }
void BatteryProperties::ConnectSignals() { … }
void BatteryProperties::Invalidate() { … }
bool BatteryProperties::is_present(bool default_value) { … }
double BatteryProperties::percentage(double default_value) { … }
uint32_t BatteryProperties::state(uint32_t default_value) { … }
int64_t BatteryProperties::time_to_empty(int64_t default_value) { … }
int64_t BatteryProperties::time_to_full(int64_t default_value) { … }
uint32_t BatteryProperties::type(uint32_t default_value) { … }
class BatteryObject { … };
BatteryObject::BatteryObject(
dbus::Bus* dbus,
const dbus::ObjectPath& device_path,
const PropertyChangedCallback& property_changed_callback)
: … { … }
BatteryObject::~BatteryObject() { … }
bool BatteryObject::IsValid() const { … }
mojom::BatteryStatus ComputeWebBatteryStatus(BatteryProperties* properties) { … }
}
class BatteryStatusManagerLinux::BatteryStatusNotificationThread
: public base::Thread { … };
BatteryStatusManagerLinux::BatteryStatusManagerLinux(
const BatteryStatusService::BatteryUpdateCallback& callback)
: … { … }
BatteryStatusManagerLinux::~BatteryStatusManagerLinux() { … }
bool BatteryStatusManagerLinux::StartListeningBatteryChange() { … }
void BatteryStatusManagerLinux::StopListeningBatteryChange() { … }
bool BatteryStatusManagerLinux::StartNotifierThreadIfNecessary() { … }
base::Thread* BatteryStatusManagerLinux::GetNotifierThreadForTesting() { … }
std::unique_ptr<BatteryStatusManagerLinux>
BatteryStatusManagerLinux::CreateForTesting(
const BatteryStatusService::BatteryUpdateCallback& callback,
dbus::Bus* bus) { … }
std::unique_ptr<BatteryStatusManager> BatteryStatusManager::Create(
const BatteryStatusService::BatteryUpdateCallback& callback) { … }
}