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

Unified Diff: chrome/browser/resource_coordinator/tab_manager.h

Issue 2931023002: [TooManyTabs] Add TabNavigationThrottle (Closed)
Patch Set: Created 3 years, 6 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: chrome/browser/resource_coordinator/tab_manager.h
diff --git a/chrome/browser/resource_coordinator/tab_manager.h b/chrome/browser/resource_coordinator/tab_manager.h
index 72fa655d0c0941118cd4ad190cc89a645c469eb9..572453d0054a6e7ec4738b1767817a24612d7e80 100644
--- a/chrome/browser/resource_coordinator/tab_manager.h
+++ b/chrome/browser/resource_coordinator/tab_manager.h
@@ -26,6 +26,7 @@
#include "chrome/browser/resource_coordinator/tab_stats.h"
#include "chrome/browser/ui/browser_tab_strip_tracker.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+#include "content/public/browser/navigation_throttle.h"
class BrowserList;
class GURL;
@@ -36,6 +37,7 @@ class TickClock;
}
namespace content {
+class NavigationHandle;
class WebContents;
}
@@ -146,6 +148,14 @@ class TabManager : public TabStripModelObserver {
// TODO(tasak): rename this to CanPurgeBackgroundedRenderer.
bool CanSuspendBackgroundedRenderer(int render_process_id) const;
+ // Maybe throttle a tab's navigation based on current system status.
+ content::NavigationThrottle::ThrottleCheckResult MaybeThrottleNavigation(
+ content::NavigationHandle* navigation_handle);
+
+ // Notifies TabManager that one tab has finished loading. TabManager can
+ // decide which tab to load next.
+ void HasFinishedLoadingTab(content::WebContents* contents);
+
// Returns true if |first| is considered less desirable to be killed than
// |second|.
static bool CompareTabStats(const TabStats& first, const TabStats& second);
@@ -154,6 +164,10 @@ class TabManager : public TabStripModelObserver {
// the WebContents could be deleted if the user closed the tab.
static int64_t IdFromWebContents(content::WebContents* web_contents);
+ // Returns true if the |url| represents an internal Chrome web UI page that
+ // can be easily reloaded and hence makes a good choice to discard.
Charlie Reis 2017/06/10 00:53:36 We may not need to expose this; see my question ab
Charlie Reis 2017/07/06 23:50:30 I'm still hoping we don't need this. (See https:/
Zhen Wang 2017/07/07 18:06:39 Now moved back to private as we do not need this U
+ static bool IsInternalPage(const GURL& url);
+
private:
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, PurgeBackgroundRenderer);
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ActivateTabResetPurgeState);
@@ -205,10 +219,6 @@ class TabManager : public TabStripModelObserver {
static void PurgeMemoryAndDiscardTab();
- // Returns true if the |url| represents an internal Chrome web UI page that
- // can be easily reloaded and hence makes a good choice to discard.
- static bool IsInternalPage(const GURL& url);
-
// Records UMA histogram statistics for a tab discard. Record statistics for
// user triggered discards via chrome://discards/ because that allows to
// manually test the system.
@@ -302,6 +312,13 @@ class TabManager : public TabStripModelObserver {
// Returns true if tabs can be discarded only once.
bool CanOnlyDiscardOnce() const;
+ // Returns true if the navigation should be throttled.
+ bool ShouldThrottleNavigation(
nasko 2017/06/12 23:22:02 nit: s/Throttle/Delay/ as in this case we only car
Zhen Wang 2017/06/13 23:33:20 Done.
+ content::NavigationHandle* navigation_handle) const;
+
+ // Resume the tab's navigation if it is pending right now.
+ void ResumeTabNavigationIfNeeded(content::WebContents* contents);
+
// Timer to periodically update the stats of the renderers.
base::RepeatingTimer update_timer_;
@@ -365,6 +382,13 @@ class TabManager : public TabStripModelObserver {
// List of observers that will receive notifications on state changes.
base::ObserverList<TabManagerObserver> observers_;
+ // The list of navigation handles that are throttled.
+ std::vector<content::NavigationHandle*> pending_navigations_;
+
+ // The tab that is currently loading. If multiple tabs are loading
+ // simultaneously, it corresponds to the lastest one.
+ content::WebContents* loading_contents_;
+
// Weak pointer factory used for posting delayed tasks.
base::WeakPtrFactory<TabManager> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698