Index: chrome/browser/sessions/session_restore_stats_collector.h |
diff --git a/chrome/browser/sessions/session_restore_stats_collector.h b/chrome/browser/sessions/session_restore_stats_collector.h |
index c312b404383a4530c356063b8acd35f0cd2ed9fd..54d740143b9dc68f1f3a2084be97fef167c4bf86 100644 |
--- a/chrome/browser/sessions/session_restore_stats_collector.h |
+++ b/chrome/browser/sessions/session_restore_stats_collector.h |
@@ -5,6 +5,7 @@ |
#ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ |
#define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_STATS_COLLECTOR_H_ |
+#include <map> |
#include <set> |
#include "base/callback_list.h" |
@@ -30,6 +31,11 @@ class SessionRestoreStatsCollector |
const std::vector<SessionRestoreDelegate::RestoredTab>& tabs, |
const base::TimeTicks& restore_started); |
+ // Called to indicate that the loading of a tab has been deferred by session |
+ // restore. If the reason for the deferral was memory pressure this will be |
+ // recorded. |
+ static void DeferTab(content::NavigationController* tab); |
+ |
private: |
friend class base::RefCounted<SessionRestoreStatsCollector>; |
@@ -46,8 +52,13 @@ class SessionRestoreStatsCollector |
// Adds new tabs to the list of tracked tabs. |
void AddTabs(const std::vector<SessionRestoreDelegate::RestoredTab>& tabs); |
- // Called when a tab is no longer tracked. |
- void RemoveTab(content::NavigationController* tab); |
+ // Called to indicate that the loading of a tab has been deferred by session |
+ // restore. Called by the static DeferTab. |
+ void DeferTabImpl(content::NavigationController* tab); |
+ |
+ // Called when a tab is no longer tracked. This is called by the 'Observe' |
+ // notification callback. |
+ void RemoveTab(bool is_deferred, content::NavigationController* tab); |
// Registers for relevant notifications for a tab. |
void RegisterForNotifications(content::NavigationController* tab); |
@@ -56,6 +67,10 @@ class SessionRestoreStatsCollector |
content::RenderWidgetHost* GetRenderWidgetHost( |
content::NavigationController* tab); |
+ // Returns true if the specified tab had it's loading deferred by an active |
+ // session restore. |
+ bool IsDeferred(content::NavigationController* tab); |
+ |
// Have we recorded the times for a foreground tab load? |
bool got_first_foreground_load_; |
@@ -71,12 +86,30 @@ class SessionRestoreStatsCollector |
// The renderers we have loaded and are waiting on to paint. |
RenderWidgetHostSet render_widget_hosts_to_paint_; |
- // List of tracked tabs. |
- std::set<content::NavigationController*> tabs_tracked_; |
+ // List of tracked tabs. Each tab is associated with the automatically |
+ // assigned ID of the ongoing session restore that created the tab. |
+ std::map<content::NavigationController*, int> tabs_tracked_; |
+ |
+ // List of deferred tabs. Each tab is associated with its session restore ID, |
+ // as with tabs_tracked_. |
+ std::map<content::NavigationController*, int> tabs_deferred_; |
- // The number of tabs that have been restored. |
+ // A set of session restore IDs that have had tabs deferred. Absence from this |
+ // set means the session restore did not defer any tabs. |
+ std::set<int> deferred_tabs_seen_; |
+ |
+ // The number of tabs that have been restored. This is across all overlapping |
+ // session restores. |
int tab_count_; |
+ // The number of tabs that have been deferred. This is across all overlapping |
+ // session restores. |
+ int tab_deferred_count_; |
+ |
+ // The ID of the most recently initiated session restore. Incremented by |
+ // calls to AddTabs. |
+ int session_restore_id_; |
+ |
// Max number of tabs that were loaded in parallel (for metrics). |
size_t max_parallel_tab_loads_; |