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

Unified Diff: chrome/browser/sessions/tab_loader_delegate.cc

Issue 983223002: Hotlist Slow: Adopt ChromeOS Session restore tab loading timeouts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_loader_delegate_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/tab_loader_delegate.cc
diff --git a/chrome/browser/sessions/tab_loader_delegate.cc b/chrome/browser/sessions/tab_loader_delegate.cc
index 8e926d4217deb8e26395bdbe6b5e45d70d1a6014..640495ed68077d5f8379997dd0b7d310c539196f 100644
--- a/chrome/browser/sessions/tab_loader_delegate.cc
+++ b/chrome/browser/sessions/tab_loader_delegate.cc
@@ -4,33 +4,65 @@
#include "chrome/browser/sessions/tab_loader_delegate.h"
-#if !defined(OS_CHROMEOS)
+#include "net/base/network_change_notifier.h"
namespace {
// The timeout time after which the next tab gets loaded if the previous tab did
-// not finish loading yet.
-static const int kInitialDelayTimerMS = 100;
+// not finish loading yet. The used value is half of the median value of all
+// ChromeOS devices loading the 25 most common web pages. Half is chosen since
+// the loading time is a mix of server response and data bandwidth.
+static const int kInitialDelayTimerMS = 1500;
-class TabLoaderDelegateImpl : public TabLoaderDelegate {
+class TabLoaderDelegateImpl
+ : public TabLoaderDelegate,
+ public net::NetworkChangeNotifier::ConnectionTypeObserver {
public:
- TabLoaderDelegateImpl() {}
- ~TabLoaderDelegateImpl() override {}
+ explicit TabLoaderDelegateImpl(TabLoaderCallback* callback);
+ ~TabLoaderDelegateImpl() override;
// TabLoaderDelegate:
base::TimeDelta GetTimeoutBeforeLoadingNextTab() const override {
return base::TimeDelta::FromMilliseconds(kInitialDelayTimerMS);
}
+ // net::NetworkChangeNotifier::ConnectionTypeObserver:
+ void OnConnectionTypeChanged(
+ net::NetworkChangeNotifier::ConnectionType type) override;
+
private:
+ // The function to call when the connection type changes.
+ TabLoaderCallback* callback_;
+
DISALLOW_COPY_AND_ASSIGN(TabLoaderDelegateImpl);
};
+
+TabLoaderDelegateImpl::TabLoaderDelegateImpl(TabLoaderCallback* callback)
+ : callback_(callback) {
+ net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
+ if (net::NetworkChangeNotifier::IsOffline()) {
+ // When we are off-line we do not allow loading of tabs, since each of
+ // these tabs would start loading simultaneously when going online.
+ // TODO(skuhne): Once we get a higher level resource control logic which
+ // distributes network access, we can remove this.
+ callback->SetTabLoadingEnabled(false);
+ }
+}
+
+TabLoaderDelegateImpl::~TabLoaderDelegateImpl() {
+ net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
+}
+
+void TabLoaderDelegateImpl::OnConnectionTypeChanged(
+ net::NetworkChangeNotifier::ConnectionType type) {
+ callback_->SetTabLoadingEnabled(
+ type != net::NetworkChangeNotifier::CONNECTION_NONE);
+}
} // namespace
// static
scoped_ptr<TabLoaderDelegate> TabLoaderDelegate::Create(
TabLoaderCallback* callback) {
- return scoped_ptr<TabLoaderDelegate>(new TabLoaderDelegateImpl());
+ return scoped_ptr<TabLoaderDelegate>(
+ new TabLoaderDelegateImpl(callback));
}
-
-#endif // !defined(OS_CHROMEOS)
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_loader_delegate_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698