Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Side by Side Diff: chrome/browser/sessions/session_restore_delegate.cc

Issue 1136523004: [Sessions] Add detailed logging of SessionRestore events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor and rebase. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started);
69
70 // Restore the favicon for all tabs. Any tab may end up being deferred due
71 // to memory pressure so it's best to have some visual indication of its
72 // contents.
73 for (auto& restored_tab : tabs) {
74 // Restore the favicon for deferred tabs.
75 favicon::ContentFaviconDriver* favicon_driver =
76 favicon::ContentFaviconDriver::FromWebContents(
77 restored_tab.contents());
78 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL());
79 }
80
68 // This experiment allows us to have comparative numbers for session restore 81 // This experiment allows us to have comparative numbers for session restore
69 // metrics. It will be removed once those numbers are obtained. 82 // metrics. It will be removed once those numbers are obtained.
70 // TODO(georgesak): Remove this experiment when stats are collected. 83 // TODO(georgesak): Remove this experiment when stats are collected.
71 base::FieldTrial* trial = 84 base::FieldTrial* trial =
72 base::FieldTrialList::Find("IntelligentSessionRestore"); 85 base::FieldTrialList::Find("IntelligentSessionRestore");
73 if (!trial || trial->group_name() != "DontRestoreBackgroundTabs") { 86 if (!trial || trial->group_name() != "DontRestoreBackgroundTabs") {
74 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started);
75 TabLoader::RestoreTabs(tabs, restore_started); 87 TabLoader::RestoreTabs(tabs, restore_started);
76 } else { 88 } else {
77 SessionRestoreStatsCollector::TrackActiveTabs(tabs, restore_started);
78 for (auto& restored_tab : tabs) { 89 for (auto& restored_tab : tabs) {
79 if (!restored_tab.is_active()) { 90 if (!restored_tab.is_active()) {
80 favicon::ContentFaviconDriver* favicon_driver = 91 // Non-active tabs aren't being loaded, so mark them as deferred.
81 favicon::ContentFaviconDriver::FromWebContents( 92 auto tab_controller = &restored_tab.contents()->GetController();
82 restored_tab.contents()); 93 SessionRestoreStatsCollector::DeferTab(tab_controller);
sky 2015/05/14 15:47:04 I would rather not expose a bunch of static functi
chrisha 2015/05/14 21:27:02 This is an edge case. When memory pressure fires t
sky 2015/05/14 21:51:50 I don't think deferred belongs in RestoredTab as i
83 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL());
84 } 94 }
85 } 95 }
86 } 96 }
87 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698