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

Side by Side Diff: content/browser/renderer_host/renderer_frame_manager.cc

Issue 2648323005: memory coordinator: Add MemoryCoordinatorClient::OnPurgeMemory() (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/renderer_frame_manager.h" 5 #include "content/browser/renderer_host/renderer_frame_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 break; 160 break;
161 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: 161 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
162 PurgeMemory(kCriticalPressurePercentage); 162 PurgeMemory(kCriticalPressurePercentage);
163 break; 163 break;
164 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: 164 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE:
165 // No need to change anything when there is no pressure. 165 // No need to change anything when there is no pressure.
166 return; 166 return;
167 } 167 }
168 } 168 }
169 169
170 void RendererFrameManager::OnMemoryStateChange(base::MemoryState state) { 170 void RendererFrameManager::OnPurgeMemory() {
171 switch (state) { 171 PurgeMemory(kCriticalPressurePercentage);
172 case base::MemoryState::NORMAL:
173 // It is not necessary to purge here.
174 break;
175 case base::MemoryState::THROTTLED:
176 PurgeMemory(kCriticalPressurePercentage);
177 break;
178 case base::MemoryState::SUSPENDED:
179 // Note that SUSPENDED never occurs in the main browser process so far.
180 // Fall through.
181 case base::MemoryState::UNKNOWN:
182 NOTREACHED();
183 break;
184 }
185 } 172 }
186 173
187 void RendererFrameManager::PurgeMemory(int percentage) { 174 void RendererFrameManager::PurgeMemory(int percentage) {
188 int saved_frame_limit = max_number_of_saved_frames_; 175 int saved_frame_limit = max_number_of_saved_frames_;
189 if (saved_frame_limit <= 1) 176 if (saved_frame_limit <= 1)
190 return; 177 return;
191 CullUnlockedFrames(std::max(1, (saved_frame_limit * percentage) / 100)); 178 CullUnlockedFrames(std::max(1, (saved_frame_limit * percentage) / 100));
192 } 179 }
193 180
194 } // namespace content 181 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698