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

Side by Side Diff: chrome/browser/resource_coordinator/tab_manager.cc

Issue 2930013005: [Tab Metrics] Measure FP, FCP and FMP for Foreground Tab during Session Restore (Closed)
Patch Set: Revise session restore start signal. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/resource_coordinator/tab_manager.h" 5 #include "chrome/browser/resource_coordinator/tab_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 TabManager::TabManager() 137 TabManager::TabManager()
138 : discard_count_(0), 138 : discard_count_(0),
139 recent_tab_discard_(false), 139 recent_tab_discard_(false),
140 discard_once_(false), 140 discard_once_(false),
141 #if !defined(OS_CHROMEOS) 141 #if !defined(OS_CHROMEOS)
142 minimum_protection_time_(base::TimeDelta::FromMinutes(10)), 142 minimum_protection_time_(base::TimeDelta::FromMinutes(10)),
143 #endif 143 #endif
144 browser_tab_strip_tracker_(this, nullptr, this), 144 browser_tab_strip_tracker_(this, nullptr, this),
145 test_tick_clock_(nullptr), 145 test_tick_clock_(nullptr),
146 is_session_restore_loading_tabs_(false), 146 is_session_restore_loading_tabs_(false),
147 initial_session_restore_foreground_tab_changed_(false),
147 weak_ptr_factory_(this) { 148 weak_ptr_factory_(this) {
148 #if defined(OS_CHROMEOS) 149 #if defined(OS_CHROMEOS)
149 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr())); 150 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr()));
150 #endif 151 #endif
151 browser_tab_strip_tracker_.Init(); 152 browser_tab_strip_tracker_.Init();
152 session_restore_observer_.reset(new TabManagerSessionRestoreObserver(this)); 153 session_restore_observer_.reset(new TabManagerSessionRestoreObserver(this));
153 } 154 }
154 155
155 TabManager::~TabManager() { 156 TabManager::~TabManager() {
156 Stop(); 157 Stop();
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // Being more recently active is more important. 476 // Being more recently active is more important.
476 return first.last_active > second.last_active; 477 return first.last_active > second.last_active;
477 } 478 }
478 479
479 // static 480 // static
480 int64_t TabManager::IdFromWebContents(WebContents* web_contents) { 481 int64_t TabManager::IdFromWebContents(WebContents* web_contents) {
481 return reinterpret_cast<int64_t>(web_contents); 482 return reinterpret_cast<int64_t>(web_contents);
482 } 483 }
483 484
484 void TabManager::OnSessionRestoreStartedLoadingTabs() { 485 void TabManager::OnSessionRestoreStartedLoadingTabs() {
485 DCHECK(!is_session_restore_loading_tabs_);
486 is_session_restore_loading_tabs_ = true; 486 is_session_restore_loading_tabs_ = true;
487
488 // Needs to reset this flag for each session restore.
489 initial_session_restore_foreground_tab_changed_ = false;
487 } 490 }
488 491
489 void TabManager::OnSessionRestoreFinishedLoadingTabs() { 492 void TabManager::OnSessionRestoreFinishedLoadingTabs() {
490 DCHECK(is_session_restore_loading_tabs_); 493 DCHECK(is_session_restore_loading_tabs_);
491 is_session_restore_loading_tabs_ = false; 494 is_session_restore_loading_tabs_ = false;
492 } 495 }
493 496
494 /////////////////////////////////////////////////////////////////////////////// 497 ///////////////////////////////////////////////////////////////////////////////
495 // TabManager, private: 498 // TabManager, private:
496 499
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 822 }
820 823
821 // An active tab is not purged. 824 // An active tab is not purged.
822 GetWebContentsData(new_contents)->set_is_purged(false); 825 GetWebContentsData(new_contents)->set_is_purged(false);
823 826
824 // Reload |web_contents| if it is in an active browser and discarded. 827 // Reload |web_contents| if it is in an active browser and discarded.
825 if (IsActiveWebContentsInActiveBrowser(new_contents)) { 828 if (IsActiveWebContentsInActiveBrowser(new_contents)) {
826 ReloadWebContentsIfDiscarded(new_contents, 829 ReloadWebContentsIfDiscarded(new_contents,
827 GetWebContentsData(new_contents)); 830 GetWebContentsData(new_contents));
828 } 831 }
832
833 if (old_contents && !initial_session_restore_foreground_tab_changed_) {
834 initial_session_restore_foreground_tab_changed_ = true;
835 }
829 } 836 }
830 837
831 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model, 838 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model,
832 content::WebContents* contents, 839 content::WebContents* contents,
833 int index, 840 int index,
834 bool foreground) { 841 bool foreground) {
835 // Only interested in background tabs, as foreground tabs get taken care of by 842 // Only interested in background tabs, as foreground tabs get taken care of by
836 // ActiveTabChanged. 843 // ActiveTabChanged.
837 if (foreground) 844 if (foreground)
838 return; 845 return;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 962
956 void TabManager::RecordSwitchToTab(content::WebContents* contents) const { 963 void TabManager::RecordSwitchToTab(content::WebContents* contents) const {
957 if (is_session_restore_loading_tabs_) { 964 if (is_session_restore_loading_tabs_) {
958 UMA_HISTOGRAM_ENUMERATION("TabManager.SessionRestore.SwitchToTab", 965 UMA_HISTOGRAM_ENUMERATION("TabManager.SessionRestore.SwitchToTab",
959 GetWebContentsData(contents)->tab_loading_state(), 966 GetWebContentsData(contents)->tab_loading_state(),
960 TAB_LOADING_STATE_MAX); 967 TAB_LOADING_STATE_MAX);
961 } 968 }
962 } 969 }
963 970
964 } // namespace resource_coordinator 971 } // namespace resource_coordinator
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698