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" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 loading_enabled_(true), | 96 loading_enabled_(true), |
97 started_to_load_count_(0), | 97 started_to_load_count_(0), |
98 restore_started_(restore_started) { | 98 restore_started_(restore_started) { |
99 stats_collector_ = new SessionRestoreStatsCollector( | 99 stats_collector_ = new SessionRestoreStatsCollector( |
100 restore_started, | 100 restore_started, |
101 base::MakeUnique< | 101 base::MakeUnique< |
102 SessionRestoreStatsCollector::UmaStatsReportingDelegate>()); | 102 SessionRestoreStatsCollector::UmaStatsReportingDelegate>()); |
103 shared_tab_loader_ = this; | 103 shared_tab_loader_ = this; |
104 this_retainer_ = this; | 104 this_retainer_ = this; |
105 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); | 105 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); |
| 106 for (auto& observer : SessionRestore::observers()) |
| 107 observer.OnSessionRestoreStartedLoadingTabs(); |
106 } | 108 } |
107 | 109 |
108 TabLoader::~TabLoader() { | 110 TabLoader::~TabLoader() { |
109 DCHECK(tabs_loading_.empty() && tabs_to_load_.empty()); | 111 DCHECK(tabs_loading_.empty() && tabs_to_load_.empty()); |
110 DCHECK(shared_tab_loader_ == this); | 112 DCHECK(shared_tab_loader_ == this); |
111 shared_tab_loader_ = nullptr; | 113 shared_tab_loader_ = nullptr; |
112 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); | 114 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); |
| 115 for (auto& observer : SessionRestore::observers()) |
| 116 observer.OnSessionRestoreFinishedLoadingTabs(); |
113 } | 117 } |
114 | 118 |
115 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) { | 119 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) { |
116 // Add the tabs to the list of tabs loading/to load and register them for | 120 // 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 | 121 // 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 | 122 // 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 | 123 // 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 | 124 // 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 | 125 // have no way of finding out which tabs corresponds to which page if the icon |
122 // is a generic grey one. | 126 // is a generic grey one. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // memory pressure. | 312 // memory pressure. |
309 stats_collector_->DeferTab(tab); | 313 stats_collector_->DeferTab(tab); |
310 } | 314 } |
311 // By calling |LoadNextTab| explicitly, we make sure that the | 315 // By calling |LoadNextTab| explicitly, we make sure that the |
312 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 316 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
313 LoadNextTab(); | 317 LoadNextTab(); |
314 } | 318 } |
315 | 319 |
316 // static | 320 // static |
317 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 321 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
OLD | NEW |