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

Side by Side Diff: chrome/browser/sessions/tab_loader.cc

Issue 1130673003: Make session restore forced tab load delay Finch configurable, and separate first tab loads from su… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now actually compiles! Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sessions/tab_loader.h" 5 #include "chrome/browser/sessions/tab_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // eventually. 110 // eventually.
111 if (delegate_) 111 if (delegate_)
112 return; 112 return;
113 113
114 // Create a TabLoaderDelegate which will allow OS specific behavior for tab 114 // Create a TabLoaderDelegate which will allow OS specific behavior for tab
115 // loading. 115 // loading.
116 if (!delegate_) { 116 if (!delegate_) {
117 delegate_ = TabLoaderDelegate::Create(this); 117 delegate_ = TabLoaderDelegate::Create(this);
118 // There is already at least one tab loading (the active tab). As such we 118 // There is already at least one tab loading (the active tab). As such we
119 // only have to start the timeout timer here. 119 // only have to start the timeout timer here.
120 StartTimer(); 120 StartFirstTimer();
121 } 121 }
122 } 122 }
123 123
124 void TabLoader::LoadNextTab() { 124 void TabLoader::LoadNextTab() {
125 // LoadNextTab should only get called after we have started the tab 125 // LoadNextTab should only get called after we have started the tab
126 // loading. 126 // loading.
127 CHECK(delegate_); 127 CHECK(delegate_);
128 if (!tabs_to_load_.empty()) { 128 if (!tabs_to_load_.empty()) {
129 NavigationController* controller = tabs_to_load_.front(); 129 NavigationController* controller = tabs_to_load_.front();
130 DCHECK(controller); 130 DCHECK(controller);
(...skipping 14 matching lines...) Expand all
145 // the call would do nothing. 145 // the call would do nothing.
146 contents->WasHidden(); 146 contents->WasHidden();
147 } 147 }
148 } 148 }
149 } 149 }
150 150
151 if (!tabs_to_load_.empty()) 151 if (!tabs_to_load_.empty())
152 StartTimer(); 152 StartTimer();
153 } 153 }
154 154
155 void TabLoader::StartFirstTimer() {
156 force_load_timer_.Stop();
gab 2015/05/15 18:21:02 Looks like Start() already takes care of stopping
chrisha 2015/05/15 18:47:12 Acknowledged.
157 force_load_timer_.Start(FROM_HERE,
158 delegate_->GetFirstTabLoadingTimeout(),
159 this, &TabLoader::ForceLoadTimerFired);
160 }
161
155 void TabLoader::StartTimer() { 162 void TabLoader::StartTimer() {
156 force_load_timer_.Stop(); 163 force_load_timer_.Stop();
157 force_load_timer_.Start(FROM_HERE, 164 force_load_timer_.Start(FROM_HERE,
158 delegate_->GetTimeoutBeforeLoadingNextTab() * 165 delegate_->GetTimeoutBeforeLoadingNextTab() *
159 force_load_delay_multiplier_, 166 force_load_delay_multiplier_,
160 this, &TabLoader::ForceLoadTimerFired); 167 this, &TabLoader::ForceLoadTimerFired);
161 } 168 }
162 169
163 void TabLoader::RemoveTab(NavigationController* controller) { 170 void TabLoader::RemoveTab(NavigationController* controller) {
164 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 171 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 tabs_to_load_.pop_front(); 225 tabs_to_load_.pop_front();
219 RemoveTab(controller); 226 RemoveTab(controller);
220 } 227 }
221 // By calling |LoadNextTab| explicitly, we make sure that the 228 // By calling |LoadNextTab| explicitly, we make sure that the
222 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. 229 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent.
223 LoadNextTab(); 230 LoadNextTab();
224 } 231 }
225 232
226 // static 233 // static
227 TabLoader* TabLoader::shared_tab_loader_ = nullptr; 234 TabLoader* TabLoader::shared_tab_loader_ = nullptr;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698