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

Unified Diff: ios/chrome/browser/ui/browser_view_controller.mm

Issue 2895013002: Perf metric tracking the wallclock time it takes to show a new tab page. (Closed)
Patch Set: Add new metric for tracking new tabs from tab switcher button, and review feedback" Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/browser_view_controller.mm
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm
index ba8d2dcf650f44e1b609551280f8fa5876c2fa0e..0326b52bbb7eb690f97ec35e1133dc97f6df8d0a 100644
--- a/ios/chrome/browser/ui/browser_view_controller.mm
+++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -572,6 +572,10 @@ NSString* const kNativeControllerTemporaryKey = @"NativeControllerTemporaryKey";
// the user from interacting with the browser view.
@property(nonatomic, strong)
ActivityOverlayCoordinator* activityOverlayCoordinator;
+// A block to be run when the |tabWasAdded:| method completes the animation
+// for the presentation of a new tab. Can be used to record performance metrics.
+@property(nonatomic, strong, nullable)
+ ProceduralBlock foregroundTabWasAddedCompletionBlock;
// The user agent type used to load the currently visible page. User agent type
// is NONE if there is no visible page or visible page is a native page.
@@ -932,6 +936,8 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
@synthesize hideStatusBar = _hideStatusBar;
@synthesize activityOverlayCoordinator = _activityOverlayCoordinator;
@synthesize presenting = _presenting;
+@synthesize foregroundTabWasAddedCompletionBlock =
+ _foregroundTabWasAddedCompletionBlock;
#pragma mark - Object lifecycle
@@ -1198,6 +1204,23 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
}
- (void)newTab:(id)sender {
+ // Observe the timing of the new tab creation, both MainController
+ // and BrowserViewController call into this method on the correct BVC to
+ // create new tabs making it preferable to doing this in
+ // |chromeExecuteCommand:|.
+ NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
+ BOOL offTheRecord = self.isOffTheRecord;
+ self.foregroundTabWasAddedCompletionBlock = ^{
+ double duration = [NSDate timeIntervalSinceReferenceDate] - startTime;
Ilya Sherman 2017/05/23 22:55:22 Optional nit: Mebbe define a TimeDelta here, outsi
PL 2017/06/08 17:57:47 Done!
+ if (offTheRecord) {
+ UMA_HISTOGRAM_TIMES("Toolbar.Menu.NewIncognitoTabPresentationDuration",
+ base::TimeDelta::FromSecondsD(duration));
+ } else {
+ UMA_HISTOGRAM_TIMES("Toolbar.Menu.NewTabPresentationDuration",
+ base::TimeDelta::FromSecondsD(duration));
+ }
+ };
+
[self setLastTapPoint:sender];
DCHECK(self.visible || self.dismissingModal);
Tab* currentTab = [_model currentTab];
@@ -1625,6 +1648,10 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
[self tabSelected:currentTab];
}
startVoiceSearchIfNecessaryBlock();
+
+ if (self.foregroundTabWasAddedCompletionBlock) {
+ self.foregroundTabWasAddedCompletionBlock();
+ }
});
} else {
// -updateSnapshotWithOverlay will force a screen redraw, so take the
@@ -1663,6 +1690,9 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
startVoiceSearchIfNecessaryBlock();
});
}
+ // Reset the foreground tab completion block so that it can never be
+ // called more than once regardless of foreground/background tab appearances.
+ self.foregroundTabWasAddedCompletionBlock = nil;
}
#pragma mark - UI Configuration and Layout
« no previous file with comments | « no previous file | ios/chrome/browser/ui/stack_view/stack_view_controller.mm » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698