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

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: Created 3 years, 6 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
« no previous file with comments | « chrome/browser/sessions/tab_loader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser_process.h"
17 #include "chrome/browser/resource_coordinator/tab_manager.h"
16 #include "chrome/browser/sessions/session_restore_stats_collector.h" 18 #include "chrome/browser/sessions/session_restore_stats_collector.h"
17 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "components/favicon/content/content_favicon_driver.h" 22 #include "components/favicon/content/content_favicon_driver.h"
21 #include "components/variations/variations_associated_data.h" 23 #include "components/variations/variations_associated_data.h"
22 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/render_widget_host.h" 27 #include "content/public/browser/render_widget_host.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 loading_enabled_(true), 98 loading_enabled_(true),
97 started_to_load_count_(0), 99 started_to_load_count_(0),
98 restore_started_(restore_started) { 100 restore_started_(restore_started) {
99 stats_collector_ = new SessionRestoreStatsCollector( 101 stats_collector_ = new SessionRestoreStatsCollector(
100 restore_started, 102 restore_started,
101 base::MakeUnique< 103 base::MakeUnique<
102 SessionRestoreStatsCollector::UmaStatsReportingDelegate>()); 104 SessionRestoreStatsCollector::UmaStatsReportingDelegate>());
103 shared_tab_loader_ = this; 105 shared_tab_loader_ = this;
104 this_retainer_ = this; 106 this_retainer_ = this;
105 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); 107 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
108 MarkSessionRestoreStarted();
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 MarkSessionRestoreEnded();
113 } 117 }
114 118
115 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) { 119 void TabLoader::StartLoading(const std::vector<RestoredTab>& tabs) {
116 // Add the tabs to the list of tabs loading/to load and register them for 120 // 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 121 // 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 122 // 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 123 // 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 124 // 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 125 // have no way of finding out which tabs corresponds to which page if the icon
122 // is a generic grey one. 126 // is a generic grey one.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // Notify the stats collector that a tab's loading has been deferred due to 311 // Notify the stats collector that a tab's loading has been deferred due to
308 // memory pressure. 312 // memory pressure.
309 stats_collector_->DeferTab(tab); 313 stats_collector_->DeferTab(tab);
310 } 314 }
311 // By calling |LoadNextTab| explicitly, we make sure that the 315 // By calling |LoadNextTab| explicitly, we make sure that the
312 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. 316 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent.
313 LoadNextTab(); 317 LoadNextTab();
314 } 318 }
315 319
316 // static 320 // static
321 void TabLoader::MarkSessionRestoreStarted() {
322 resource_coordinator::TabManager* tab_manager =
323 g_browser_process->GetTabManager();
324 if (tab_manager)
fmeawad 2017/06/14 15:34:58 Can this be a DCHECK instead? Similar to here mayb
fmeawad 2017/06/14 16:20:56 This is why we put the DCHECK, if the check is alw
ducbui 2017/06/14 16:24:18 Is the usage of TabLoader limited to only tab-mana
ducbui 2017/06/14 16:47:39 The TabLoader is not compiled on Android and on Ch
325 tab_manager->MarkSessionRestoreStarted();
326 }
327
328 // static
329 void TabLoader::MarkSessionRestoreEnded() {
330 resource_coordinator::TabManager* tab_manager =
331 g_browser_process->GetTabManager();
332 if (tab_manager)
333 tab_manager->MarkSessionRestoreEnded();
334 }
335
336 // static
317 TabLoader* TabLoader::shared_tab_loader_ = nullptr; 337 TabLoader* TabLoader::shared_tab_loader_ = nullptr;
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698