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

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

Issue 2483003004: Make purge-and-suspend-time finch experiment parameter (Closed)
Patch Set: Rebaselined Created 4 years 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 | chrome/common/chrome_switches.h » ('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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 break; 724 break;
725 case SUSPENDED: 725 case SUSPENDED:
726 if (time_passed > kDurationOfRendererSuspension) 726 if (time_passed > kDurationOfRendererSuspension)
727 return RESUMED; 727 return RESUMED;
728 break; 728 break;
729 } 729 }
730 return state; 730 return state;
731 } 731 }
732 732
733 void TabManager::PurgeAndSuspendBackgroundedTabs() { 733 void TabManager::PurgeAndSuspendBackgroundedTabs() {
734 const base::CommandLine& command_line = 734 std::string purge_and_suspend_time = variations::GetVariationParamValue(
chrisha 2016/11/23 19:38:09 Maybe do this once in some kind of initialization
tasak 2016/11/24 02:16:20 I see. Done.
735 *base::CommandLine::ForCurrentProcess(); 735 "PurgeAndSuspend", "purge-and-suspend-time");
736 if (!command_line.HasSwitch(switches::kPurgeAndSuspendTime)) 736 int time_to_first_suspension_sec = 0;
737 if (purge_and_suspend_time.empty() ||
738 !base::StringToInt(purge_and_suspend_time, &time_to_first_suspension_sec))
737 return; 739 return;
738 int purge_and_suspend_time = 0; 740 if (time_to_first_suspension_sec <= 0)
739 if (!base::StringToInt(
740 command_line.GetSwitchValueASCII(switches::kPurgeAndSuspendTime),
741 &purge_and_suspend_time)) {
742 return;
743 }
744 if (purge_and_suspend_time <= 0)
745 return; 741 return;
746 base::TimeTicks current_time = NowTicks(); 742 base::TimeTicks current_time = NowTicks();
747 base::TimeDelta time_to_first_suspension = 743 base::TimeDelta time_to_first_suspension =
748 base::TimeDelta::FromSeconds(purge_and_suspend_time); 744 base::TimeDelta::FromSeconds(time_to_first_suspension_sec);
749 auto tab_stats = GetUnsortedTabStats(); 745 auto tab_stats = GetUnsortedTabStats();
750 for (auto& tab : tab_stats) { 746 for (auto& tab : tab_stats) {
751 if (!tab.render_process_host->IsProcessBackgrounded()) 747 if (!tab.render_process_host->IsProcessBackgrounded())
752 continue; 748 continue;
753 if (!CanSuspendBackgroundedRenderer(tab.child_process_host_id)) 749 if (!CanSuspendBackgroundedRenderer(tab.child_process_host_id))
754 continue; 750 continue;
755 751
756 WebContents* content = GetWebContentsById(tab.tab_contents_id); 752 WebContents* content = GetWebContentsById(tab.tab_contents_id);
757 if (!content) 753 if (!content)
758 continue; 754 continue;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 // platform. 1026 // platform.
1031 std::string allow_multiple_discards = variations::GetVariationParamValue( 1027 std::string allow_multiple_discards = variations::GetVariationParamValue(
1032 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); 1028 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards");
1033 return (allow_multiple_discards != "true"); 1029 return (allow_multiple_discards != "true");
1034 #else 1030 #else
1035 return false; 1031 return false;
1036 #endif 1032 #endif
1037 } 1033 }
1038 1034
1039 } // namespace memory 1035 } // namespace memory
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698