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/memory/memory_coordinator_client_registry.h" | 10 #include "base/memory/memory_coordinator_client_registry.h" |
11 #include "base/memory/memory_coordinator_proxy.h" | 11 #include "base/memory/memory_coordinator_proxy.h" |
12 #include "base/memory/memory_pressure_monitor.h" | 12 #include "base/memory/memory_pressure_monitor.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/browser_process.h" | |
17 #include "chrome/browser/resource_coordinator/tab_manager.h" | |
16 #include "chrome/browser/sessions/session_restore_stats_collector.h" | 18 #include "chrome/browser/sessions/session_restore_stats_collector.h" |
17 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
20 #include "components/favicon/content/content_favicon_driver.h" | 22 #include "components/favicon/content/content_favicon_driver.h" |
21 #include "components/variations/variations_associated_data.h" | 23 #include "components/variations/variations_associated_data.h" |
22 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
23 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
25 #include "content/public/browser/render_widget_host.h" | 27 #include "content/public/browser/render_widget_host.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 loading_enabled_(true), | 98 loading_enabled_(true), |
97 started_to_load_count_(0), | 99 started_to_load_count_(0), |
98 restore_started_(restore_started) { | 100 restore_started_(restore_started) { |
99 stats_collector_ = new SessionRestoreStatsCollector( | 101 stats_collector_ = new SessionRestoreStatsCollector( |
100 restore_started, | 102 restore_started, |
101 base::MakeUnique< | 103 base::MakeUnique< |
102 SessionRestoreStatsCollector::UmaStatsReportingDelegate>()); | 104 SessionRestoreStatsCollector::UmaStatsReportingDelegate>()); |
103 shared_tab_loader_ = this; | 105 shared_tab_loader_ = this; |
104 this_retainer_ = this; | 106 this_retainer_ = this; |
105 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); | 107 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); |
108 | |
109 resource_coordinator::TabManager* tab_manager = | |
110 g_browser_process->GetTabManager(); | |
111 if (tab_manager) | |
112 tab_manager->MarkSessionRestoreStarted(); | |
chrisha
2017/06/15 19:44:56
This will fail if their are multiple session resto
| |
106 } | 113 } |
107 | 114 |
108 TabLoader::~TabLoader() { | 115 TabLoader::~TabLoader() { |
109 DCHECK(tabs_loading_.empty() && tabs_to_load_.empty()); | 116 DCHECK(tabs_loading_.empty() && tabs_to_load_.empty()); |
110 DCHECK(shared_tab_loader_ == this); | 117 DCHECK(shared_tab_loader_ == this); |
111 shared_tab_loader_ = nullptr; | 118 shared_tab_loader_ = nullptr; |
112 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); | 119 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); |
120 | |
121 resource_coordinator::TabManager* tab_manager = | |
122 g_browser_process->GetTabManager(); | |
123 if (tab_manager) | |
124 tab_manager->MarkSessionRestoreEnded(); | |
113 } | 125 } |
114 | 126 |
115 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) { | 127 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) { |
116 // Add the tabs to the list of tabs loading/to load and register them for | 128 // Add the tabs to the list of tabs loading/to load and register them for |
117 // notifications. Also, restore the favicons of the background tabs (the title | 129 // notifications. Also, restore the favicons of the background tabs (the title |
118 // has already been set by now).This avoids having blank icons in case the | 130 // has already been set by now).This avoids having blank icons in case the |
119 // restore is halted due to memory pressure. Also, when multiple tabs are | 131 // restore is halted due to memory pressure. Also, when multiple tabs are |
120 // restored to a single window, the title may not appear, and the user will | 132 // restored to a single window, the title may not appear, and the user will |
121 // have no way of finding out which tabs corresponds to which page if the icon | 133 // have no way of finding out which tabs corresponds to which page if the icon |
122 // is a generic grey one. | 134 // is a generic grey one. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 // memory pressure. | 320 // memory pressure. |
309 stats_collector_->DeferTab(tab); | 321 stats_collector_->DeferTab(tab); |
310 } | 322 } |
311 // By calling |LoadNextTab| explicitly, we make sure that the | 323 // By calling |LoadNextTab| explicitly, we make sure that the |
312 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 324 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
313 LoadNextTab(); | 325 LoadNextTab(); |
314 } | 326 } |
315 | 327 |
316 // static | 328 // static |
317 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 329 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
OLD | NEW |