| 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/session_restore_delegate.h" | 5 #include "chrome/browser/sessions/session_restore_delegate.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "chrome/browser/sessions/session_restore_stats_collector.h" | 8 #include "chrome/browser/sessions/session_restore_stats_collector.h" |
| 9 #include "chrome/browser/sessions/tab_loader.h" | 9 #include "chrome/browser/sessions/tab_loader.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 if (is_app_ != right.is_app_) | 58 if (is_app_ != right.is_app_) |
| 59 return is_app_; | 59 return is_app_; |
| 60 // TODO(georgesak): Add criterion based on recency. | 60 // TODO(georgesak): Add criterion based on recency. |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 void SessionRestoreDelegate::RestoreTabs( | 65 void SessionRestoreDelegate::RestoreTabs( |
| 66 const std::vector<RestoredTab>& tabs, | 66 const std::vector<RestoredTab>& tabs, |
| 67 const base::TimeTicks& restore_started) { | 67 const base::TimeTicks& restore_started) { |
| 68 // Restore the favicon for all tabs. Any tab may end up being deferred due |
| 69 // to memory pressure so it's best to have some visual indication of its |
| 70 // contents. |
| 71 for (auto& restored_tab : tabs) { |
| 72 // Restore the favicon for deferred tabs. |
| 73 favicon::ContentFaviconDriver* favicon_driver = |
| 74 favicon::ContentFaviconDriver::FromWebContents( |
| 75 restored_tab.contents()); |
| 76 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); |
| 77 } |
| 78 |
| 68 // This experiment allows us to have comparative numbers for session restore | 79 // This experiment allows us to have comparative numbers for session restore |
| 69 // metrics. It will be removed once those numbers are obtained. | 80 // metrics. It will be removed once those numbers are obtained. |
| 70 // TODO(georgesak): Remove this experiment when stats are collected. | 81 // TODO(georgesak): Remove this experiment when stats are collected. |
| 71 base::FieldTrial* trial = | 82 base::FieldTrial* trial = |
| 72 base::FieldTrialList::Find("IntelligentSessionRestore"); | 83 base::FieldTrialList::Find("IntelligentSessionRestore"); |
| 73 if (!trial || trial->group_name() != "DontRestoreBackgroundTabs") { | 84 if (!trial || trial->group_name() != "DontRestoreBackgroundTabs") { |
| 74 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started); | |
| 75 TabLoader::RestoreTabs(tabs, restore_started); | 85 TabLoader::RestoreTabs(tabs, restore_started); |
| 76 } else { | 86 } else { |
| 77 SessionRestoreStatsCollector::TrackActiveTabs(tabs, restore_started); | 87 // A TabLoader will not be used for this session restore, so manually create |
| 88 // and use a SessionRestoreStatsCollector, normally owned by the TabLoader. |
| 89 scoped_refptr<SessionRestoreStatsCollector> stats_collector = |
| 90 new SessionRestoreStatsCollector(restore_started); |
| 91 stats_collector->TrackTabs(tabs); |
| 78 for (auto& restored_tab : tabs) { | 92 for (auto& restored_tab : tabs) { |
| 79 if (!restored_tab.is_active()) { | 93 if (!restored_tab.is_active()) { |
| 80 favicon::ContentFaviconDriver* favicon_driver = | 94 // Non-active tabs aren't being loaded, so mark them as deferred. |
| 81 favicon::ContentFaviconDriver::FromWebContents( | 95 auto tab_controller = &restored_tab.contents()->GetController(); |
| 82 restored_tab.contents()); | 96 stats_collector->DeferTab(tab_controller); |
| 83 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); | |
| 84 } | 97 } |
| 85 } | 98 } |
| 86 } | 99 } |
| 87 } | 100 } |
| OLD | NEW |