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

Side by Side Diff: chrome/browser/sessions/tab_loader.cc

Issue 2935183002: [TabMetrics] Add signals that mark the start and end of session restore. (Closed)
Patch Set: Store global SessionRestoreObserver list into a separate class. 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/sessions/tab_loader.h" 5 #include "chrome/browser/sessions/tab_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/memory_coordinator_client_registry.h" 10 #include "base/memory/memory_coordinator_client_registry.h"
11 #include "base/memory/memory_coordinator_proxy.h" 11 #include "base/memory/memory_coordinator_proxy.h"
12 #include "base/memory/memory_pressure_monitor.h" 12 #include "base/memory/memory_pressure_monitor.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/sessions/session_restore_observer.h"
16 #include "chrome/browser/sessions/session_restore_stats_collector.h" 17 #include "chrome/browser/sessions/session_restore_stats_collector.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_finder.h" 19 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "components/favicon/content/content_favicon_driver.h" 21 #include "components/favicon/content/content_favicon_driver.h"
21 #include "components/variations/variations_associated_data.h" 22 #include "components/variations/variations_associated_data.h"
22 #include "content/public/browser/navigation_controller.h" 23 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/render_widget_host.h" 26 #include "content/public/browser/render_widget_host.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 loading_enabled_(true), 97 loading_enabled_(true),
97 started_to_load_count_(0), 98 started_to_load_count_(0),
98 restore_started_(restore_started) { 99 restore_started_(restore_started) {
99 stats_collector_ = new SessionRestoreStatsCollector( 100 stats_collector_ = new SessionRestoreStatsCollector(
100 restore_started, 101 restore_started,
101 base::MakeUnique< 102 base::MakeUnique<
102 SessionRestoreStatsCollector::UmaStatsReportingDelegate>()); 103 SessionRestoreStatsCollector::UmaStatsReportingDelegate>());
103 shared_tab_loader_ = this; 104 shared_tab_loader_ = this;
104 this_retainer_ = this; 105 this_retainer_ = this;
105 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); 106 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
107 for (auto* observer : *SessionRestoreObserver::observers())
lpy 2017/06/23 22:35:57 Once use base::ObserverList, this should be auto&
ducbui 2017/06/23 23:30:15 Done.
108 observer->OnTabLoadingStarted();
106 } 109 }
107 110
108 TabLoader::~TabLoader() { 111 TabLoader::~TabLoader() {
109 DCHECK(tabs_loading_.empty() && tabs_to_load_.empty()); 112 DCHECK(tabs_loading_.empty() && tabs_to_load_.empty());
110 DCHECK(shared_tab_loader_ == this); 113 DCHECK(shared_tab_loader_ == this);
111 shared_tab_loader_ = nullptr; 114 shared_tab_loader_ = nullptr;
112 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); 115 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
116 for (auto* observer : *SessionRestoreObserver::observers())
117 observer->OnTabLoadingEnded();
113 } 118 }
114 119
115 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) { 120 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) {
116 // Add the tabs to the list of tabs loading/to load and register them for 121 // Add the tabs to the list of tabs loading/to load and register them for
117 // notifications. Also, restore the favicons of the background tabs (the title 122 // notifications. Also, restore the favicons of the background tabs (the title
118 // has already been set by now).This avoids having blank icons in case the 123 // has already been set by now).This avoids having blank icons in case the
119 // restore is halted due to memory pressure. Also, when multiple tabs are 124 // restore is halted due to memory pressure. Also, when multiple tabs are
120 // restored to a single window, the title may not appear, and the user will 125 // restored to a single window, the title may not appear, and the user will
121 // have no way of finding out which tabs corresponds to which page if the icon 126 // have no way of finding out which tabs corresponds to which page if the icon
122 // is a generic grey one. 127 // is a generic grey one.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // memory pressure. 313 // memory pressure.
309 stats_collector_->DeferTab(tab); 314 stats_collector_->DeferTab(tab);
310 } 315 }
311 // By calling |LoadNextTab| explicitly, we make sure that the 316 // By calling |LoadNextTab| explicitly, we make sure that the
312 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. 317 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent.
313 LoadNextTab(); 318 LoadNextTab();
314 } 319 }
315 320
316 // static 321 // static
317 TabLoader* TabLoader::shared_tab_loader_ = nullptr; 322 TabLoader* TabLoader::shared_tab_loader_ = nullptr;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698