Index: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm |
diff --git a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm |
index 5cedc12de5b5f2fe4733f156fbe920bd7f2dc233..4b1ec3bb47f77010baaa5ad6cdeedff74ed6dd22 100644 |
--- a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm |
+++ b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm |
@@ -89,6 +89,23 @@ NSString* GetRefererFromNavigationAction(WKNavigationAction* action) { |
NSString* const kScriptMessageName = @"crwebinvoke"; |
NSString* const kScriptImmediateName = @"crwebinvokeimmediate"; |
+// 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, |
+ // 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 |
+}; |
+ |
// Utility functions for storing the source of NSErrors received by WKWebViews: |
// - Errors received by |-webView:didFailProvisionalNavigation:withError:| are |
// recorded using WKWebViewErrorSource::PROVISIONAL_LOAD. These should be |
@@ -472,6 +489,35 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) { |
_stoppedWKNavigation.reset(_latestWKNavigation); |
} |
+- (void)goDelta:(int)delta { |
+ [super goDelta:delta]; |
+ if (delta != 0) { |
Eugene But (OOO till 7-30)
2016/01/21 15:03:49
NIT: Please use early return to avoid indentations
stkhapugin
2016/02/05 15:40:15
Done.
|
+ // Report slow/fast navigation metric. |
+ web::WKBackForwardListItemHolder* holder = |
+ web::WKBackForwardListItemHolder::FromNavigationItem( |
+ self.currentSessionEntry.navigationItemImpl); |
+ BOOL isFast = |
+ (holder->back_forward_list_item() && |
+ [self isBackForwardListItemValid:holder->back_forward_list_item()]); |
stuartmorgan
2016/01/28 23:25:44
The fact that the logic for measuring fast back/fo
stkhapugin
2016/02/05 15:40:15
Keeping the reported metric as is for now. Please
stuartmorgan
2016/02/08 17:12:52
It's not a question of the divisions in the metric
|
+ |
+ BOOL isBack = (delta < 0); |
+ |
+ BackForwardNavigationType navigationType = |
+ BackForwardNavigationType::FAST_BACK; |
+ 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); |
+ } |
+} |
+ |
#pragma mark - |
#pragma mark Testing-Only Methods |