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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/browser_view_controller.h" 5 #import "ios/chrome/browser/ui/browser_view_controller.h"
6 6
7 #import <AssetsLibrary/AssetsLibrary.h> 7 #import <AssetsLibrary/AssetsLibrary.h>
8 #import <MobileCoreServices/MobileCoreServices.h> 8 #import <MobileCoreServices/MobileCoreServices.h>
9 #import <PassKit/PassKit.h> 9 #import <PassKit/PassKit.h>
10 #import <Photos/Photos.h> 10 #import <Photos/Photos.h>
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 @property(nonatomic, assign, getter=isInNewTabAnimation) BOOL inNewTabAnimation; 565 @property(nonatomic, assign, getter=isInNewTabAnimation) BOOL inNewTabAnimation;
566 // Whether BVC prefers to hide the status bar. This value is used to determine 566 // Whether BVC prefers to hide the status bar. This value is used to determine
567 // the response from the |prefersStatusBarHidden| method. 567 // the response from the |prefersStatusBarHidden| method.
568 @property(nonatomic, assign) BOOL hideStatusBar; 568 @property(nonatomic, assign) BOOL hideStatusBar;
569 // Whether the VoiceSearchBar should be displayed. 569 // Whether the VoiceSearchBar should be displayed.
570 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar; 570 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar;
571 // Coordinator for displaying a modal overlay with activity indicator to prevent 571 // Coordinator for displaying a modal overlay with activity indicator to prevent
572 // the user from interacting with the browser view. 572 // the user from interacting with the browser view.
573 @property(nonatomic, strong) 573 @property(nonatomic, strong)
574 ActivityOverlayCoordinator* activityOverlayCoordinator; 574 ActivityOverlayCoordinator* activityOverlayCoordinator;
575 // A block to be run when the |tabWasAdded:| method completes the animation
576 // for the presentation of a new tab. Can be used to record performance metrics.
577 @property(nonatomic, strong, nullable)
578 ProceduralBlock tabWasAddedCompletionBlock;
575 579
576 // The user agent type used to load the currently visible page. User agent type 580 // The user agent type used to load the currently visible page. User agent type
577 // is NONE if there is no visible page or visible page is a native page. 581 // is NONE if there is no visible page or visible page is a native page.
578 @property(nonatomic, assign, readonly) web::UserAgentType userAgentType; 582 @property(nonatomic, assign, readonly) web::UserAgentType userAgentType;
579 583
580 // Returns the header views, all the chrome on top of the page, including the 584 // Returns the header views, all the chrome on top of the page, including the
581 // ones that cannot be scrolled off screen by full screen. 585 // ones that cannot be scrolled off screen by full screen.
582 @property(nonatomic, strong, readonly) NSArray<HeaderDefinition*>* headerViews; 586 @property(nonatomic, strong, readonly) NSArray<HeaderDefinition*>* headerViews;
583 587
584 // BVC initialization: 588 // BVC initialization:
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 929
926 @synthesize contentArea = _contentArea; 930 @synthesize contentArea = _contentArea;
927 @synthesize typingShield = _typingShield; 931 @synthesize typingShield = _typingShield;
928 @synthesize active = _active; 932 @synthesize active = _active;
929 @synthesize visible = _visible; 933 @synthesize visible = _visible;
930 @synthesize viewVisible = _viewVisible; 934 @synthesize viewVisible = _viewVisible;
931 @synthesize dismissingModal = _dismissingModal; 935 @synthesize dismissingModal = _dismissingModal;
932 @synthesize hideStatusBar = _hideStatusBar; 936 @synthesize hideStatusBar = _hideStatusBar;
933 @synthesize activityOverlayCoordinator = _activityOverlayCoordinator; 937 @synthesize activityOverlayCoordinator = _activityOverlayCoordinator;
934 @synthesize presenting = _presenting; 938 @synthesize presenting = _presenting;
939 @synthesize tabWasAddedCompletionBlock = _tabWasAddedCompletionBlock;
935 940
936 #pragma mark - Object lifecycle 941 #pragma mark - Object lifecycle
937 942
938 - (instancetype)initWithTabModel:(TabModel*)model 943 - (instancetype)initWithTabModel:(TabModel*)model
939 browserState:(ios::ChromeBrowserState*)browserState 944 browserState:(ios::ChromeBrowserState*)browserState
940 dependencyFactory: 945 dependencyFactory:
941 (BrowserViewControllerDependencyFactory*)factory { 946 (BrowserViewControllerDependencyFactory*)factory {
942 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; 947 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()];
943 if (self) { 948 if (self) {
944 DCHECK(factory); 949 DCHECK(factory);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 [self setNeedsStatusBarAppearanceUpdate]; 1196 [self setNeedsStatusBarAppearanceUpdate];
1192 } 1197 }
1193 1198
1194 #pragma mark - IBActions 1199 #pragma mark - IBActions
1195 1200
1196 - (void)shieldWasTapped:(id)sender { 1201 - (void)shieldWasTapped:(id)sender {
1197 [_toolbarController cancelOmniboxEdit]; 1202 [_toolbarController cancelOmniboxEdit];
1198 } 1203 }
1199 1204
1200 - (void)newTab:(id)sender { 1205 - (void)newTab:(id)sender {
1206 // Observe the timing of the new tab creation, both MainController
1207 // and BrowserViewController call into this method on the correct BVC to
1208 // create new tabs making it preferable to doing this in
1209 // |chromeExecuteCommand:|.
1210 NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
1211 __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!
1212 self.tabWasAddedCompletionBlock = ^{
1213 UMA_HISTOGRAM_TIMES(
1214 weakSelf.isOffTheRecord
1215 ? "Toolbar.Menu.NewIncognitoTabPresentationDuration"
1216 : "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
1217 base::TimeDelta::FromSecondsD([NSDate timeIntervalSinceReferenceDate] -
1218 startTime));
1219 };
1220
1201 [self setLastTapPoint:sender]; 1221 [self setLastTapPoint:sender];
1202 DCHECK(self.visible || self.dismissingModal); 1222 DCHECK(self.visible || self.dismissingModal);
1203 Tab* currentTab = [_model currentTab]; 1223 Tab* currentTab = [_model currentTab];
1204 if (currentTab) { 1224 if (currentTab) {
1205 [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; 1225 [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
1206 } 1226 }
1207 [self addSelectedTabWithURL:GURL(kChromeUINewTabURL) 1227 [self addSelectedTabWithURL:GURL(kChromeUINewTabURL)
1208 transition:ui::PAGE_TRANSITION_TYPED]; 1228 transition:ui::PAGE_TRANSITION_TYPED];
1209 } 1229 }
1210 1230
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 // Block that starts voice search at the end of new Tab animation if 1604 // Block that starts voice search at the end of new Tab animation if
1585 // necessary. 1605 // necessary.
1586 ProceduralBlock startVoiceSearchIfNecessaryBlock = ^void() { 1606 ProceduralBlock startVoiceSearchIfNecessaryBlock = ^void() {
1587 if (_startVoiceSearchAfterNewTabAnimation) { 1607 if (_startVoiceSearchAfterNewTabAnimation) {
1588 _startVoiceSearchAfterNewTabAnimation = NO; 1608 _startVoiceSearchAfterNewTabAnimation = NO;
1589 [self startVoiceSearch]; 1609 [self startVoiceSearch];
1590 } 1610 }
1591 }; 1611 };
1592 1612
1593 self.inNewTabAnimation = YES; 1613 self.inNewTabAnimation = YES;
1594 if (!inBackground) { 1614 if (!inBackground) {
rohitrao (ping after 24h) 2017/05/22 12:55:05 What happens when we open a new tab in the backgro
PL 2017/05/23 22:37:55 This is a good question. The answer is (I believ
1595 UIView* animationParentView = _contentArea; 1615 UIView* animationParentView = _contentArea;
1596 // Create the new page image, and load with the new tab page snapshot. 1616 // Create the new page image, and load with the new tab page snapshot.
1597 CGFloat newPageOffset = 0; 1617 CGFloat newPageOffset = 0;
1598 UIImageView* newPage; 1618 UIImageView* newPage;
1599 if (tab.url == GURL(kChromeUINewTabURL) && !_isOffTheRecord && 1619 if (tab.url == GURL(kChromeUINewTabURL) && !_isOffTheRecord &&
1600 !IsIPadIdiom()) { 1620 !IsIPadIdiom()) {
1601 animationParentView = self.view; 1621 animationParentView = self.view;
1602 newPage = [self pageFullScreenOpenCloseAnimationView]; 1622 newPage = [self pageFullScreenOpenCloseAnimationView];
1603 } else { 1623 } else {
1604 newPage = [self pageOpenCloseAnimationView]; 1624 newPage = [self pageOpenCloseAnimationView];
(...skipping 13 matching lines...) Expand all
1618 // Use the model's currentTab here because it is possible that it can 1638 // Use the model's currentTab here because it is possible that it can
1619 // be reset to a new value before the new Tab animation finished (e.g. 1639 // be reset to a new value before the new Tab animation finished (e.g.
1620 // if another Tab shows a dialog via |dialogPresenter|). However, that 1640 // if another Tab shows a dialog via |dialogPresenter|). However, that
1621 // tab's view hasn't been displayed yet because it was in a new tab 1641 // tab's view hasn't been displayed yet because it was in a new tab
1622 // animation. 1642 // animation.
1623 Tab* currentTab = [_model currentTab]; 1643 Tab* currentTab = [_model currentTab];
1624 if (currentTab) { 1644 if (currentTab) {
1625 [self tabSelected:currentTab]; 1645 [self tabSelected:currentTab];
1626 } 1646 }
1627 startVoiceSearchIfNecessaryBlock(); 1647 startVoiceSearchIfNecessaryBlock();
1648
1649 if (self.tabWasAddedCompletionBlock) {
1650 self.tabWasAddedCompletionBlock();
1651 self.tabWasAddedCompletionBlock = nil;
1652 }
1628 }); 1653 });
1629 } else { 1654 } else {
1630 // -updateSnapshotWithOverlay will force a screen redraw, so take the 1655 // -updateSnapshotWithOverlay will force a screen redraw, so take the
1631 // snapshot before adding the views needed for the background animation. 1656 // snapshot before adding the views needed for the background animation.
1632 Tab* topTab = [_model currentTab]; 1657 Tab* topTab = [_model currentTab];
1633 UIImage* image = [topTab updateSnapshotWithOverlay:YES 1658 UIImage* image = [topTab updateSnapshotWithOverlay:YES
1634 visibleFrameOnly:self.isToolbarOnScreen]; 1659 visibleFrameOnly:self.isToolbarOnScreen];
1635 // Add three layers in order on top of the contentArea for the animation: 1660 // Add three layers in order on top of the contentArea for the animation:
1636 // 1. The black "background" screen. 1661 // 1. The black "background" screen.
1637 UIView* background = [[UIView alloc] initWithFrame:[_contentArea bounds]]; 1662 UIView* background = [[UIView alloc] initWithFrame:[_contentArea bounds]];
(...skipping 3531 matching lines...) Expand 10 before | Expand all | Expand 10 after
5169 5194
5170 - (UIView*)voiceSearchButton { 5195 - (UIView*)voiceSearchButton {
5171 return _voiceSearchButton; 5196 return _voiceSearchButton;
5172 } 5197 }
5173 5198
5174 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5199 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5175 return [self currentLogoAnimationControllerOwner]; 5200 return [self currentLogoAnimationControllerOwner];
5176 } 5201 }
5177 5202
5178 @end 5203 @end
OLDNEW
« 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