Commit 9586a8fa authored by chrisha's avatar chrisha Committed by Commit bot

Make session restore forced tab load delay Finch configurable, and separate...

Make session restore forced tab load delay Finch configurable, and separate first tab loads from subsequent.

BUG=472772

Review URL: https://codereview.chromium.org/1130673003

Cr-Commit-Position: refs/heads/master@{#330171}
parent 9c04acba
...@@ -117,7 +117,7 @@ void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) { ...@@ -117,7 +117,7 @@ void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) {
delegate_ = TabLoaderDelegate::Create(this); delegate_ = TabLoaderDelegate::Create(this);
// There is already at least one tab loading (the active tab). As such we // There is already at least one tab loading (the active tab). As such we
// only have to start the timeout timer here. // only have to start the timeout timer here.
StartTimer(); StartFirstTimer();
} }
} }
...@@ -152,6 +152,13 @@ void TabLoader::LoadNextTab() { ...@@ -152,6 +152,13 @@ void TabLoader::LoadNextTab() {
StartTimer(); StartTimer();
} }
void TabLoader::StartFirstTimer() {
force_load_timer_.Stop();
force_load_timer_.Start(FROM_HERE,
delegate_->GetFirstTabLoadingTimeout(),
this, &TabLoader::ForceLoadTimerFired);
}
void TabLoader::StartTimer() { void TabLoader::StartTimer() {
force_load_timer_.Stop(); force_load_timer_.Stop();
force_load_timer_.Start(FROM_HERE, force_load_timer_.Start(FROM_HERE,
......
...@@ -68,8 +68,14 @@ class TabLoader : public content::NotificationObserver, ...@@ -68,8 +68,14 @@ class TabLoader : public content::NotificationObserver,
// otherwise |force_load_timer_| is restarted. // otherwise |force_load_timer_| is restarted.
void LoadNextTab(); void LoadNextTab();
// Starts a timer to load load the next tab once expired before the current // Starts |force_load_timer_| to load the first non-visible tab if the timer
// tab loading is finished. // expires before a visible tab has finished loading. This uses the same
// timer but a different timeout value than StartTimer.
void StartFirstTimer();
// Starts |force_load_timer_| to load the next tab if the timer expires
// before the current tab loading is finished. This uses the same timer but a
// different timeout value than StartFirstTimer.
void StartTimer(); void StartTimer();
// Removes the listeners from the specified tab and removes the tab from // Removes the listeners from the specified tab and removes the tab from
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/sessions/tab_loader_delegate.h" #include "chrome/browser/sessions/tab_loader_delegate.h"
#include "base/strings/string_number_conversions.h"
#include "components/variations/variations_associated_data.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
namespace { namespace {
...@@ -21,9 +23,14 @@ class TabLoaderDelegateImpl ...@@ -21,9 +23,14 @@ class TabLoaderDelegateImpl
explicit TabLoaderDelegateImpl(TabLoaderCallback* callback); explicit TabLoaderDelegateImpl(TabLoaderCallback* callback);
~TabLoaderDelegateImpl() override; ~TabLoaderDelegateImpl() override;
// TabLoaderDelegate:
base::TimeDelta GetFirstTabLoadingTimeout() const override {
return first_timeout_;
}
// TabLoaderDelegate: // TabLoaderDelegate:
base::TimeDelta GetTimeoutBeforeLoadingNextTab() const override { base::TimeDelta GetTimeoutBeforeLoadingNextTab() const override {
return base::TimeDelta::FromMilliseconds(kInitialDelayTimerMS); return timeout_;
} }
// net::NetworkChangeNotifier::ConnectionTypeObserver: // net::NetworkChangeNotifier::ConnectionTypeObserver:
...@@ -34,6 +41,10 @@ class TabLoaderDelegateImpl ...@@ -34,6 +41,10 @@ class TabLoaderDelegateImpl
// The function to call when the connection type changes. // The function to call when the connection type changes.
TabLoaderCallback* callback_; TabLoaderCallback* callback_;
// The timeouts to use in tab loading.
base::TimeDelta first_timeout_;
base::TimeDelta timeout_;
DISALLOW_COPY_AND_ASSIGN(TabLoaderDelegateImpl); DISALLOW_COPY_AND_ASSIGN(TabLoaderDelegateImpl);
}; };
...@@ -47,6 +58,28 @@ TabLoaderDelegateImpl::TabLoaderDelegateImpl(TabLoaderCallback* callback) ...@@ -47,6 +58,28 @@ TabLoaderDelegateImpl::TabLoaderDelegateImpl(TabLoaderCallback* callback)
// distributes network access, we can remove this. // distributes network access, we can remove this.
callback->SetTabLoadingEnabled(false); callback->SetTabLoadingEnabled(false);
} }
// Initialize the timeouts to use from the session restore field trial.
// Default to the usual value if none is specified.
static const char kIntelligentSessionRestore[] = "IntelligentSessionRestore";
std::string timeout = variations::GetVariationParamValue(
kIntelligentSessionRestore, "FirstTabLoadTimeoutMs");
int timeout_ms = 0;
if (timeout.empty() || !base::StringToInt(timeout, &timeout_ms) ||
timeout_ms <= 0) {
timeout_ms = kInitialDelayTimerMS;
}
first_timeout_ = base::TimeDelta::FromMilliseconds(timeout_ms);
timeout = variations::GetVariationParamValue(
kIntelligentSessionRestore, "TabLoadTimeoutMs");
timeout_ms = 0;
if (timeout.empty() || !base::StringToInt(timeout, &timeout_ms) ||
timeout_ms <= 0) {
timeout_ms = kInitialDelayTimerMS;
}
timeout_ = base::TimeDelta::FromMilliseconds(timeout_ms);
} }
TabLoaderDelegateImpl::~TabLoaderDelegateImpl() { TabLoaderDelegateImpl::~TabLoaderDelegateImpl() {
......
...@@ -27,8 +27,12 @@ class TabLoaderDelegate { ...@@ -27,8 +27,12 @@ class TabLoaderDelegate {
// The callback object is valid as long as this object exists. // The callback object is valid as long as this object exists.
static scoped_ptr<TabLoaderDelegate> Create(TabLoaderCallback* callback); static scoped_ptr<TabLoaderDelegate> Create(TabLoaderCallback* callback);
// Returns the default timeout time after which the first non-visible tab
// gets loaded if the first (visible) tab did not finish loading.
virtual base::TimeDelta GetFirstTabLoadingTimeout() const = 0;
// Returns the default timeout time after which the next tab gets loaded if // Returns the default timeout time after which the next tab gets loaded if
// the previous tab did not finish to load. // the previous tab did not finish loading.
virtual base::TimeDelta GetTimeoutBeforeLoadingNextTab() const = 0; virtual base::TimeDelta GetTimeoutBeforeLoadingNextTab() const = 0;
}; };
......
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