Commit e7cb7785 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

RC: Mark TabManager::IsTab(InSessionRestore|RestoredInForeground) as static.

These methods don't access member variables, so they can easily be
made static. Making these methods static will avoid having to initialize
TabManager and its dependencies in a bunch of tests.

Bug: 775644
Change-Id: I2ef567c855e34e234faad569126e752460cd2418
Reviewed-on: https://chromium-review.googlesource.com/1132094Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarSébastien Marchand <sebmarchand@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574163}
parent d9068c11
...@@ -36,14 +36,11 @@ SessionRestorePageLoadMetricsObserver::OnStart( ...@@ -36,14 +36,11 @@ SessionRestorePageLoadMetricsObserver::OnStart(
const GURL& currently_committed_url, const GURL& currently_committed_url,
bool started_in_foreground) { bool started_in_foreground) {
content::WebContents* contents = navigation_handle->GetWebContents(); content::WebContents* contents = navigation_handle->GetWebContents();
resource_coordinator::TabManager* tab_manager = if (!started_in_foreground ||
g_browser_process->GetTabManager(); !resource_coordinator::TabManager::IsTabInSessionRestore(contents) ||
// Should not be null because this is used only on supported platforms. !resource_coordinator::TabManager::IsTabRestoredInForeground(contents)) {
DCHECK(tab_manager);
if (!started_in_foreground || !tab_manager->IsTabInSessionRestore(contents) ||
!tab_manager->IsTabRestoredInForeground(contents))
return STOP_OBSERVING; return STOP_OBSERVING;
}
// The navigation should be from the last session. // The navigation should be from the last session.
DCHECK(navigation_handle->GetRestoreType() == DCHECK(navigation_handle->GetRestoreType() ==
......
...@@ -348,14 +348,6 @@ bool TabManager::CanPurgeBackgroundedRenderer(int render_process_id) const { ...@@ -348,14 +348,6 @@ bool TabManager::CanPurgeBackgroundedRenderer(int render_process_id) const {
return true; return true;
} }
bool TabManager::IsTabInSessionRestore(WebContents* web_contents) const {
return GetWebContentsData(web_contents)->is_in_session_restore();
}
bool TabManager::IsTabRestoredInForeground(WebContents* web_contents) const {
return GetWebContentsData(web_contents)->is_restored_in_foreground();
}
size_t TabManager::GetBackgroundTabLoadingCount() const { size_t TabManager::GetBackgroundTabLoadingCount() const {
if (!IsInBackgroundTabOpeningSession()) if (!IsInBackgroundTabOpeningSession())
return 0; return 0;
...@@ -377,8 +369,14 @@ int TabManager::GetTabCount() const { ...@@ -377,8 +369,14 @@ int TabManager::GetTabCount() const {
return tab_count; return tab_count;
} }
int TabManager::restored_tab_count() const { // static
return restored_tab_count_; bool TabManager::IsTabInSessionRestore(WebContents* web_contents) {
return GetWebContentsData(web_contents)->is_in_session_restore();
}
// static
bool TabManager::IsTabRestoredInForeground(WebContents* web_contents) {
return GetWebContentsData(web_contents)->is_restored_in_foreground();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -157,14 +157,6 @@ class TabManager : public LifecycleUnitObserver, ...@@ -157,14 +157,6 @@ class TabManager : public LifecycleUnitObserver,
return is_session_restore_loading_tabs_; return is_session_restore_loading_tabs_;
} }
// Returns true if the tab was created by session restore and has not finished
// the first navigation.
bool IsTabInSessionRestore(content::WebContents* web_contents) const;
// Returns true if the tab was created by session restore and initially in
// foreground.
bool IsTabRestoredInForeground(content::WebContents* web_contents) const;
// Returns the number of background tabs that are loading in a background tab // Returns the number of background tabs that are loading in a background tab
// opening session. // opening session.
size_t GetBackgroundTabLoadingCount() const; size_t GetBackgroundTabLoadingCount() const;
...@@ -178,12 +170,20 @@ class TabManager : public LifecycleUnitObserver, ...@@ -178,12 +170,20 @@ class TabManager : public LifecycleUnitObserver,
// Returns the number of restored tabs during session restore. This is // Returns the number of restored tabs during session restore. This is
// non-zero only during session restore. // non-zero only during session restore.
int restored_tab_count() const; int restored_tab_count() const { return restored_tab_count_; }
InterventionPolicyDatabase* intervention_policy_database() { InterventionPolicyDatabase* intervention_policy_database() {
return intervention_policy_database_.get(); return intervention_policy_database_.get();
} }
// Returns true if the tab was created by session restore and has not finished
// the first navigation.
static bool IsTabInSessionRestore(content::WebContents* web_contents);
// Returns true if the tab was created by session restore and initially in
// foreground.
static bool IsTabRestoredInForeground(content::WebContents* web_contents);
private: private:
friend class TabManagerStatsCollectorTest; friend class TabManagerStatsCollectorTest;
friend class TabManagerWithProactiveDiscardExperimentEnabledTest; friend class TabManagerWithProactiveDiscardExperimentEnabledTest;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment