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

Unified Diff: chrome/browser/sessions/session_restore.cc

Issue 2930013005: [Tab Metrics] Measure FP, FCP and FMP for Foreground Tab during Session Restore (Closed)
Patch Set: Add RemoveFromWebContents() to RestoreOrigin. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/session_restore.cc
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index db3bc9ddab8a9348e27653a3fe120d85e023bf33..9d5ca3a4dd6b8f914aa9e435be0e5a0af54bece7 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -91,6 +91,27 @@ std::set<SessionRestoreImpl*>* active_session_restorers = nullptr;
} // namespace
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(RestoreOrigin);
+
+// static
+void RestoreOrigin::CreateForWebContents(content::WebContents* contents,
+ RestoreOrigin::Type type) {
+ DCHECK(contents);
+ if (!FromWebContents(contents))
+ contents->SetUserData(UserDataKey(),
+ base::WrapUnique(new RestoreOrigin(type)));
+}
+
+// static
+void RestoreOrigin::RemoveFromWebContents(content::WebContents* contents) {
+ if (FromWebContents(contents))
+ contents->RemoveUserData(UserDataKey());
+}
+
+RestoreOrigin::RestoreOrigin(RestoreOrigin::Type type) : type_(type) {}
+
+RestoreOrigin::~RestoreOrigin() = default;
+
// SessionRestoreImpl ---------------------------------------------------------
// SessionRestoreImpl is responsible for fetching the set of tabs to create
@@ -616,7 +637,8 @@ class SessionRestoreImpl : public content::NotificationObserver {
WebContents* web_contents = chrome::AddRestoredTab(
browser, tab.navigations, tab_index, selected_index,
tab.extension_app_id, is_selected_tab, tab.pinned, true,
- session_storage_namespace.get(), tab.user_agent_override);
+ session_storage_namespace.get(), tab.user_agent_override,
+ RestoreOrigin::Type::SESSION_RESTORE);
// Regression check: if the current tab |is_selected_tab|, it should load
// immediately, otherwise, tabs should not start loading right away. The
// focused tab will be loaded by Browser, and TabLoader will load the rest.

Powered by Google App Engine
This is Rietveld 408576698