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

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

Issue 2727663004: Use TabLoader in TabRestoreService. (Closed)
Patch Set: Fix review notes: comments, namings etc. Created 3 years, 10 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
« no previous file with comments | « chrome/browser/sessions/tab_loader.h ('k') | chrome/browser/sessions/tab_restore_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/tab_loader.cc
diff --git a/chrome/browser/sessions/tab_loader.cc b/chrome/browser/sessions/tab_loader.cc
index ef4c3cdeb8b3102d9f7d85ec609fa0fefffc4911..753f4e0493c23ad66dc15e7f1f37a6574ce3f7e1 100644
--- a/chrome/browser/sessions/tab_loader.cc
+++ b/chrome/browser/sessions/tab_loader.cc
@@ -31,6 +31,12 @@ using content::NavigationController;
using content::RenderWidgetHost;
using content::WebContents;
+namespace {
+
+size_t g_max_loaded_tab_count_for_testing = 0;
+
+} // namespace
+
void TabLoader::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -78,11 +84,17 @@ void TabLoader::RestoreTabs(const std::vector<RestoredTab>& tabs,
shared_tab_loader_->StartLoading(tabs);
}
+// static
+void TabLoader::SetMaxLoadedTabCountForTest(size_t value) {
+ g_max_loaded_tab_count_for_testing = value;
+}
+
TabLoader::TabLoader(base::TimeTicks restore_started)
: memory_pressure_listener_(
base::Bind(&TabLoader::OnMemoryPressure, base::Unretained(this))),
force_load_delay_multiplier_(1),
loading_enabled_(true),
+ started_to_load_count_(0),
restore_started_(restore_started) {
stats_collector_ = new SessionRestoreStatsCollector(
restore_started,
@@ -118,6 +130,7 @@ void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) {
if (favicon_driver)
favicon_driver->FetchFavicon(favicon_driver->GetActiveURL());
} else {
+ ++started_to_load_count_;
tabs_loading_.insert(&restored_tab.contents()->GetController());
}
RegisterForNotifications(&restored_tab.contents()->GetController());
@@ -168,6 +181,7 @@ void TabLoader::LoadNextTab() {
NavigationController* controller = tabs_to_load_.front();
DCHECK(controller);
+ ++started_to_load_count_;
tabs_loading_.insert(controller);
tabs_to_load_.pop_front();
controller->LoadIfNecessary();
@@ -242,6 +256,9 @@ void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) {
}
bool TabLoader::ShouldStopLoadingTabs() const {
+ if (g_max_loaded_tab_count_for_testing != 0 &&
+ started_to_load_count_ >= g_max_loaded_tab_count_for_testing)
+ return true;
if (base::FeatureList::IsEnabled(features::kMemoryCoordinator))
return base::MemoryCoordinatorProxy::GetInstance()->GetCurrentMemoryState()
!= base::MemoryState::NORMAL;
« no previous file with comments | « chrome/browser/sessions/tab_loader.h ('k') | chrome/browser/sessions/tab_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698