Commit 9e91e72c authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

iOS: Add performance metric for context menu element fetch duration.

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ia4cdf1f83336fc4f1c5b8dff8891e323ad4c0a14
Reviewed-on: https://chromium-review.googlesource.com/883042
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534201}
parent dd394d24
......@@ -75,6 +75,9 @@ void CancelTouches(UIGestureRecognizer* gesture_recognizer) {
completionHandler:(void (^)(NSDictionary*))handler;
// Sets the value of |_DOMElementForLastTouch|.
- (void)setDOMElementForLastTouch:(NSDictionary*)element;
// Logs the time taken to fetch DOM element details.
- (void)logElementFetchDurationWithStartTime:
(base::TimeTicks)elementFetchStartTime;
// Forwards the execution of |script| to |javaScriptDelegate| and if it is nil,
// to |webView|.
- (void)executeJavaScript:(NSString*)script
......@@ -286,6 +289,12 @@ void CancelTouches(UIGestureRecognizer* gesture_recognizer) {
}
}
- (void)logElementFetchDurationWithStartTime:
(base::TimeTicks)elementFetchStartTime {
UMA_HISTOGRAM_TIMES("ContextMenu.DOMElementFetchDuration",
base::TimeTicks::Now() - elementFetchStartTime);
}
#pragma mark -
#pragma mark UIGestureRecognizerDelegate
......@@ -309,10 +318,14 @@ void CancelTouches(UIGestureRecognizer* gesture_recognizer) {
// fetched - system context menu will be shown.
[self setDOMElementForLastTouch:nil];
_contextMenuNeedsDisplay = NO;
base::TimeTicks fetchStartTime = base::TimeTicks::Now();
__weak CRWContextMenuController* weakSelf = self;
[self fetchDOMElementAtPoint:[touch locationInView:_webView]
completionHandler:^(NSDictionary* element) {
[weakSelf setDOMElementForLastTouch:element];
CRWContextMenuController* strongSelf = weakSelf;
[strongSelf logElementFetchDurationWithStartTime:fetchStartTime];
[strongSelf setDOMElementForLastTouch:element];
}];
return YES;
}
......
......@@ -11716,6 +11716,17 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="ContextMenu.DOMElementFetchDuration" units="ms">
<owner>michaeldo@chromium.org</owner>
<summary>
How long it takes to fetch the details of the DOM element the user is
selecting for the context menu. On iOS, JavaScript must be run in order to
get the details of the DOM element. If the element is not inside the main
frame, latency could be added due to the communication between frames. Only
logged on iOS.
</summary>
</histogram>
<histogram name="ContextMenu.SaveLinkType" enum="ContextMenuSaveLinkType">
<owner>qinmin@chromium.org</owner>
<summary>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment