Commit 738aeed4 authored by bashi's avatar bashi Committed by Commit bot

HostDiscardableSharedMemoryManager should store the default memory limit

OnMemoryStateChange() callback is invoked on the UI thread but we can't
call GetDefaultMemoryLimit() from the UI thread. Store the default limit
on construction.

BUG=652557

Review-Url: https://codereview.chromium.org/2388403002
Cr-Commit-Position: refs/heads/master@{#422700}
parent 2d1f91c1
......@@ -164,7 +164,8 @@ HostDiscardableSharedMemoryManager::MemorySegment::~MemorySegment() {
}
HostDiscardableSharedMemoryManager::HostDiscardableSharedMemoryManager()
: memory_limit_(GetDefaultMemoryLimit()),
: default_memory_limit_(GetDefaultMemoryLimit()),
memory_limit_(default_memory_limit_),
bytes_allocated_(0),
memory_pressure_listener_(new base::MemoryPressureListener(
base::Bind(&HostDiscardableSharedMemoryManager::OnMemoryPressure,
......@@ -352,7 +353,7 @@ void HostDiscardableSharedMemoryManager::OnMemoryStateChange(
base::MemoryState state) {
switch (state) {
case base::MemoryState::NORMAL:
SetMemoryLimit(GetDefaultMemoryLimit());
SetMemoryLimit(default_memory_limit_);
break;
case base::MemoryState::THROTTLED:
SetMemoryLimit(0);
......
......@@ -136,6 +136,7 @@ class CONTENT_EXPORT HostDiscardableSharedMemoryManager
// a heap. The LRU memory segment always first.
typedef std::vector<scoped_refptr<MemorySegment>> MemorySegmentVector;
MemorySegmentVector segments_;
size_t default_memory_limit_;
size_t memory_limit_;
size_t bytes_allocated_;
std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
......
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