Commit 0599ca5e authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Win OS Memory Pressure signals: address some comments from previous CL.

Change-Id: I6625de68dcac33fd74f768d7fa7c60b899e2f200
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354527
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: default avatarRafael Cintron <rafael.cintron@microsoft.com>
Auto-Submit: Sébastien Marchand <sebmarchand@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797936}
parent cb64c418
......@@ -54,22 +54,18 @@ MemoryPressureWatcherDelegate::MemoryPressureWatcherDelegate(
CHECK(watcher_.StartWatchingOnce(handle_.Get(), this));
}
MemoryPressureWatcherDelegate::~MemoryPressureWatcherDelegate() {
if (watcher_.IsWatching())
watcher_.StopWatching();
handle_.Close();
}
MemoryPressureWatcherDelegate::~MemoryPressureWatcherDelegate() = default;
void MemoryPressureWatcherDelegate::ReplaceWatchedHandleForTesting(
base::win::ScopedHandle handle) {
if (watcher_.IsWatching())
watcher_.StopWatching();
handle_.Close();
handle_ = std::move(handle);
CHECK(watcher_.StartWatchingOnce(handle_.Get(), this));
}
void MemoryPressureWatcherDelegate::OnObjectSignaled(HANDLE object) {
void MemoryPressureWatcherDelegate::OnObjectSignaled(HANDLE handle) {
DCHECK_EQ(handle, handle_.Get());
std::move(callback_).Run();
}
......@@ -79,7 +75,8 @@ void MemoryPressureWatcherDelegate::OnObjectSignaled(HANDLE object) {
// memory pressure monitor. The values were determined experimentally to ensure
// sufficient responsiveness of the memory pressure subsystem, and minimal
// overhead.
const int SystemMemoryPressureEvaluator::kModeratePressureCooldownMs = 10000;
const base::TimeDelta SystemMemoryPressureEvaluator::kModeratePressureCooldown =
base::TimeDelta::FromSeconds(10);
// TODO(chrisha): Explore the following constants further with an experiment.
......@@ -269,9 +266,8 @@ void SystemMemoryPressureEvaluator::CheckMemoryPressure() {
// Already in moderate pressure, only notify if sustained over the
// cooldown period.
const int kModeratePressureCooldownCycles =
kModeratePressureCooldownMs /
base::MemoryPressureMonitor::kUMAMemoryPressureLevelPeriod
.InMilliseconds();
kModeratePressureCooldown /
base::MemoryPressureMonitor::kUMAMemoryPressureLevelPeriod;
if (++moderate_pressure_repeat_count_ ==
kModeratePressureCooldownCycles) {
moderate_pressure_repeat_count_ = 0;
......
......@@ -33,7 +33,7 @@ class SystemMemoryPressureEvaluator
// Constants governing the polling and hysteresis behaviour of the observer.
// The time which should pass between 2 successive moderate memory pressure
// signals, in milliseconds.
static const int kModeratePressureCooldownMs;
static const base::TimeDelta kModeratePressureCooldown;
// Constants governing the memory pressure level detection.
......
......@@ -241,9 +241,8 @@ TEST_F(WinSystemMemoryPressureEvaluatorTest, CheckMemoryPressure) {
// Check that the event gets reposted after a while.
const int kModeratePressureCooldownCycles =
evaluator.kModeratePressureCooldownMs /
base::MemoryPressureMonitor::kUMAMemoryPressureLevelPeriod
.InMilliseconds();
evaluator.kModeratePressureCooldown /
base::MemoryPressureMonitor::kUMAMemoryPressureLevelPeriod;
for (int i = 0; i < kModeratePressureCooldownCycles; ++i) {
if (i + 1 == kModeratePressureCooldownCycles) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment