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

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

Issue 43193002: Aura/ÜC: Drop frames on background tabs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test, properly extract RendererFrameManager Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/renderer_frame_manager.h"
6
7 #include "base/logging.h"
8 #include "base/sys_info.h"
9
10 namespace content {
11
12 ////////////////////////////////////////////////////////////////////////////////
danakj 2013/10/28 21:39:21 What's up with these comment things? Is this a c/b
piman 2013/10/28 22:08:38 Not particularly, but I removed from here where it
13 // RendererFrameManager
14
15 RendererFrameManager* RendererFrameManager::GetInstance() {
16 return Singleton<RendererFrameManager>::get();
17 }
18
19 void RendererFrameManager::AddFrame(RendererFrameManagerClient* frame,
20 bool visible) {
21 RemoveFrame(frame);
22 if (visible)
23 visible_frames_.insert(frame);
24 else
25 hidden_frames_.push_front(frame);
26 CullHiddenFrames();
27 }
28
29 void RendererFrameManager::RemoveFrame(RendererFrameManagerClient* frame) {
30 visible_frames_.erase(frame);
31 hidden_frames_.remove(frame);
32 }
33
34 void RendererFrameManager::SetFrameVisibility(RendererFrameManagerClient* frame,
35 bool visible) {
36 if (visible) {
37 hidden_frames_.remove(frame);
38 visible_frames_.insert(frame);
39 } else {
40 visible_frames_.erase(frame);
41 hidden_frames_.push_front(frame);
42 CullHiddenFrames();
43 }
44 }
45
46 RendererFrameManager::RendererFrameManager()
47 : max_number_of_saved_frames_(
48 std::min(5, 2 + (base::SysInfo::AmountOfPhysicalMemoryMB() / 256))) {}
49
50 RendererFrameManager::~RendererFrameManager() {}
51
52 void RendererFrameManager::CullHiddenFrames() {
53 while (!hidden_frames_.empty() &&
54 hidden_frames_.size() + visible_frames_.size() >
55 max_number_of_saved_frames()) {
56 size_t old_size = hidden_frames_.size();
57 // Should remove self from list.
58 hidden_frames_.back()->EvictCurrentFrame();
59 DCHECK_EQ(hidden_frames_.size() + 1, old_size);
60 }
61 }
62
63 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698