| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // restore is halted due to memory pressure. Also, when multiple tabs are | 108 // restore is halted due to memory pressure. Also, when multiple tabs are |
| 109 // restored to a single window, the title may not appear, and the user will | 109 // restored to a single window, the title may not appear, and the user will |
| 110 // have no way of finding out which tabs corresponds to which page if the icon | 110 // have no way of finding out which tabs corresponds to which page if the icon |
| 111 // is a generic grey one. | 111 // is a generic grey one. |
| 112 for (auto& restored_tab : tabs) { | 112 for (auto& restored_tab : tabs) { |
| 113 if (!restored_tab.is_active()) { | 113 if (!restored_tab.is_active()) { |
| 114 tabs_to_load_.push_back(&restored_tab.contents()->GetController()); | 114 tabs_to_load_.push_back(&restored_tab.contents()->GetController()); |
| 115 favicon::ContentFaviconDriver* favicon_driver = | 115 favicon::ContentFaviconDriver* favicon_driver = |
| 116 favicon::ContentFaviconDriver::FromWebContents( | 116 favicon::ContentFaviconDriver::FromWebContents( |
| 117 restored_tab.contents()); | 117 restored_tab.contents()); |
| 118 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); | 118 // |favicon_driver| might be null when testing. |
| 119 if (favicon_driver) |
| 120 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); |
| 119 } else { | 121 } else { |
| 120 tabs_loading_.insert(&restored_tab.contents()->GetController()); | 122 tabs_loading_.insert(&restored_tab.contents()->GetController()); |
| 121 } | 123 } |
| 122 RegisterForNotifications(&restored_tab.contents()->GetController()); | 124 RegisterForNotifications(&restored_tab.contents()->GetController()); |
| 123 } | 125 } |
| 124 | 126 |
| 125 // When multiple profiles are using the same TabLoader, another profile might | 127 // When multiple profiles are using the same TabLoader, another profile might |
| 126 // already have started loading. In that case, the tabs scheduled for loading | 128 // already have started loading. In that case, the tabs scheduled for loading |
| 127 // by this profile are already in the loading queue, and they will get loaded | 129 // by this profile are already in the loading queue, and they will get loaded |
| 128 // eventually. | 130 // eventually. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // memory pressure. | 292 // memory pressure. |
| 291 stats_collector_->DeferTab(tab); | 293 stats_collector_->DeferTab(tab); |
| 292 } | 294 } |
| 293 // By calling |LoadNextTab| explicitly, we make sure that the | 295 // By calling |LoadNextTab| explicitly, we make sure that the |
| 294 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 296 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
| 295 LoadNextTab(); | 297 LoadNextTab(); |
| 296 } | 298 } |
| 297 | 299 |
| 298 // static | 300 // static |
| 299 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 301 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
| OLD | NEW |