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

Side by Side Diff: chrome/browser/memory/tab_manager.cc

Issue 2399293002: Add MemoryCoordinatorDelegate (Closed)
Patch Set: Add a separate delegate class 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 | « chrome/browser/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/memory/tab_manager.h" 5 #include "chrome/browser/memory/tab_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 bool TabManager::IsTabAutoDiscardable(content::WebContents* contents) const { 412 bool TabManager::IsTabAutoDiscardable(content::WebContents* contents) const {
413 return GetWebContentsData(contents)->IsAutoDiscardable(); 413 return GetWebContentsData(contents)->IsAutoDiscardable();
414 } 414 }
415 415
416 void TabManager::SetTabAutoDiscardableState(content::WebContents* contents, 416 void TabManager::SetTabAutoDiscardableState(content::WebContents* contents,
417 bool state) { 417 bool state) {
418 GetWebContentsData(contents)->SetAutoDiscardableState(state); 418 GetWebContentsData(contents)->SetAutoDiscardableState(state);
419 } 419 }
420 420
421 bool TabManager::CanSuspendBackgroundedRenderer(int render_process_id) {
422 // A renderer can be suspended if it's not playing media.
423 auto tab_stats = GetUnsortedTabStats();
424 for (auto& tab : tab_stats) {
425 if (tab.child_process_host_id != render_process_id)
426 continue;
427 TabStripModel* model;
428 int index = FindTabStripModelById(tab.tab_contents_id, &model);
429 if (index == -1)
430 return false;
431 WebContents* web_contents = model->GetWebContentsAt(index);
432 if (IsMediaTab(web_contents))
433 return false;
434 }
435 return true;
436 }
437
421 // static 438 // static
422 bool TabManager::CompareTabStats(const TabStats& first, 439 bool TabManager::CompareTabStats(const TabStats& first,
423 const TabStats& second) { 440 const TabStats& second) {
424 // Being currently selected is most important to protect. 441 // Being currently selected is most important to protect.
425 if (first.is_selected != second.is_selected) 442 if (first.is_selected != second.is_selected)
426 return first.is_selected; 443 return first.is_selected;
427 444
428 // Non auto-discardable tabs are more important to protect. 445 // Non auto-discardable tabs are more important to protect.
429 if (first.is_auto_discardable != second.is_auto_discardable) 446 if (first.is_auto_discardable != second.is_auto_discardable)
430 return !first.is_auto_discardable; 447 return !first.is_auto_discardable;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // platform. 957 // platform.
941 std::string allow_multiple_discards = variations::GetVariationParamValue( 958 std::string allow_multiple_discards = variations::GetVariationParamValue(
942 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); 959 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards");
943 return (allow_multiple_discards != "true"); 960 return (allow_multiple_discards != "true");
944 #else 961 #else
945 return false; 962 return false;
946 #endif 963 #endif
947 } 964 }
948 965
949 } // namespace memory 966 } // namespace memory
OLDNEW
« no previous file with comments | « chrome/browser/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698