Commit 6f901938 authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Move the initialization of TabLifecycleUnitSource out of the constructor

On CrOS the global performance manager instance isn't available when
this gets created.

Change-Id: I082a1fae17665f10eab87a211157d4c969d1d238
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1704716Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678365}
parent 5f1aeb93
...@@ -116,10 +116,14 @@ TabLifecycleUnitSource::TabLifecycleUnitSource( ...@@ -116,10 +116,14 @@ TabLifecycleUnitSource::TabLifecycleUnitSource(
// instantiated. No TabLifecycleUnit is created for these tabs. // instantiated. No TabLifecycleUnit is created for these tabs.
DCHECK(intervention_policy_database_); DCHECK(intervention_policy_database_);
browser_tab_strip_tracker_.Init(); browser_tab_strip_tracker_.Init();
}
TabLifecycleUnitSource::~TabLifecycleUnitSource() = default;
auto* perf_man = performance_manager::PerformanceManager::GetInstance(); void TabLifecycleUnitSource::Start() {
if (perf_man) { if (auto* perf_man = performance_manager::PerformanceManager::GetInstance()) {
// The performance manager dies on its own sequence, so posting unretained // The performance manager dies on its own sequence, so posting unretained
// is fine. // is fine.
perf_man->CallOnGraph( perf_man->CallOnGraph(
...@@ -133,8 +137,6 @@ TabLifecycleUnitSource::TabLifecycleUnitSource( ...@@ -133,8 +137,6 @@ TabLifecycleUnitSource::TabLifecycleUnitSource(
} }
} }
TabLifecycleUnitSource::~TabLifecycleUnitSource() = default;
// static // static
TabLifecycleUnitExternal* TabLifecycleUnitSource::GetTabLifecycleUnitExternal( TabLifecycleUnitExternal* TabLifecycleUnitSource::GetTabLifecycleUnitExternal(
content::WebContents* web_contents) { content::WebContents* web_contents) {
......
...@@ -46,6 +46,10 @@ class TabLifecycleUnitSource : public BrowserListObserver, ...@@ -46,6 +46,10 @@ class TabLifecycleUnitSource : public BrowserListObserver,
UsageClock* usage_clock); UsageClock* usage_clock);
~TabLifecycleUnitSource() override; ~TabLifecycleUnitSource() override;
// Should be called once all the dependencies of this class have been created
// (e.g. the global PerformanceManager instance).
void Start();
// Returns the TabLifecycleUnitExternal instance associated with // Returns the TabLifecycleUnitExternal instance associated with
// |web_contents|, or nullptr if |web_contents| isn't a tab. // |web_contents|, or nullptr if |web_contents| isn't a tab.
static TabLifecycleUnitExternal* GetTabLifecycleUnitExternal( static TabLifecycleUnitExternal* GetTabLifecycleUnitExternal(
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "chrome/browser/performance_manager/performance_manager.h" #include "chrome/browser/performance_manager/performance_manager.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/background_tab_navigation_throttle.h" #include "chrome/browser/resource_coordinator/background_tab_navigation_throttle.h"
#include "chrome/browser/resource_coordinator/resource_coordinator_parts.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h" #include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
#include "chrome/browser/resource_coordinator/tab_manager.h" #include "chrome/browser/resource_coordinator/tab_manager.h"
#include "chrome/browser/resource_coordinator/tab_manager_features.h" #include "chrome/browser/resource_coordinator/tab_manager_features.h"
...@@ -222,6 +223,10 @@ void TabManager::Start() { ...@@ -222,6 +223,10 @@ void TabManager::Start() {
std::make_unique<ResourceCoordinatorSignalObserver>( std::make_unique<ResourceCoordinatorSignalObserver>(
weak_ptr_factory_.GetWeakPtr()))); weak_ptr_factory_.GetWeakPtr())));
} }
g_browser_process->resource_coordinator_parts()
->tab_lifecycle_unit_source()
->Start();
} }
LifecycleUnitVector TabManager::GetSortedLifecycleUnits() { LifecycleUnitVector TabManager::GetSortedLifecycleUnits() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment