OLD | NEW |
---|---|
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/session_restore_stats_collector.h" | 5 #include "chrome/browser/sessions/session_restore_stats_collector.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
12 #include "content/public/browser/notification_types.h" | 12 #include "content/public/browser/notification_types.h" |
13 #include "content/public/browser/render_widget_host_view.h" | 13 #include "content/public/browser/render_widget_host_view.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 | 15 |
16 using content::NavigationController; | 16 using content::NavigationController; |
17 using content::RenderWidgetHost; | 17 using content::RenderWidgetHost; |
18 using content::WebContents; | 18 using content::WebContents; |
19 | 19 |
20 namespace { | |
21 | |
22 // Metric names. | |
23 const char kSessionRestoreActions[] = "SessionRestore.Actions"; | |
24 const char kSessionRestoreTabCount[] = "SessionRestore.TabCount"; | |
25 const char kSessionRestoreTabActions[] = "SessionRestore.TabActions"; | |
26 | |
27 // The enumeration values stored in the kSessionRestoreActions histogram. | |
28 enum SessionRestoreActionsUma { | |
29 // Counts the total number of session restores that have occurred. | |
30 kSessionRestoreActionsUma_Initiated = 0, | |
sky
2015/05/12 15:27:56
SESSION_RESTORE_ACTION_UMA_INITIATED (see chrome s
chrisha
2015/05/13 21:18:01
Done.
| |
31 // Counts the number of session restores that have been deferred tab loadings | |
32 // for whatever reason (almost certainly due to memory pressure). | |
33 kSessionRestoreActionsUma_DeferredTabs = 1, | |
34 // The size of this enum. Must be the last entry. | |
35 kSessionRestoreActionsUma_Max, | |
36 }; | |
37 | |
38 // The enumeration of values stored in the kSessionRestoreTabActions histogram. | |
39 enum SessionRestoreTabActionsUma { | |
40 // Incremented for each tab created in a session restore. | |
41 kSessionRestoreTabActionsUma_TabCreated = 0, | |
42 // Incremented for each tab started to load by the session restore. | |
43 kSessionRestoreTabActionsUma_TabLoading = 1, | |
44 // Incremented for each tab that session restore decides not to load. | |
45 kSessionRestoreTabActionsUma_TabLoadingDeferred = 2, | |
46 // Incremented for each tab that is successfully loaded. | |
47 kSessionRestoreTabActionsUma_TabLoaded = 3, | |
48 // Incremented for each session-restore-deferred tab that subsequently starts | |
49 // to load. | |
50 kSessionRestoreTabActionsUma_DeferredTabLoading = 4, | |
51 // Incremented for each non-deferred not-yet-loaded tab closed by the user. | |
52 kSessionRestoreTabActionsUma_NonDeferredNotLoadingTabClosed = 5, | |
53 // Incremented for each non-deferred actively-loading tab closed by the user. | |
54 kSessionRestoreTabActionsUma_NonDeferredLoadingTabClosed = 6, | |
55 // Incremented for each deferred not-yet-loaded tab closed by the user. | |
56 kSessionRestoreTabActionsUma_DeferredNotLoadingTabClosed = 7, | |
57 // Incremented for each deferred actively-loading tab closed by the user. | |
58 kSessionRestoreTabActionsUma_DeferredLoadingTabClosed = 8, | |
59 // The size of this enum. Must be the last entry. | |
60 kSessionRestoreTabActionsUma_Max, | |
61 }; | |
62 | |
63 } // namespace | |
64 | |
20 // static | 65 // static |
21 void SessionRestoreStatsCollector::TrackTabs( | 66 void SessionRestoreStatsCollector::TrackTabs( |
22 const std::vector<SessionRestoreDelegate::RestoredTab>& tabs, | 67 const std::vector<SessionRestoreDelegate::RestoredTab>& tabs, |
23 const base::TimeTicks& restore_started) { | 68 const base::TimeTicks& restore_started) { |
24 if (!shared_collector_) | 69 if (!shared_collector_) |
25 shared_collector_ = new SessionRestoreStatsCollector(restore_started); | 70 shared_collector_ = new SessionRestoreStatsCollector(restore_started); |
26 | 71 |
27 shared_collector_->AddTabs(tabs); | 72 shared_collector_->AddTabs(tabs); |
28 } | 73 } |
29 | 74 |
75 // static | |
76 void SessionRestoreStatsCollector::DeferTab( | |
77 content::NavigationController* tab) { | |
78 // It only makes sense for this to have been called *after* DeferTab, so a | |
79 // stats collector will always exist. | |
sky
2015/05/12 15:27:56
DCHECK(shared_collector_)
chrisha
2015/05/13 21:18:01
Done.
| |
80 shared_collector_->DeferTabImpl(tab); | |
81 } | |
82 | |
30 SessionRestoreStatsCollector::SessionRestoreStatsCollector( | 83 SessionRestoreStatsCollector::SessionRestoreStatsCollector( |
31 const base::TimeTicks& restore_started) | 84 const base::TimeTicks& restore_started) |
32 : got_first_foreground_load_(false), | 85 : got_first_foreground_load_(false), |
33 got_first_paint_(false), | 86 got_first_paint_(false), |
34 restore_started_(restore_started), | 87 restore_started_(restore_started), |
35 tab_count_(0), | 88 tab_count_(0), |
89 tab_deferred_count_(0), | |
90 session_restore_id_(0), | |
36 max_parallel_tab_loads_(0) { | 91 max_parallel_tab_loads_(0) { |
37 this_retainer_ = this; | 92 this_retainer_ = this; |
38 registrar_.Add( | 93 registrar_.Add( |
39 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, | 94 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, |
40 content::NotificationService::AllSources()); | 95 content::NotificationService::AllSources()); |
41 } | 96 } |
42 | 97 |
43 SessionRestoreStatsCollector::~SessionRestoreStatsCollector() { | 98 SessionRestoreStatsCollector::~SessionRestoreStatsCollector() { |
44 DCHECK((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && | 99 DCHECK((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && |
45 tabs_tracked_.empty() && render_widget_hosts_loading_.empty()); | 100 tabs_tracked_.empty() && render_widget_hosts_loading_.empty()); |
46 DCHECK(shared_collector_ == this); | 101 DCHECK(shared_collector_ == this); |
47 shared_collector_ = nullptr; | 102 shared_collector_ = nullptr; |
48 } | 103 } |
49 | 104 |
50 void SessionRestoreStatsCollector::Observe( | 105 void SessionRestoreStatsCollector::Observe( |
51 int type, | 106 int type, |
52 const content::NotificationSource& source, | 107 const content::NotificationSource& source, |
53 const content::NotificationDetails& details) { | 108 const content::NotificationDetails& details) { |
54 switch (type) { | 109 switch (type) { |
55 case content::NOTIFICATION_LOAD_START: { | 110 case content::NOTIFICATION_LOAD_START: { |
56 // Add this render_widget_host to the set of those we're waiting for | 111 // Add this render_widget_host to the set of those we're waiting for |
57 // paints on. We want to only record stats for paints that occur after | 112 // paints on. We want to only record stats for paints that occur after |
58 // a load has finished. | 113 // a load has finished. |
59 NavigationController* tab = | 114 NavigationController* tab = |
60 content::Source<NavigationController>(source).ptr(); | 115 content::Source<NavigationController>(source).ptr(); |
116 bool is_deferred = IsDeferred(tab); | |
117 | |
118 // Record the appropriate tab loading event type. | |
119 auto tab_action = | |
120 is_deferred ? kSessionRestoreTabActionsUma_TabLoading : | |
121 kSessionRestoreTabActionsUma_DeferredTabLoading; | |
122 UMA_HISTOGRAM_ENUMERATION(kSessionRestoreTabActions, | |
123 tab_action, | |
124 kSessionRestoreTabActionsUma_Max); | |
125 | |
61 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(tab); | 126 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(tab); |
62 DCHECK(render_widget_host); | 127 DCHECK(render_widget_host); |
63 render_widget_hosts_loading_.insert(render_widget_host); | 128 render_widget_hosts_loading_.insert(render_widget_host); |
64 break; | 129 break; |
65 } | 130 } |
66 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { | 131 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { |
67 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 132 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
68 RemoveTab(&web_contents->GetController()); | 133 NavigationController* tab = &web_contents->GetController(); |
134 bool is_deferred = IsDeferred(tab); | |
135 | |
136 // Record a tab action for the tab that is being closed. If this tab is | |
137 // loading it will have a RenderWidgetHost in the tracking set. | |
138 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(tab); | |
139 auto tab_action = kSessionRestoreTabActionsUma_Max; | |
140 if (render_widget_hosts_loading_.count(render_widget_host) > 0) { | |
141 // This tab is loading. | |
142 tab_action = is_deferred ? | |
143 kSessionRestoreTabActionsUma_DeferredLoadingTabClosed : | |
144 kSessionRestoreTabActionsUma_NonDeferredLoadingTabClosed; | |
145 } else { | |
146 // This tab is not loading. | |
147 tab_action = is_deferred ? | |
148 kSessionRestoreTabActionsUma_DeferredNotLoadingTabClosed : | |
149 kSessionRestoreTabActionsUma_NonDeferredNotLoadingTabClosed; | |
150 } | |
151 UMA_HISTOGRAM_ENUMERATION(kSessionRestoreTabActions, | |
152 tab_action, | |
153 kSessionRestoreTabActionsUma_Max); | |
154 | |
155 RemoveTab(is_deferred, tab); | |
69 break; | 156 break; |
70 } | 157 } |
71 case content::NOTIFICATION_LOAD_STOP: { | 158 case content::NOTIFICATION_LOAD_STOP: { |
72 NavigationController* tab = | 159 NavigationController* tab = |
73 content::Source<NavigationController>(source).ptr(); | 160 content::Source<NavigationController>(source).ptr(); |
161 bool is_deferred = IsDeferred(tab); | |
74 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(tab); | 162 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(tab); |
75 render_widget_hosts_to_paint_.insert(render_widget_host); | 163 render_widget_hosts_to_paint_.insert(render_widget_host); |
76 RemoveTab(tab); | 164 |
165 // Note the fact that this tab loaded. | |
166 UMA_HISTOGRAM_ENUMERATION(kSessionRestoreTabActions, | |
167 kSessionRestoreTabActionsUma_TabLoaded, | |
168 kSessionRestoreTabActionsUma_Max); | |
169 | |
170 RemoveTab(is_deferred, tab); | |
171 | |
172 // Update UMA stats for foreground tabs. | |
77 if (!got_first_foreground_load_ && render_widget_host && | 173 if (!got_first_foreground_load_ && render_widget_host && |
78 render_widget_host->GetView() && | 174 render_widget_host->GetView() && |
79 render_widget_host->GetView()->IsShowing()) { | 175 render_widget_host->GetView()->IsShowing()) { |
80 got_first_foreground_load_ = true; | 176 got_first_foreground_load_ = true; |
81 base::TimeDelta time_to_load = | 177 base::TimeDelta time_to_load = |
82 base::TimeTicks::Now() - restore_started_; | 178 base::TimeTicks::Now() - restore_started_; |
83 UMA_HISTOGRAM_CUSTOM_TIMES("SessionRestore.ForegroundTabFirstLoaded", | 179 UMA_HISTOGRAM_CUSTOM_TIMES("SessionRestore.ForegroundTabFirstLoaded", |
sky
2015/05/12 15:27:56
Seems like we should never log this if any tab was
chrisha
2015/05/13 21:18:02
I'm not sure I agree... there will always be at le
sky
2015/05/14 00:12:40
Two cases to consider:
. what happens when you clo
chrisha
2015/05/14 21:27:01
These are concerns regardless of whether or not th
sky
2015/05/14 21:51:50
Fair enough. As long as they get dealt with.
chrisha
2015/05/26 20:00:18
Added a TODO capturing this.
| |
84 time_to_load, | 180 time_to_load, |
85 base::TimeDelta::FromMilliseconds(10), | 181 base::TimeDelta::FromMilliseconds(10), |
86 base::TimeDelta::FromSeconds(100), 100); | 182 base::TimeDelta::FromSeconds(100), 100); |
87 // Record a time for the number of tabs, to help track down | 183 // Record a time for the number of tabs, to help track down |
88 // contention. | 184 // contention. |
89 std::string time_for_count = base::StringPrintf( | 185 std::string time_for_count = base::StringPrintf( |
90 "SessionRestore.ForegroundTabFirstLoaded_%d", tab_count_); | 186 "SessionRestore.ForegroundTabFirstLoaded_%d", tab_count_); |
91 base::HistogramBase* counter_for_count = | 187 base::HistogramBase* counter_for_count = |
92 base::Histogram::FactoryTimeGet( | 188 base::Histogram::FactoryTimeGet( |
93 time_for_count, base::TimeDelta::FromMilliseconds(10), | 189 time_for_count, base::TimeDelta::FromMilliseconds(10), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 | 252 |
157 // Check if we are done and if so, reset |this_retainer_| as the collector no | 253 // Check if we are done and if so, reset |this_retainer_| as the collector no |
158 // longer needs to stay alive. | 254 // longer needs to stay alive. |
159 if ((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && | 255 if ((got_first_paint_ || render_widget_hosts_to_paint_.empty()) && |
160 tabs_tracked_.empty() && render_widget_hosts_loading_.empty()) | 256 tabs_tracked_.empty() && render_widget_hosts_loading_.empty()) |
161 this_retainer_ = nullptr; | 257 this_retainer_ = nullptr; |
162 } | 258 } |
163 | 259 |
164 void SessionRestoreStatsCollector::AddTabs( | 260 void SessionRestoreStatsCollector::AddTabs( |
165 const std::vector<SessionRestoreDelegate::RestoredTab>& tabs) { | 261 const std::vector<SessionRestoreDelegate::RestoredTab>& tabs) { |
262 // Increment the session restore ID so to distinguish which tabs belong to | |
263 // which conceptual session restore. | |
264 ++session_restore_id_; | |
265 | |
266 // Each session restore makes a call to AddTabs with all of its tabs to be | |
267 // restored all at once. Record statistics about the session restore as a | |
268 // whole. | |
269 UMA_HISTOGRAM_COUNTS_100(kSessionRestoreTabCount, tabs.size()); | |
270 UMA_HISTOGRAM_ENUMERATION(kSessionRestoreActions, | |
271 kSessionRestoreActionsUma_Initiated, | |
272 kSessionRestoreActionsUma_Max); | |
273 | |
166 tab_count_ += tabs.size(); | 274 tab_count_ += tabs.size(); |
167 for (auto& tab : tabs) { | 275 for (auto& tab : tabs) { |
276 // Record actions for each individual tab. | |
277 UMA_HISTOGRAM_ENUMERATION(kSessionRestoreTabActions, | |
278 kSessionRestoreTabActionsUma_TabCreated, | |
279 kSessionRestoreTabActionsUma_Max); | |
280 | |
168 RegisterForNotifications(&tab.contents()->GetController()); | 281 RegisterForNotifications(&tab.contents()->GetController()); |
169 if (tab.is_active()) { | 282 if (tab.is_active()) { |
170 RenderWidgetHost* render_widget_host = | 283 RenderWidgetHost* render_widget_host = |
171 GetRenderWidgetHost(&tab.contents()->GetController()); | 284 GetRenderWidgetHost(&tab.contents()->GetController()); |
172 render_widget_hosts_loading_.insert(render_widget_host); | 285 render_widget_hosts_loading_.insert(render_widget_host); |
173 } | 286 } |
174 } | 287 } |
175 } | 288 } |
176 | 289 |
177 void SessionRestoreStatsCollector::RemoveTab(NavigationController* tab) { | 290 void SessionRestoreStatsCollector::DeferTabImpl( |
291 content::NavigationController* tab) { | |
292 // We simply move this tab from the tracked set to the deferred set. | |
293 ++tab_deferred_count_; | |
294 auto tracked_it = tabs_tracked_.find(tab); | |
295 int session_id = tracked_it->second; | |
296 tabs_deferred_.insert(*tracked_it); | |
297 tabs_tracked_.erase(tracked_it); | |
298 | |
299 // Only indicate that the session has had deferred tabs if this is the first | |
300 // tab associated with that session being deferred. | |
301 if (deferred_tabs_seen_.insert(session_id).second) { | |
302 // It is assumed that tabs are being deferred due to memory pressure as this | |
303 // is currently the only mechanism in which this can happen. | |
304 UMA_HISTOGRAM_ENUMERATION(kSessionRestoreActions, | |
305 kSessionRestoreActionsUma_DeferredTabs, | |
306 kSessionRestoreActionsUma_Max); | |
307 } | |
308 | |
309 UMA_HISTOGRAM_ENUMERATION(kSessionRestoreTabActions, | |
310 kSessionRestoreTabActionsUma_TabLoadingDeferred, | |
311 kSessionRestoreTabActionsUma_Max); | |
312 } | |
313 | |
314 void SessionRestoreStatsCollector::RemoveTab(bool is_deferred, | |
315 NavigationController* tab) { | |
316 // Stop observing this tab. | |
178 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 317 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
179 content::Source<WebContents>(tab->GetWebContents())); | 318 content::Source<WebContents>(tab->GetWebContents())); |
180 registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP, | 319 registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP, |
181 content::Source<NavigationController>(tab)); | 320 content::Source<NavigationController>(tab)); |
182 registrar_.Remove(this, content::NOTIFICATION_LOAD_START, | 321 registrar_.Remove(this, content::NOTIFICATION_LOAD_START, |
183 content::Source<NavigationController>(tab)); | 322 content::Source<NavigationController>(tab)); |
184 if (render_widget_hosts_loading_.size() > max_parallel_tab_loads_) | 323 |
324 // Keep track of the maximum number of automatically loaded tabs that are | |
325 // loading at the same time. | |
326 if (!is_deferred && | |
327 render_widget_hosts_loading_.size() > max_parallel_tab_loads_) { | |
185 max_parallel_tab_loads_ = render_widget_hosts_loading_.size(); | 328 max_parallel_tab_loads_ = render_widget_hosts_loading_.size(); |
329 } | |
330 | |
186 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(tab); | 331 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(tab); |
187 render_widget_hosts_loading_.erase(render_widget_host); | 332 render_widget_hosts_loading_.erase(render_widget_host); |
188 tabs_tracked_.erase(tab); | 333 |
334 // Remove the tab from the appropriate list. | |
335 if (is_deferred) { | |
336 tabs_deferred_.erase(tab); | |
337 } else { | |
338 tabs_tracked_.erase(tab); | |
339 } | |
189 | 340 |
sky
2015/05/12 15:27:56
Would be nice to have some DCHECKs here that tab i
chrisha
2015/05/13 21:18:02
I moved to using a map that tracks the 'deferred'
| |
190 // If there are no more tabs loading or being tracked, restore is done and | 341 // If there are no more tabs loading or being tracked, restore is done and |
191 // record the time. Note that we are not yet finished, as we might still be | 342 // record the time. Note that we are not yet finished, as we might still be |
192 // waiting for our first paint, which can happen after all tabs are done | 343 // waiting for our first paint, which can happen after all tabs are done |
193 // loading. | 344 // loading. |
194 // TODO(georgesak): review behaviour of ForegroundTabFirstPaint. | 345 // NOTE: This is only concerned with tabs that are being actively tracked, |
346 // and not deferred tabs. Deferred tabs are still tracked, but don't | |
347 // affect the AllTabsLoaded metric. | |
348 // TODO(georgesak): Review behaviour of ForegroundTabFirstPaint. | |
195 if (tabs_tracked_.empty() && render_widget_hosts_loading_.empty()) { | 349 if (tabs_tracked_.empty() && render_widget_hosts_loading_.empty()) { |
sky
2015/05/12 15:27:56
Lets say tabs_tracked_ goes empty, adoesn't that m
chrisha
2015/05/13 21:18:02
Yes, that's true. This is no worse than before in
sky
2015/05/14 00:12:40
Not sure there. I think you're change makes it wor
chrisha
2015/05/14 21:27:02
The 'deferred state' of a tab doesn't change it's
sky
2015/05/14 21:51:50
Ok.
| |
196 base::TimeDelta time_to_load = base::TimeTicks::Now() - restore_started_; | 350 base::TimeDelta time_to_load = base::TimeTicks::Now() - restore_started_; |
197 UMA_HISTOGRAM_CUSTOM_TIMES("SessionRestore.AllTabsLoaded", time_to_load, | 351 UMA_HISTOGRAM_CUSTOM_TIMES("SessionRestore.AllTabsLoaded", time_to_load, |
198 base::TimeDelta::FromMilliseconds(10), | 352 base::TimeDelta::FromMilliseconds(10), |
199 base::TimeDelta::FromSeconds(100), 100); | 353 base::TimeDelta::FromSeconds(100), 100); |
200 // Record a time for the number of tabs, to help track down contention. | 354 // Record a time for the number of tabs, to help track down contention. |
355 int tabs_loaded = tab_count_ - tab_deferred_count_; | |
201 std::string time_for_count = | 356 std::string time_for_count = |
202 base::StringPrintf("SessionRestore.AllTabsLoaded_%d", tab_count_); | 357 base::StringPrintf("SessionRestore.AllTabsLoaded_%d", tabs_loaded); |
203 base::HistogramBase* counter_for_count = base::Histogram::FactoryTimeGet( | 358 base::HistogramBase* counter_for_count = base::Histogram::FactoryTimeGet( |
204 time_for_count, base::TimeDelta::FromMilliseconds(10), | 359 time_for_count, base::TimeDelta::FromMilliseconds(10), |
205 base::TimeDelta::FromSeconds(100), 100, | 360 base::TimeDelta::FromSeconds(100), 100, |
206 base::Histogram::kUmaTargetedHistogramFlag); | 361 base::Histogram::kUmaTargetedHistogramFlag); |
207 counter_for_count->AddTime(time_to_load); | 362 counter_for_count->AddTime(time_to_load); |
208 | 363 |
209 UMA_HISTOGRAM_COUNTS_100("SessionRestore.ParallelTabLoads", | 364 UMA_HISTOGRAM_COUNTS_100("SessionRestore.ParallelTabLoads", |
210 max_parallel_tab_loads_); | 365 max_parallel_tab_loads_); |
211 } | 366 } |
212 } | 367 } |
213 | 368 |
214 void SessionRestoreStatsCollector::RegisterForNotifications( | 369 void SessionRestoreStatsCollector::RegisterForNotifications( |
215 NavigationController* tab) { | 370 NavigationController* tab) { |
sky
2015/05/12 15:27:56
can you make this take session_restore_id_ so that
chrisha
2015/05/13 21:18:02
After hashing this out with Georges, we really don
sky
2015/05/14 00:12:40
I have to think about that more. I'm concerned tha
chrisha
2015/05/14 21:27:02
This is effectively preserving the existing behavi
sky
2015/05/14 21:51:50
I think the old behavior is wrong in some cases. I
chrisha
2015/05/26 20:00:18
Added a TODO capturing this.
| |
216 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 371 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
217 content::Source<WebContents>(tab->GetWebContents())); | 372 content::Source<WebContents>(tab->GetWebContents())); |
218 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 373 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
219 content::Source<NavigationController>(tab)); | 374 content::Source<NavigationController>(tab)); |
220 registrar_.Add(this, content::NOTIFICATION_LOAD_START, | 375 registrar_.Add(this, content::NOTIFICATION_LOAD_START, |
221 content::Source<NavigationController>(tab)); | 376 content::Source<NavigationController>(tab)); |
222 tabs_tracked_.insert(tab); | 377 tabs_tracked_.insert(std::make_pair(tab, session_restore_id_)); |
223 } | 378 } |
224 | 379 |
225 RenderWidgetHost* SessionRestoreStatsCollector::GetRenderWidgetHost( | 380 RenderWidgetHost* SessionRestoreStatsCollector::GetRenderWidgetHost( |
226 NavigationController* tab) { | 381 NavigationController* tab) { |
227 WebContents* web_contents = tab->GetWebContents(); | 382 WebContents* web_contents = tab->GetWebContents(); |
228 if (web_contents) { | 383 if (web_contents) { |
229 content::RenderWidgetHostView* render_widget_host_view = | 384 content::RenderWidgetHostView* render_widget_host_view = |
230 web_contents->GetRenderWidgetHostView(); | 385 web_contents->GetRenderWidgetHostView(); |
231 if (render_widget_host_view) | 386 if (render_widget_host_view) |
232 return render_widget_host_view->GetRenderWidgetHost(); | 387 return render_widget_host_view->GetRenderWidgetHost(); |
233 } | 388 } |
234 return nullptr; | 389 return nullptr; |
235 } | 390 } |
236 | 391 |
392 bool SessionRestoreStatsCollector::IsDeferred( | |
393 content::NavigationController* tab) { | |
394 if (tabs_deferred_.count(tab) > 0) | |
sky
2015/05/12 15:27:56
nit: return tabs_deffered_.count(tab) > 0
chrisha
2015/05/13 21:18:01
(I have a tendency to write code this way because
| |
395 return true; | |
396 return false; | |
397 } | |
398 | |
237 // static | 399 // static |
238 SessionRestoreStatsCollector* SessionRestoreStatsCollector::shared_collector_ = | 400 SessionRestoreStatsCollector* SessionRestoreStatsCollector::shared_collector_ = |
239 nullptr; | 401 nullptr; |
OLD | NEW |