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

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: Fix tab_manager null on Android. 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DCHECK(!is_session_restore_loading_tabs_);
486 is_session_restore_loading_tabs_ = true; 487 is_session_restore_loading_tabs_ = true;
488
489 // Needs to reset this flag for each session restore.
490 initial_session_restore_foreground_tab_changed_ = false;
487 } 491 }
488 492
489 void TabManager::OnSessionRestoreFinishedLoadingTabs() { 493 void TabManager::OnSessionRestoreFinishedLoadingTabs() {
490 DCHECK(is_session_restore_loading_tabs_); 494 DCHECK(is_session_restore_loading_tabs_);
491 is_session_restore_loading_tabs_ = false; 495 is_session_restore_loading_tabs_ = false;
492 } 496 }
493 497
494 /////////////////////////////////////////////////////////////////////////////// 498 ///////////////////////////////////////////////////////////////////////////////
495 // TabManager, private: 499 // TabManager, private:
496 500
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 823 }
820 824
821 // An active tab is not purged. 825 // An active tab is not purged.
822 GetWebContentsData(new_contents)->set_is_purged(false); 826 GetWebContentsData(new_contents)->set_is_purged(false);
823 827
824 // Reload |web_contents| if it is in an active browser and discarded. 828 // Reload |web_contents| if it is in an active browser and discarded.
825 if (IsActiveWebContentsInActiveBrowser(new_contents)) { 829 if (IsActiveWebContentsInActiveBrowser(new_contents)) {
826 ReloadWebContentsIfDiscarded(new_contents, 830 ReloadWebContentsIfDiscarded(new_contents,
827 GetWebContentsData(new_contents)); 831 GetWebContentsData(new_contents));
828 } 832 }
833
834 if (old_contents && !initial_session_restore_foreground_tab_changed_) {
835 initial_session_restore_foreground_tab_changed_ = true;
836 }
829 } 837 }
830 838
831 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model, 839 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model,
832 content::WebContents* contents, 840 content::WebContents* contents,
833 int index, 841 int index,
834 bool foreground) { 842 bool foreground) {
835 // Only interested in background tabs, as foreground tabs get taken care of by 843 // Only interested in background tabs, as foreground tabs get taken care of by
836 // ActiveTabChanged. 844 // ActiveTabChanged.
837 if (foreground) 845 if (foreground)
838 return; 846 return;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 963
956 void TabManager::RecordSwitchToTab(content::WebContents* contents) const { 964 void TabManager::RecordSwitchToTab(content::WebContents* contents) const {
957 if (is_session_restore_loading_tabs_) { 965 if (is_session_restore_loading_tabs_) {
958 UMA_HISTOGRAM_ENUMERATION("TabManager.SessionRestore.SwitchToTab", 966 UMA_HISTOGRAM_ENUMERATION("TabManager.SessionRestore.SwitchToTab",
959 GetWebContentsData(contents)->tab_loading_state(), 967 GetWebContentsData(contents)->tab_loading_state(),
960 TAB_LOADING_STATE_MAX); 968 TAB_LOADING_STATE_MAX);
961 } 969 }
962 } 970 }
963 971
964 } // namespace resource_coordinator 972 } // namespace resource_coordinator
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698