Chromium Code Reviews| Index: ios/web/web_state/ui/crw_web_controller.mm |
| diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm |
| index 18aaf164228ffe7f528893ee76c72051d3447da0..076ac3be2034a2e90379e32f2df9808cba6f4a65 100644 |
| --- a/ios/web/web_state/ui/crw_web_controller.mm |
| +++ b/ios/web/web_state/ui/crw_web_controller.mm |
| @@ -166,6 +166,23 @@ void CancelAllTouches(UIScrollView* web_scroll_view) { |
| } |
| } |
| +// Key of the UMA Navigation.IOSWKWebViewSlowFastBackForward histogram. |
| +const char kUMAWKWebViewSlowFastBackForwardNavigationKey[] = |
| + "Navigation.IOSWKWebViewSlowFastBackForward"; |
| + |
| +// Values for the histogram that counts slow/fast back/forward navigations. |
| +enum BackForwardNavigationType { |
| + // Fast back navigation through WKWebView back-forward list. |
| + FAST_BACK = 0, |
|
Eugene But (OOO till 7-30)
2016/01/20 16:45:04
Back usually means previous (not negative delta),
stkhapugin
2016/01/21 10:39:36
Stuart mentioned that he'd like to have a distinct
Eugene But (OOO till 7-30)
2016/01/21 15:03:49
The problem here is that FAST_BACK is misleading,
stuartmorgan
2016/01/28 23:25:44
By "negative delta" do you mean going back N>1 pag
|
| + // Slow back navigation when back-forward list navigation is not possible. |
| + SLOW_BACK, |
| + // Fast forward navigation through WKWebView back-forward list. |
| + FAST_FORWARD, |
| + // Slow forward navigation when back-forward list navigation is not possible. |
| + SLOW_FORWARD, |
| + BACK_FORWARD_NAVIGATION_TYPE_COUNT |
| +}; |
| + |
| } // namespace |
| @interface CRWWebController () <CRWNativeContentDelegate, |
| @@ -1686,6 +1703,11 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
| } |
| } |
| +- (BOOL)canPerformFastNavigationForSessionEntry:(CRWSessionEntry*)sessionEntry { |
| + // Should be overriden by subclasses if they support fast navigation. |
| + return NO; |
| +} |
| + |
| - (void)abortLoad { |
| [self abortWebLoad]; |
| [self loadCancelled]; |
| @@ -1753,6 +1775,26 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
| [self finishHistoryNavigationFromEntry:fromEntry]; |
| _webStateImpl->SetCacheMode(net::RequestTracker::CACHE_NORMAL); |
| } |
| + |
| + // If using WKWebView, report slow/fast navigation metric. |
| + if ([self isKindOfClass:[CRWWKWebViewWebController class]]) { |
|
Eugene But (OOO till 7-30)
2016/01/20 16:45:04
I think you should move this code to subclass' goD
stkhapugin
2016/01/21 10:39:36
Done.
|
| + BOOL isFast = |
| + [self canPerformFastNavigationForSessionEntry:self.currentSessionEntry]; |
| + BOOL isBack = (delta < 0); |
| + |
| + BackForwardNavigationType navigationType; |
|
Eugene But (OOO till 7-30)
2016/01/20 16:45:04
Please always initialize local variables.
stkhapugin
2016/01/21 10:39:36
Done.
|
| + if (isBack) { |
| + navigationType = isFast ? BackForwardNavigationType::FAST_BACK |
| + : BackForwardNavigationType::SLOW_BACK; |
| + } else { |
| + navigationType = isFast ? BackForwardNavigationType::FAST_FORWARD |
| + : BackForwardNavigationType::SLOW_FORWARD; |
| + } |
| + |
| + UMA_HISTOGRAM_ENUMERATION( |
| + kUMAWKWebViewSlowFastBackForwardNavigationKey, navigationType, |
| + BackForwardNavigationType::BACK_FORWARD_NAVIGATION_TYPE_COUNT); |
| + } |
| } |
| - (BOOL)isLoaded { |