Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 41 break; | 42 break; |
| 42 } | 43 } |
| 43 default: | 44 default: |
| 44 NOTREACHED() << "Unknown notification received:" << type; | 45 NOTREACHED() << "Unknown notification received:" << type; |
| 45 } | 46 } |
| 46 // Delete ourselves when we are done. | 47 // Delete ourselves when we are done. |
| 47 if (tabs_loading_.empty() && tabs_to_load_.empty()) | 48 if (tabs_loading_.empty() && tabs_to_load_.empty()) |
| 48 this_retainer_ = nullptr; | 49 this_retainer_ = nullptr; |
| 49 } | 50 } |
| 50 | 51 |
| 51 void TabLoader::SetTabLoadingEnabled(bool enable_tab_loading) { | 52 void TabLoader::SetTabLoadingEnabled(bool enable_tab_loading) { |
|
sky
2015/05/12 15:27:56
This likely needs to invalidate a bunch of histogr
chrisha
2015/05/13 21:18:02
No more information is provided at the site of thi
sky
2015/05/14 00:12:40
My concern is that any time based histograms are n
chrisha
2015/05/14 21:27:02
We only track time to first paint, and this concer
| |
| 52 if (enable_tab_loading == loading_enabled_) | 53 if (enable_tab_loading == loading_enabled_) |
| 53 return; | 54 return; |
| 54 loading_enabled_ = enable_tab_loading; | 55 loading_enabled_ = enable_tab_loading; |
| 55 if (loading_enabled_) | 56 if (loading_enabled_) |
| 56 LoadNextTab(); | 57 LoadNextTab(); |
| 57 else | 58 else |
| 58 force_load_timer_.Stop(); | 59 force_load_timer_.Stop(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 // static | 62 // static |
| (...skipping 145 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 |