#include "chrome/browser/dbus_memory_pressure_evaluator_linux.h"
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/scoped_refptr.h"
#include "chrome/common/chrome_features.h"
#include "components/dbus/thread_linux/dbus_thread_linux.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
namespace {
scoped_refptr<dbus::Bus> CreateBusOfType(dbus::Bus::BusType type) { … }
}
const char DbusMemoryPressureEvaluatorLinux::kMethodNameHasOwner[] = …;
const char DbusMemoryPressureEvaluatorLinux::kMethodListActivatableNames[] = …;
const char DbusMemoryPressureEvaluatorLinux::kLmmService[] = …;
const char DbusMemoryPressureEvaluatorLinux::kLmmObject[] = …;
const char DbusMemoryPressureEvaluatorLinux::kLmmInterface[] = …;
const char DbusMemoryPressureEvaluatorLinux::kXdgPortalService[] = …;
const char DbusMemoryPressureEvaluatorLinux::kXdgPortalObject[] = …;
const char
DbusMemoryPressureEvaluatorLinux::kXdgPortalMemoryMonitorInterface[] = …;
const char DbusMemoryPressureEvaluatorLinux::kLowMemoryWarningSignal[] = …;
const base::TimeDelta DbusMemoryPressureEvaluatorLinux::kResetVotePeriod = …;
DbusMemoryPressureEvaluatorLinux::DbusMemoryPressureEvaluatorLinux(
std::unique_ptr<memory_pressure::MemoryPressureVoter> voter)
: … { … }
DbusMemoryPressureEvaluatorLinux::DbusMemoryPressureEvaluatorLinux(
std::unique_ptr<memory_pressure::MemoryPressureVoter> voter,
scoped_refptr<dbus::Bus> system_bus,
scoped_refptr<dbus::Bus> session_bus)
: … { … }
DbusMemoryPressureEvaluatorLinux::~DbusMemoryPressureEvaluatorLinux() { … }
void DbusMemoryPressureEvaluatorLinux::CheckIfLmmIsAvailable() { … }
void DbusMemoryPressureEvaluatorLinux::CheckIfLmmIsAvailableResponse(
bool is_available) { … }
void DbusMemoryPressureEvaluatorLinux::CheckIfPortalIsAvailable() { … }
void DbusMemoryPressureEvaluatorLinux::CheckIfPortalIsAvailableResponse(
bool is_available) { … }
void DbusMemoryPressureEvaluatorLinux::CheckIfServiceIsAvailable(
scoped_refptr<dbus::Bus> bus,
const std::string& service,
base::OnceCallback<void(bool)> callback) { … }
void DbusMemoryPressureEvaluatorLinux::OnNameHasOwnerResponse(
scoped_refptr<dbus::Bus> bus,
const std::string& service,
base::OnceCallback<void(bool)> callback,
dbus::Response* response) { … }
void DbusMemoryPressureEvaluatorLinux::OnListActivatableNamesResponse(
const std::string& service,
base::OnceCallback<void(bool)> callback,
dbus::Response* response) { … }
void DbusMemoryPressureEvaluatorLinux::ResetBus(scoped_refptr<dbus::Bus>& bus) { … }
void DbusMemoryPressureEvaluatorLinux::OnSignalConnected(
const std::string& interface,
const std::string& signal,
bool connected) { … }
void DbusMemoryPressureEvaluatorLinux::OnLowMemoryWarning(
dbus::Signal* signal) { … }
base::MemoryPressureListener::MemoryPressureLevel
DbusMemoryPressureEvaluatorLinux::LmmToBasePressureLevel(uint8_t lmm_level) { … }
void DbusMemoryPressureEvaluatorLinux::UpdateLevel(
base::MemoryPressureListener::MemoryPressureLevel new_level) { … }