OLD | NEW |
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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "chrome/browser/sessions/session_restore_stats_collector.h" |
12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "components/favicon/content/content_favicon_driver.h" | 16 #include "components/favicon/content/content_favicon_driver.h" |
16 #include "components/variations/variations_associated_data.h" | 17 #include "components/variations/variations_associated_data.h" |
17 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
20 #include "content/public/browser/render_widget_host.h" | 21 #include "content/public/browser/render_widget_host.h" |
21 #include "content/public/browser/render_widget_host_view.h" | 22 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 #endif | 208 #endif |
208 | 209 |
209 // When receiving a resource pressure level warning, we stop pre-loading more | 210 // When receiving a resource pressure level warning, we stop pre-loading more |
210 // tabs since we are running in danger of loading more tabs by throwing out | 211 // tabs since we are running in danger of loading more tabs by throwing out |
211 // old ones. | 212 // old ones. |
212 if (tabs_to_load_.empty()) | 213 if (tabs_to_load_.empty()) |
213 return; | 214 return; |
214 // Stop the timer and suppress any tab loads while we clean the list. | 215 // Stop the timer and suppress any tab loads while we clean the list. |
215 SetTabLoadingEnabled(false); | 216 SetTabLoadingEnabled(false); |
216 while (!tabs_to_load_.empty()) { | 217 while (!tabs_to_load_.empty()) { |
217 NavigationController* controller = tabs_to_load_.front(); | 218 NavigationController* tab = tabs_to_load_.front(); |
218 tabs_to_load_.pop_front(); | 219 tabs_to_load_.pop_front(); |
219 RemoveTab(controller); | 220 RemoveTab(tab); |
| 221 |
| 222 // Notify the stats collector that a tab's loading has been deferred due to |
| 223 // memory pressure. It's possible for the stats collector to infer this on |
| 224 // its own, but not in the presence of the above experiment, hence this is |
| 225 // explicitly called. |
| 226 // TODO(chrisha): Re-evaluate this was the memory-pressure experiment is |
| 227 // finished. |
| 228 SessionRestoreStatsCollector::DeferTab(tab); |
220 } | 229 } |
221 // By calling |LoadNextTab| explicitly, we make sure that the | 230 // By calling |LoadNextTab| explicitly, we make sure that the |
222 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 231 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
223 LoadNextTab(); | 232 LoadNextTab(); |
224 } | 233 } |
225 | 234 |
226 // static | 235 // static |
227 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 236 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
OLD | NEW |