Commit 8a4be6b1 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

RC: Remove TabLifecycleUnitExternal::FreezeTab/IsFrozen().

Freezing shouldn't be exposed to external components.

Bug: 775644
Change-Id: I60014f3a39ab241677d678d49ab1ffb2f99689c6
Reviewed-on: https://chromium-review.googlesource.com/1099650Reviewed-by: default avatarSébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: default avatarFadi Meawad <fmeawad@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568033}
parent f1240efe
...@@ -41,11 +41,6 @@ bool IsDiscardedOrPendingDiscard(LifecycleUnitState state) { ...@@ -41,11 +41,6 @@ bool IsDiscardedOrPendingDiscard(LifecycleUnitState state) {
state == LifecycleUnitState::PENDING_DISCARD; state == LifecycleUnitState::PENDING_DISCARD;
} }
bool IsFrozenOrPendingFreeze(LifecycleUnitState state) {
return state == LifecycleUnitState::FROZEN ||
state == LifecycleUnitState::PENDING_FREEZE;
}
// Returns true if it is valid to transition from |from| to |to| for |reason|. // Returns true if it is valid to transition from |from| to |to| for |reason|.
bool IsValidStateChange(LifecycleUnitState from, bool IsValidStateChange(LifecycleUnitState from,
LifecycleUnitState to, LifecycleUnitState to,
...@@ -680,10 +675,6 @@ void TabLifecycleUnitSource::TabLifecycleUnit::ReloadBloatedTab() { ...@@ -680,10 +675,6 @@ void TabLifecycleUnitSource::TabLifecycleUnit::ReloadBloatedTab() {
} }
} }
bool TabLifecycleUnitSource::TabLifecycleUnit::FreezeTab() {
return Freeze();
}
bool TabLifecycleUnitSource::TabLifecycleUnit::IsDiscarded() const { bool TabLifecycleUnitSource::TabLifecycleUnit::IsDiscarded() const {
// External code does not need to know about the intermediary PENDING_DISCARD // External code does not need to know about the intermediary PENDING_DISCARD
// state. To external callers, the tab is discarded while in the // state. To external callers, the tab is discarded while in the
...@@ -691,13 +682,6 @@ bool TabLifecycleUnitSource::TabLifecycleUnit::IsDiscarded() const { ...@@ -691,13 +682,6 @@ bool TabLifecycleUnitSource::TabLifecycleUnit::IsDiscarded() const {
return IsDiscardedOrPendingDiscard(GetState()); return IsDiscardedOrPendingDiscard(GetState());
} }
bool TabLifecycleUnitSource::TabLifecycleUnit::IsFrozen() const {
// External code does not need to know about the intermediary PENDING_FREEZE
// state. To external callers, the tab is frozen while in the PENDING_FREEZE
// state.
return IsFrozenOrPendingFreeze(GetState());
}
int TabLifecycleUnitSource::TabLifecycleUnit::GetDiscardCount() const { int TabLifecycleUnitSource::TabLifecycleUnit::GetDiscardCount() const {
return discard_count_; return discard_count_;
} }
......
...@@ -103,10 +103,8 @@ class TabLifecycleUnitSource::TabLifecycleUnit ...@@ -103,10 +103,8 @@ class TabLifecycleUnitSource::TabLifecycleUnit
bool IsMediaTab() const override; bool IsMediaTab() const override;
bool IsAutoDiscardable() const override; bool IsAutoDiscardable() const override;
void SetAutoDiscardable(bool auto_discardable) override; void SetAutoDiscardable(bool auto_discardable) override;
bool FreezeTab() override;
bool DiscardTab() override; bool DiscardTab() override;
bool IsDiscarded() const override; bool IsDiscarded() const override;
bool IsFrozen() const override;
int GetDiscardCount() const override; int GetDiscardCount() const override;
protected: protected:
......
...@@ -42,18 +42,12 @@ class TabLifecycleUnitExternal { ...@@ -42,18 +42,12 @@ class TabLifecycleUnitExternal {
// Allows/disallows this tab to be automatically discarded. // Allows/disallows this tab to be automatically discarded.
virtual void SetAutoDiscardable(bool auto_discardable) = 0; virtual void SetAutoDiscardable(bool auto_discardable) = 0;
// Freezes the tab.
virtual bool FreezeTab() = 0;
// Discards the tab. // Discards the tab.
virtual bool DiscardTab() = 0; virtual bool DiscardTab() = 0;
// Returns true if the tab is discarded. // Returns true if the tab is discarded.
virtual bool IsDiscarded() const = 0; virtual bool IsDiscarded() const = 0;
// Returns true if the tab is frozen.
virtual bool IsFrozen() const = 0;
// Returns the number of times that the tab was discarded. // Returns the number of times that the tab was discarded.
virtual int GetDiscardCount() const = 0; virtual int GetDiscardCount() const = 0;
}; };
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/background_tab_navigation_throttle.h" #include "chrome/browser/resource_coordinator/background_tab_navigation_throttle.h"
#include "chrome/browser/resource_coordinator/tab_helper.h" #include "chrome/browser/resource_coordinator/tab_helper.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h" #include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
#include "chrome/browser/resource_coordinator/tab_manager_features.h" #include "chrome/browser/resource_coordinator/tab_manager_features.h"
#include "chrome/browser/resource_coordinator/tab_manager_resource_coordinator_signal_observer.h" #include "chrome/browser/resource_coordinator/tab_manager_resource_coordinator_signal_observer.h"
...@@ -109,14 +110,6 @@ enum TestIndicies { ...@@ -109,14 +110,6 @@ enum TestIndicies {
kInternalPage, kInternalPage,
}; };
bool IsTabDiscarded(content::WebContents* web_contents) {
return TabLifecycleUnitExternal::FromWebContents(web_contents)->IsDiscarded();
}
bool IsTabFrozen(content::WebContents* web_contents) {
return TabLifecycleUnitExternal::FromWebContents(web_contents)->IsFrozen();
}
} // namespace } // namespace
class TabManagerTest : public ChromeRenderViewHostTestHarness { class TabManagerTest : public ChromeRenderViewHostTestHarness {
...@@ -211,6 +204,19 @@ class TabManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -211,6 +204,19 @@ class TabManagerTest : public ChromeRenderViewHostTestHarness {
CheckThrottleResults(result1, result2, result3, loading_slots); CheckThrottleResults(result1, result2, result3, loading_slots);
} }
bool IsTabDiscarded(content::WebContents* content) {
return TabLifecycleUnitExternal::FromWebContents(content)->IsDiscarded();
}
bool IsTabFrozen(content::WebContents* content) {
const LifecycleUnitState state =
static_cast<TabLifecycleUnitSource::TabLifecycleUnit*>(
TabLifecycleUnitExternal::FromWebContents(content))
->GetState();
return state == LifecycleUnitState::PENDING_FREEZE ||
state == LifecycleUnitState::FROZEN;
}
virtual void CheckThrottleResults( virtual void CheckThrottleResults(
NavigationThrottle::ThrottleCheckResult result1, NavigationThrottle::ThrottleCheckResult result1,
NavigationThrottle::ThrottleCheckResult result2, NavigationThrottle::ThrottleCheckResult result2,
......
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