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

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: Review nits Created 3 years, 6 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 | ios/chrome/browser/ui/stack_view/stack_view_controller.mm » ('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 foregroundTabWasAddedCompletionBlock;
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 foregroundTabWasAddedCompletionBlock =
940 _foregroundTabWasAddedCompletionBlock;
935 941
936 #pragma mark - Object lifecycle 942 #pragma mark - Object lifecycle
937 943
938 - (instancetype)initWithTabModel:(TabModel*)model 944 - (instancetype)initWithTabModel:(TabModel*)model
939 browserState:(ios::ChromeBrowserState*)browserState 945 browserState:(ios::ChromeBrowserState*)browserState
940 dependencyFactory: 946 dependencyFactory:
941 (BrowserViewControllerDependencyFactory*)factory { 947 (BrowserViewControllerDependencyFactory*)factory {
942 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; 948 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()];
943 if (self) { 949 if (self) {
944 DCHECK(factory); 950 DCHECK(factory);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 [self setNeedsStatusBarAppearanceUpdate]; 1194 [self setNeedsStatusBarAppearanceUpdate];
1189 } 1195 }
1190 1196
1191 #pragma mark - IBActions 1197 #pragma mark - IBActions
1192 1198
1193 - (void)shieldWasTapped:(id)sender { 1199 - (void)shieldWasTapped:(id)sender {
1194 [_toolbarController cancelOmniboxEdit]; 1200 [_toolbarController cancelOmniboxEdit];
1195 } 1201 }
1196 1202
1197 - (void)newTab:(id)sender { 1203 - (void)newTab:(id)sender {
1204 // Observe the timing of the new tab creation, both MainController
1205 // and BrowserViewController call into this method on the correct BVC to
1206 // create new tabs making it preferable to doing this in
1207 // |chromeExecuteCommand:|.
1208 NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
1209 BOOL offTheRecord = self.isOffTheRecord;
1210 self.foregroundTabWasAddedCompletionBlock = ^{
1211 double duration = [NSDate timeIntervalSinceReferenceDate] - startTime;
1212 base::TimeDelta timeDelta = base::TimeDelta::FromSecondsD(duration);
1213 if (offTheRecord) {
1214 UMA_HISTOGRAM_TIMES("Toolbar.Menu.NewIncognitoTabPresentationDuration",
1215 timeDelta);
1216 } else {
1217 UMA_HISTOGRAM_TIMES("Toolbar.Menu.NewTabPresentationDuration", timeDelta);
1218 }
1219 };
1220
1198 [self setLastTapPoint:sender]; 1221 [self setLastTapPoint:sender];
1199 DCHECK(self.visible || self.dismissingModal); 1222 DCHECK(self.visible || self.dismissingModal);
1200 Tab* currentTab = [_model currentTab]; 1223 Tab* currentTab = [_model currentTab];
1201 if (currentTab) { 1224 if (currentTab) {
1202 [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; 1225 [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
1203 } 1226 }
1204 [self addSelectedTabWithURL:GURL(kChromeUINewTabURL) 1227 [self addSelectedTabWithURL:GURL(kChromeUINewTabURL)
1205 transition:ui::PAGE_TRANSITION_TYPED]; 1228 transition:ui::PAGE_TRANSITION_TYPED];
1206 } 1229 }
1207 1230
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 // 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
1616 // 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.
1617 // if another Tab shows a dialog via |dialogPresenter|). However, that 1640 // if another Tab shows a dialog via |dialogPresenter|). However, that
1618 // 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
1619 // animation. 1642 // animation.
1620 Tab* currentTab = [_model currentTab]; 1643 Tab* currentTab = [_model currentTab];
1621 if (currentTab) { 1644 if (currentTab) {
1622 [self tabSelected:currentTab]; 1645 [self tabSelected:currentTab];
1623 } 1646 }
1624 startVoiceSearchIfNecessaryBlock(); 1647 startVoiceSearchIfNecessaryBlock();
1648
1649 if (self.foregroundTabWasAddedCompletionBlock) {
1650 self.foregroundTabWasAddedCompletionBlock();
1651 }
1625 }); 1652 });
1626 } else { 1653 } else {
1627 // -updateSnapshotWithOverlay will force a screen redraw, so take the 1654 // -updateSnapshotWithOverlay will force a screen redraw, so take the
1628 // snapshot before adding the views needed for the background animation. 1655 // snapshot before adding the views needed for the background animation.
1629 Tab* topTab = [_model currentTab]; 1656 Tab* topTab = [_model currentTab];
1630 UIImage* image = [topTab updateSnapshotWithOverlay:YES 1657 UIImage* image = [topTab updateSnapshotWithOverlay:YES
1631 visibleFrameOnly:self.isToolbarOnScreen]; 1658 visibleFrameOnly:self.isToolbarOnScreen];
1632 // Add three layers in order on top of the contentArea for the animation: 1659 // Add three layers in order on top of the contentArea for the animation:
1633 // 1. The black "background" screen. 1660 // 1. The black "background" screen.
1634 UIView* background = [[UIView alloc] initWithFrame:[_contentArea bounds]]; 1661 UIView* background = [[UIView alloc] initWithFrame:[_contentArea bounds]];
(...skipping 18 matching lines...) Expand all
1653 self.inNewTabAnimation = NO; 1680 self.inNewTabAnimation = NO;
1654 // Resnapshot the top card if it has its own toolbar, as the toolbar 1681 // Resnapshot the top card if it has its own toolbar, as the toolbar
1655 // will be captured in the new tab animation, but isn't desired for 1682 // will be captured in the new tab animation, but isn't desired for
1656 // the stack view snapshots. 1683 // the stack view snapshots.
1657 id nativeController = [self nativeControllerForTab:topTab]; 1684 id nativeController = [self nativeControllerForTab:topTab];
1658 if ([nativeController conformsToProtocol:@protocol(ToolbarOwner)]) 1685 if ([nativeController conformsToProtocol:@protocol(ToolbarOwner)])
1659 [topTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; 1686 [topTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
1660 startVoiceSearchIfNecessaryBlock(); 1687 startVoiceSearchIfNecessaryBlock();
1661 }); 1688 });
1662 } 1689 }
1690 // Reset the foreground tab completion block so that it can never be
1691 // called more than once regardless of foreground/background tab appearances.
1692 self.foregroundTabWasAddedCompletionBlock = nil;
1663 } 1693 }
1664 1694
1665 #pragma mark - UI Configuration and Layout 1695 #pragma mark - UI Configuration and Layout
1666 1696
1667 - (void)updateWithTabModel:(TabModel*)model 1697 - (void)updateWithTabModel:(TabModel*)model
1668 browserState:(ios::ChromeBrowserState*)browserState { 1698 browserState:(ios::ChromeBrowserState*)browserState {
1669 DCHECK(model); 1699 DCHECK(model);
1670 DCHECK(browserState); 1700 DCHECK(browserState);
1671 DCHECK(!_model); 1701 DCHECK(!_model);
1672 DCHECK(!_browserState); 1702 DCHECK(!_browserState);
(...skipping 3509 matching lines...) Expand 10 before | Expand all | Expand 10 after
5182 5212
5183 - (UIView*)voiceSearchButton { 5213 - (UIView*)voiceSearchButton {
5184 return _voiceSearchButton; 5214 return _voiceSearchButton;
5185 } 5215 }
5186 5216
5187 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5217 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5188 return [self currentLogoAnimationControllerOwner]; 5218 return [self currentLogoAnimationControllerOwner];
5189 } 5219 }
5190 5220
5191 @end 5221 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/stack_view/stack_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698