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

Unified 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: CONTENT_EXPORT Created 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/renderer_frame_manager.cc
diff --git a/content/browser/renderer_host/renderer_frame_manager.cc b/content/browser/renderer_host/renderer_frame_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3d16361828d3707af4ba58bc1d3c69b709653e50
--- /dev/null
+++ b/content/browser/renderer_host/renderer_frame_manager.cc
@@ -0,0 +1,60 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/renderer_frame_manager.h"
+
+#include "base/logging.h"
+#include "base/sys_info.h"
+
+namespace content {
+
+RendererFrameManager* RendererFrameManager::GetInstance() {
+ return Singleton<RendererFrameManager>::get();
+}
+
+void RendererFrameManager::AddFrame(RendererFrameManagerClient* frame,
+ bool visible) {
+ RemoveFrame(frame);
+ if (visible)
+ visible_frames_.insert(frame);
+ else
+ hidden_frames_.push_front(frame);
+ CullHiddenFrames();
+}
+
+void RendererFrameManager::RemoveFrame(RendererFrameManagerClient* frame) {
+ visible_frames_.erase(frame);
+ hidden_frames_.remove(frame);
+}
+
+void RendererFrameManager::SetFrameVisibility(RendererFrameManagerClient* frame,
+ bool visible) {
+ if (visible) {
+ hidden_frames_.remove(frame);
+ visible_frames_.insert(frame);
+ } else {
+ visible_frames_.erase(frame);
+ hidden_frames_.push_front(frame);
+ CullHiddenFrames();
+ }
+}
+
+RendererFrameManager::RendererFrameManager()
+ : max_number_of_saved_frames_(
+ std::min(5, 2 + (base::SysInfo::AmountOfPhysicalMemoryMB() / 256))) {}
+
+RendererFrameManager::~RendererFrameManager() {}
+
+void RendererFrameManager::CullHiddenFrames() {
+ while (!hidden_frames_.empty() &&
+ hidden_frames_.size() + visible_frames_.size() >
+ max_number_of_saved_frames()) {
+ size_t old_size = hidden_frames_.size();
+ // Should remove self from list.
+ hidden_frames_.back()->EvictCurrentFrame();
+ DCHECK_EQ(hidden_frames_.size() + 1, old_size);
+ }
+}
+
+} // namespace content
« no previous file with comments | « content/browser/renderer_host/renderer_frame_manager.h ('k') | content/browser/renderer_host/software_frame_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698