Skip to content

Commit

Permalink
[Memory] Remove LowMemoryPressure and flags to disable memory discard…
Browse files Browse the repository at this point in the history
…ing.

Since LowMemoryPressure is not being anymore, this removes it, which reduces the Chromeos-specific code.

Note: This is the second step of expanding Chromeos tab killing to other platforms.

BUG=463597

Review URL: https://codereview.chromium.org/1201453002

Cr-Commit-Position: refs/heads/master@{#335602}
  • Loading branch information
georgesak authored and Commit bot committed Jun 23, 2015
1 parent 5abd2d6 commit 2a9c37c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 300 deletions.
6 changes: 0 additions & 6 deletions chrome/app/chromeos_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,12 +1214,6 @@ Press any key to continue exploring.
<message name="IDS_FLAGS_DISABLE_DISPLAY_COLOR_CALIBRATION_DESCRIPTION" desc="Description for the flag to disable the color calibration of the display.">
Disable calibrating the color of the display even if the display supports the feature.
</message>
<message name="IDS_FLAGS_DISABLE_MEMORY_PRESSURE_NAME" desc="Name for the flag to disable memory pressure handling on ChromeOS.">
Disable memory pressure handling
</message>
<message name="IDS_FLAGS_DISABLE_MEMORY_PRESSURE_DESCRIPTION" desc="Description for the flag to disable memory pressure handling on ChromeOS.">
Disable enhanced memory pressure handling on ChromeOS.
</message>
<message name="IDS_FLAGS_MEMORY_PRESSURE_THRESHOLD_NAME" desc="Name for the flag which specifies which memory pressure strategy should be used on ChromeOS.">
Memory discard strategy for advanced pressure handling
</message>
Expand Down
6 changes: 0 additions & 6 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1706,12 +1706,6 @@ const Experiment kExperiments[] = {
SINGLE_VALUE_TYPE(switches::kEnableMaterialDesignSettings)},
#endif
#if defined(OS_CHROMEOS)
{"disable-memory-pressure-chromeos",
IDS_FLAGS_DISABLE_MEMORY_PRESSURE_NAME,
IDS_FLAGS_DISABLE_MEMORY_PRESSURE_DESCRIPTION,
kOsCrOS,
SINGLE_VALUE_TYPE(
chromeos::switches::kDisableMemoryPressureSystemChromeOS)},
{"memory-pressure-thresholds",
IDS_FLAGS_MEMORY_PRESSURE_THRESHOLD_NAME,
IDS_FLAGS_MEMORY_PRESSURE_THRESHOLD_DESCRIPTION,
Expand Down
189 changes: 0 additions & 189 deletions chrome/browser/memory/low_memory_observer_chromeos.cc

This file was deleted.

41 changes: 0 additions & 41 deletions chrome/browser/memory/low_memory_observer_chromeos.h

This file was deleted.

8 changes: 0 additions & 8 deletions chrome/browser/memory/oom_priority_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class GURL;

namespace memory {

class LowMemoryObserver;

// The OomPriorityManager periodically checks (see
// ADJUSTMENT_INTERVAL_SECONDS in the source) the status of renderers
// and adjusts the out of memory (OOM) adjustment value (in
Expand Down Expand Up @@ -160,12 +158,6 @@ class OomPriorityManager : public content::NotificationObserver {
// Holds the focused tab's child process host id.
ProcessInfo focused_tab_process_info_;

// The old observer for the kernel low memory signal. This is null if
// the new MemoryPressureListener is used.
// TODO(skuhne): Remove this when the enhanced memory observer is turned on
// by default.
scoped_ptr<LowMemoryObserver> low_memory_observer_;

// A listener to global memory pressure events. This will be used if the
// memory pressure system was instantiated - otherwise the LowMemoryObserver
// will be used.
Expand Down
63 changes: 23 additions & 40 deletions chrome/browser/memory/oom_priority_manager_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chrome/browser/memory/low_memory_observer_chromeos.h"
#include "chrome/browser/memory/oom_memory_details.h"
#include "chrome/browser/memory/system_memory_stats_recorder.h"
#include "chrome/browser/ui/browser.h"
Expand Down Expand Up @@ -104,10 +103,6 @@ OomPriorityManager::OomPriorityManager()
: focused_tab_process_info_(std::make_pair(0, 0)),
discard_count_(0),
recent_tab_discard_(false) {
// Use the old |LowMemoryObserver| when there is no |MemoryPressureMonitor|.
if (!base::MemoryPressureMonitor::Get())
low_memory_observer_.reset(new LowMemoryObserver);

registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
Expand All @@ -131,33 +126,23 @@ void OomPriorityManager::Start() {
this, &OomPriorityManager::RecordRecentTabDiscard);
}
start_time_ = TimeTicks::Now();
// If a |LowMemoryObserver| exists we use the old system, otherwise we create
// a |MemoryPressureListener| to listen for memory events.
if (low_memory_observer_) {
low_memory_observer_->Start();
} else {
base::MemoryPressureMonitor* monitor = base::MemoryPressureMonitor::Get();
if (monitor) {
memory_pressure_listener_.reset(
new base::MemoryPressureListener(base::Bind(
&OomPriorityManager::OnMemoryPressure, base::Unretained(this))));
base::MemoryPressureListener::MemoryPressureLevel level =
monitor->GetCurrentPressureLevel();
if (level ==
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
OnMemoryPressure(level);
}
// Create a |MemoryPressureListener| to listen for memory events.
base::MemoryPressureMonitor* monitor = base::MemoryPressureMonitor::Get();
if (monitor) {
memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind(
&OomPriorityManager::OnMemoryPressure, base::Unretained(this))));
base::MemoryPressureListener::MemoryPressureLevel level =
monitor->GetCurrentPressureLevel();
if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
OnMemoryPressure(level);
}
}
}

void OomPriorityManager::Stop() {
timer_.Stop();
recent_tab_discard_timer_.Stop();
if (low_memory_observer_)
low_memory_observer_->Stop();
else
memory_pressure_listener_.reset();
memory_pressure_listener_.reset();
}

std::vector<base::string16> OomPriorityManager::GetTabTitles() {
Expand Down Expand Up @@ -407,21 +392,19 @@ void OomPriorityManager::Observe(int type,
content::RenderProcessHost* host =
content::Source<content::RenderProcessHost>(source).ptr();
oom_score_map_.erase(host->GetID());
if (!low_memory_observer_) {
// Coming here we know that a renderer was just killed and memory should
// come back into the pool. However - the memory pressure observer did
// not yet update its status and therefore we ask it to redo the
// measurement, calling us again if we have to release more.
// Note: We do not only accelerate the discarding speed by doing another
// check in short succession - we also accelerate it because the timer
// driven MemoryPressureMonitor will continue to produce timed events
// on top. So the longer the cleanup phase takes, the more tabs will
// get discarded in parallel.
base::chromeos::MemoryPressureMonitor* monitor =
base::chromeos::MemoryPressureMonitor::Get();
if (monitor)
monitor->ScheduleEarlyCheck();
}
// Coming here we know that a renderer was just killed and memory should
// come back into the pool. However - the memory pressure observer did
// not yet update its status and therefore we ask it to redo the
// measurement, calling us again if we have to release more.
// Note: We do not only accelerate the discarding speed by doing another
// check in short succession - we also accelerate it because the timer
// driven MemoryPressureMonitor will continue to produce timed events
// on top. So the longer the cleanup phase takes, the more tabs will
// get discarded in parallel.
base::chromeos::MemoryPressureMonitor* monitor =
base::chromeos::MemoryPressureMonitor::Get();
if (monitor)
monitor->ScheduleEarlyCheck();
break;
}
case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: {
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,6 @@
'browser/memory_details_linux.cc',
'browser/memory_details_mac.cc',
'browser/memory_details_win.cc',
'browser/memory/low_memory_observer_chromeos.cc',
'browser/memory/low_memory_observer_chromeos.h',
'browser/memory/oom_memory_details_chromeos.cc',
'browser/memory/oom_memory_details.h',
'browser/memory/oom_priority_manager_chromeos.cc',
Expand Down
Loading

0 comments on commit 2a9c37c

Please sign in to comment.