OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/session_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 RenderWidgetHostSet render_widget_hosts_to_paint_; | 152 RenderWidgetHostSet render_widget_hosts_to_paint_; |
153 | 153 |
154 // The number of tabs that have been restored. | 154 // The number of tabs that have been restored. |
155 int tab_count_; | 155 int tab_count_; |
156 | 156 |
157 base::OneShotTimer<TabLoader> force_load_timer_; | 157 base::OneShotTimer<TabLoader> force_load_timer_; |
158 | 158 |
159 // The time the restore process started. | 159 // The time the restore process started. |
160 base::TimeTicks restore_started_; | 160 base::TimeTicks restore_started_; |
161 | 161 |
162 // Max number of tabs that were loaded in parallel (for metrics). | |
163 size_t max_parallel_tab_loads_; | |
164 | |
162 DISALLOW_COPY_AND_ASSIGN(TabLoader); | 165 DISALLOW_COPY_AND_ASSIGN(TabLoader); |
163 }; | 166 }; |
164 | 167 |
165 TabLoader::TabLoader(base::TimeTicks restore_started) | 168 TabLoader::TabLoader(base::TimeTicks restore_started) |
166 : force_load_delay_(kInitialDelayTimerMS), | 169 : force_load_delay_(kInitialDelayTimerMS), |
167 loading_(false), | 170 loading_(false), |
168 got_first_paint_(false), | 171 got_first_paint_(false), |
169 tab_count_(0), | 172 tab_count_(0), |
170 restore_started_(restore_started) { | 173 restore_started_(restore_started), |
174 max_parallel_tab_loads_(0) { | |
171 } | 175 } |
172 | 176 |
173 TabLoader::~TabLoader() { | 177 TabLoader::~TabLoader() { |
174 DCHECK((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && | 178 DCHECK((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && |
175 tabs_loading_.empty() && tabs_to_load_.empty()); | 179 tabs_loading_.empty() && tabs_to_load_.empty()); |
176 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); | 180 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); |
177 } | 181 } |
178 | 182 |
179 void TabLoader::ScheduleLoad(NavigationController* controller) { | 183 void TabLoader::ScheduleLoad(NavigationController* controller) { |
180 DCHECK(controller); | 184 DCHECK(controller); |
(...skipping 28 matching lines...) Expand all Loading... | |
209 loading_ = true; | 213 loading_ = true; |
210 LoadNextTab(); | 214 LoadNextTab(); |
211 #endif | 215 #endif |
212 } | 216 } |
213 | 217 |
214 void TabLoader::LoadNextTab() { | 218 void TabLoader::LoadNextTab() { |
215 if (!tabs_to_load_.empty()) { | 219 if (!tabs_to_load_.empty()) { |
216 NavigationController* tab = tabs_to_load_.front(); | 220 NavigationController* tab = tabs_to_load_.front(); |
217 DCHECK(tab); | 221 DCHECK(tab); |
218 tabs_loading_.insert(tab); | 222 tabs_loading_.insert(tab); |
223 if (tabs_loading_.size() > max_parallel_tab_loads_) | |
224 max_parallel_tab_loads_ = tabs_loading_.size(); | |
219 tabs_to_load_.pop_front(); | 225 tabs_to_load_.pop_front(); |
220 tab->LoadIfNecessary(); | 226 tab->LoadIfNecessary(); |
221 if (tab->GetWebContents()) { | 227 if (tab->GetWebContents()) { |
222 int tab_index; | 228 int tab_index; |
223 Browser* browser = Browser::GetBrowserForController(tab, &tab_index); | 229 Browser* browser = Browser::GetBrowserForController(tab, &tab_index); |
224 if (browser && browser->active_index() != tab_index) { | 230 if (browser && browser->active_index() != tab_index) { |
225 // By default tabs are marked as visible. As only the active tab is | 231 // By default tabs are marked as visible. As only the active tab is |
226 // visible we need to explicitly tell non-active tabs they are hidden. | 232 // visible we need to explicitly tell non-active tabs they are hidden. |
227 // Without this call non-active tabs are not marked as backgrounded. | 233 // Without this call non-active tabs are not marked as backgrounded. |
228 // | 234 // |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 std::string time_for_count = | 403 std::string time_for_count = |
398 base::StringPrintf("SessionRestore.AllTabsLoaded_%d", tab_count_); | 404 base::StringPrintf("SessionRestore.AllTabsLoaded_%d", tab_count_); |
399 base::Histogram* counter_for_count = | 405 base::Histogram* counter_for_count = |
400 base::Histogram::FactoryTimeGet( | 406 base::Histogram::FactoryTimeGet( |
401 time_for_count, | 407 time_for_count, |
402 base::TimeDelta::FromMilliseconds(10), | 408 base::TimeDelta::FromMilliseconds(10), |
403 base::TimeDelta::FromSeconds(100), | 409 base::TimeDelta::FromSeconds(100), |
404 100, | 410 100, |
405 base::Histogram::kUmaTargetedHistogramFlag); | 411 base::Histogram::kUmaTargetedHistogramFlag); |
406 counter_for_count->AddTime(time_to_load); | 412 counter_for_count->AddTime(time_to_load); |
413 | |
414 UMA_HISTOGRAM_COUNTS_100("SessionRestore.ParallelTabLoads", | |
sky
2012/03/27 17:04:34
Would it be better to do this in the destructor?
marja
2012/03/27 18:37:48
Hmm, why? The other "finished tab loading" -relate
sky
2012/03/27 20:10:10
I was assuming you only cared about the max number
| |
415 max_parallel_tab_loads_); | |
407 } | 416 } |
408 } | 417 } |
409 | 418 |
410 // SessionRestoreImpl --------------------------------------------------------- | 419 // SessionRestoreImpl --------------------------------------------------------- |
411 | 420 |
412 // SessionRestoreImpl is responsible for fetching the set of tabs to create | 421 // SessionRestoreImpl is responsible for fetching the set of tabs to create |
413 // from SessionService. SessionRestoreImpl deletes itself when done. | 422 // from SessionService. SessionRestoreImpl deletes itself when done. |
414 | 423 |
415 class SessionRestoreImpl : public content::NotificationObserver { | 424 class SessionRestoreImpl : public content::NotificationObserver { |
416 public: | 425 public: |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1011 if (active_session_restorers == NULL) | 1020 if (active_session_restorers == NULL) |
1012 return false; | 1021 return false; |
1013 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1022 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1014 active_session_restorers->begin(); | 1023 active_session_restorers->begin(); |
1015 it != active_session_restorers->end(); ++it) { | 1024 it != active_session_restorers->end(); ++it) { |
1016 if ((*it)->profile() == profile) | 1025 if ((*it)->profile() == profile) |
1017 return true; | 1026 return true; |
1018 } | 1027 } |
1019 return false; | 1028 return false; |
1020 } | 1029 } |
OLD | NEW |