Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3396)

Unified Diff: athena/resource_manager/memory_pressure_notifier.cc

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: athena/resource_manager/memory_pressure_notifier.cc
diff --git a/athena/resource_manager/memory_pressure_notifier.cc b/athena/resource_manager/memory_pressure_notifier.cc
deleted file mode 100644
index dff0f1d37c3300e2edcb196c015ed774fa47ac89..0000000000000000000000000000000000000000
--- a/athena/resource_manager/memory_pressure_notifier.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2014 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 "athena/resource_manager/memory_pressure_notifier.h"
-
-#include "athena/resource_manager/public/resource_manager_delegate.h"
-#include "base/time/time.h"
-
-
-namespace athena {
-
-MemoryPressureNotifier::MemoryPressureNotifier(
- MemoryPressureObserver* listener)
- : listener_(listener),
- current_pressure_(ResourceManager::MEMORY_PRESSURE_UNKNOWN) {
- StartObserving();
-}
-
-MemoryPressureNotifier::~MemoryPressureNotifier() {
- StopObserving();
-}
-
-void MemoryPressureNotifier::StartObserving() {
- int time_in_ms = listener_->GetDelegate()->MemoryPressureIntervalInMS();
- timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(time_in_ms),
- base::Bind(&MemoryPressureNotifier::CheckMemoryPressure,
- base::Unretained(this)));
-}
-
-void MemoryPressureNotifier::StopObserving() {
- // If StartObserving failed, StopObserving will still get called.
- timer_.Stop();
-}
-
-void MemoryPressureNotifier::CheckMemoryPressure() {
- ResourceManager::MemoryPressure pressure =
- GetMemoryPressureLevelFromFillLevel(
- listener_->GetDelegate()->GetUsedMemoryInPercent());
- if (current_pressure_ != pressure ||
- (pressure != ResourceManager::MEMORY_PRESSURE_LOW &&
- pressure != ResourceManager::MEMORY_PRESSURE_UNKNOWN)) {
- // If we are anything worse than |MEMORY_PRESSURE_LOW|, we notify the
- // listener.
- current_pressure_ = pressure;
- listener_->OnMemoryPressure(current_pressure_);
- }
-}
-
-ResourceManager::MemoryPressure
-MemoryPressureNotifier::GetMemoryPressureLevelFromFillLevel(
- int memory_fill_level) {
- if (memory_fill_level == 0)
- return ResourceManager::MEMORY_PRESSURE_UNKNOWN;
- if (memory_fill_level < 50)
- return ResourceManager::MEMORY_PRESSURE_LOW;
- if (memory_fill_level < 75)
- return ResourceManager::MEMORY_PRESSURE_MODERATE;
- if (memory_fill_level < 90)
- return ResourceManager::MEMORY_PRESSURE_HIGH;
- return ResourceManager::MEMORY_PRESSURE_CRITICAL;
-}
-
-} // namespace athena
« no previous file with comments | « athena/resource_manager/memory_pressure_notifier.h ('k') | athena/resource_manager/memory_pressure_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698