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

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: 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1271cea016bb063baa8cc2dd4162d3f0fff7faca..a3d5756082c305ef847245154fee83e90610ba7d 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 tabWasAddedCompletionBlock;
// 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,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
@synthesize hideStatusBar = _hideStatusBar;
@synthesize activityOverlayCoordinator = _activityOverlayCoordinator;
@synthesize presenting = _presenting;
+@synthesize tabWasAddedCompletionBlock = _tabWasAddedCompletionBlock;
#pragma mark - Object lifecycle
@@ -1198,6 +1203,21 @@ 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];
+ __weak __typeof(self) weakSelf = self;
rohitrao (ping after 24h) 2017/05/22 12:55:05 Could we capture the value of isOffTheRecord inste
PL 2017/05/23 22:37:55 Absolutely! Done!
+ self.tabWasAddedCompletionBlock = ^{
+ UMA_HISTOGRAM_TIMES(
+ weakSelf.isOffTheRecord
+ ? "Toolbar.Menu.NewIncognitoTabPresentationDuration"
+ : "Toolbar.Menu.NewTabPresentationDuration",
Ilya Sherman 2017/05/22 20:45:45 Names passed to UMA_HISTOGRAM macros must be runti
PL 2017/05/23 22:37:55 Ah thanks! I've broken these out into two separate
+ base::TimeDelta::FromSecondsD([NSDate timeIntervalSinceReferenceDate] -
+ startTime));
+ };
+
[self setLastTapPoint:sender];
DCHECK(self.visible || self.dismissingModal);
Tab* currentTab = [_model currentTab];
@@ -1625,6 +1645,11 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
[self tabSelected:currentTab];
}
startVoiceSearchIfNecessaryBlock();
+
+ if (self.tabWasAddedCompletionBlock) {
+ self.tabWasAddedCompletionBlock();
+ self.tabWasAddedCompletionBlock = nil;
+ }
});
} else {
// -updateSnapshotWithOverlay will force a screen redraw, so take the
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698