Chromium Code Reviews| 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 |