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

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

Issue 2394113003: Increase max saved frames on high-end Android devices (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 RendererFrameManager::RendererFrameManager() 98 RendererFrameManager::RendererFrameManager()
99 : memory_pressure_listener_( 99 : memory_pressure_listener_(
100 base::Bind(&RendererFrameManager::OnMemoryPressure, 100 base::Bind(&RendererFrameManager::OnMemoryPressure,
101 base::Unretained(this))) { 101 base::Unretained(this))) {
102 // Note: With the destruction of this class the |memory_pressure_listener_| 102 // Note: With the destruction of this class the |memory_pressure_listener_|
103 // gets destroyed and the observer will remove itself. 103 // gets destroyed and the observer will remove itself.
104 max_number_of_saved_frames_ = 104 max_number_of_saved_frames_ =
105 #if defined(OS_ANDROID) 105 #if defined(OS_ANDROID)
106 1; 106 // If the amount of memory on the device is >= 3.5 GB, save up to 5
107 // frames.
108 base::SysInfo::AmountOfPhysicalMemoryMB() < 1024 * 3.5f ? 1 : 5;
107 #else 109 #else
108 std::min(5, 2 + (base::SysInfo::AmountOfPhysicalMemoryMB() / 256)); 110 std::min(5, 2 + (base::SysInfo::AmountOfPhysicalMemoryMB() / 256));
109 #endif 111 #endif
110 max_handles_ = base::SharedMemory::GetHandleLimit() / 8.0f; 112 max_handles_ = base::SharedMemory::GetHandleLimit() / 8.0f;
111 } 113 }
112 114
113 RendererFrameManager::~RendererFrameManager() {} 115 RendererFrameManager::~RendererFrameManager() {}
114 116
115 void RendererFrameManager::CullUnlockedFrames(size_t saved_frame_limit) { 117 void RendererFrameManager::CullUnlockedFrames(size_t saved_frame_limit) {
116 if (unlocked_frames_.size() + locked_frames_.size() > 0) { 118 if (unlocked_frames_.size() + locked_frames_.size() > 0) {
(...skipping 29 matching lines...) Expand all
146 percentage = kCriticalPressurePercentage; 148 percentage = kCriticalPressurePercentage;
147 break; 149 break;
148 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: 150 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE:
149 // No need to change anything when there is no pressure. 151 // No need to change anything when there is no pressure.
150 return; 152 return;
151 } 153 }
152 CullUnlockedFrames(std::max(1, (saved_frame_limit * percentage) / 100)); 154 CullUnlockedFrames(std::max(1, (saved_frame_limit * percentage) / 100));
153 } 155 }
154 156
155 } // namespace content 157 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698