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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js

Issue 2717393003: [DevTools] Turn starting tracing into promise. (Closed)
Patch Set: more work Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 /** 534 /**
535 * @param {boolean} enabled 535 * @param {boolean} enabled
536 */ 536 */
537 _setUIControlsEnabled(enabled) { 537 _setUIControlsEnabled(enabled) {
538 this._recordingOptionUIControls.forEach(control => control.setEnabled(enable d)); 538 this._recordingOptionUIControls.forEach(control => control.setEnabled(enable d));
539 } 539 }
540 540
541 /** 541 /**
542 * @param {boolean} userInitiated 542 * @param {boolean} userInitiated
543 * @return {!Promise}
543 */ 544 */
544 _startRecording(userInitiated) { 545 _startRecording(userInitiated) {
545 console.assert(!this._statusPane, 'Status pane is already opened.'); 546 console.assert(!this._statusPane, 'Status pane is already opened.');
546 var mainTarget = SDK.targetManager.mainTarget(); 547 var mainTarget = SDK.targetManager.mainTarget();
547 if (!mainTarget) 548 if (!mainTarget)
548 return; 549 return Promise.resolve();
549 this._setState(Timeline.TimelinePanel.State.StartPending); 550 this._setState(Timeline.TimelinePanel.State.StartPending);
550 this._showRecordingStarted(); 551 this._showRecordingStarted();
551 552
552 this._autoRecordGeneration = userInitiated ? null : Symbol('Generation'); 553 this._autoRecordGeneration = userInitiated ? null : Symbol('Generation');
553 var enabledTraceProviders = Extensions.extensionServer.traceProviders().filt er( 554 var enabledTraceProviders = Extensions.extensionServer.traceProviders().filt er(
554 provider => Timeline.TimelinePanel._settingForTraceProvider(provider).ge t()); 555 provider => Timeline.TimelinePanel._settingForTraceProvider(provider).ge t());
555 556
556 const recordingOptions = { 557 const recordingOptions = {
557 enableJSSampling: !this._disableCaptureJSProfileSetting.get(), 558 enableJSSampling: !this._disableCaptureJSProfileSetting.get(),
558 capturePictures: this._captureLayersAndPicturesSetting.get(), 559 capturePictures: this._captureLayersAndPicturesSetting.get(),
559 captureFilmStrip: this._showScreenshotsSetting.get() 560 captureFilmStrip: this._showScreenshotsSetting.get()
560 }; 561 };
561 562
562 this._pendingPerformanceModel = new Timeline.PerformanceModel(); 563 this._pendingPerformanceModel = new Timeline.PerformanceModel();
563 this._controller = new Timeline.TimelineController(mainTarget, this._pending PerformanceModel, this); 564 this._controller = new Timeline.TimelineController(mainTarget, this._pending PerformanceModel, this);
564 this._controller.startRecording(recordingOptions, enabledTraceProviders);
565
566 Host.userMetrics.actionTaken( 565 Host.userMetrics.actionTaken(
567 userInitiated ? Host.UserMetrics.Action.TimelineStarted : Host.UserMetri cs.Action.TimelinePageReloadStarted); 566 userInitiated ? Host.UserMetrics.Action.TimelineStarted : Host.UserMetri cs.Action.TimelinePageReloadStarted);
568 this._setUIControlsEnabled(false); 567 this._setUIControlsEnabled(false);
569 this._hideLandingPage(); 568 this._hideLandingPage();
569 return this._controller.startRecording(recordingOptions, enabledTraceProvide rs)
alph 2017/02/28 03:11:25 nit: await
570 .then(() => this._recordingStarted());
570 } 571 }
571 572
572 _stopRecording() { 573 _stopRecording() {
573 if (this._statusPane) { 574 if (this._statusPane) {
574 this._statusPane.finish(); 575 this._statusPane.finish();
575 this._statusPane.updateStatus(Common.UIString('Stopping timeline\u2026')); 576 this._statusPane.updateStatus(Common.UIString('Stopping timeline\u2026'));
576 this._statusPane.updateProgressBar(Common.UIString('Received'), 0); 577 this._statusPane.updateProgressBar(Common.UIString('Received'), 0);
577 } 578 }
578 this._setState(Timeline.TimelinePanel.State.StopPending); 579 this._setState(Timeline.TimelinePanel.State.StopPending);
579 this._autoRecordGeneration = null; 580 this._autoRecordGeneration = null;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 643 }
643 this._overviewPane.scheduleUpdate(); 644 this._overviewPane.scheduleUpdate();
644 if (this._detailsView) 645 if (this._detailsView)
645 this._detailsView.setModel(model); 646 this._detailsView.setModel(model);
646 647
647 this.select(null); 648 this.select(null);
648 if (this._flameChart) 649 if (this._flameChart)
649 this._flameChart.resizeToPreferredHeights(); 650 this._flameChart.resizeToPreferredHeights();
650 } 651 }
651 652
652 /** 653 _recordingStarted() {
653 * @override
654 */
655 recordingStarted() {
656 this._reset(); 654 this._reset();
657 this._setState(Timeline.TimelinePanel.State.Recording); 655 this._setState(Timeline.TimelinePanel.State.Recording);
658 this._showRecordingStarted(); 656 this._showRecordingStarted();
659 this._statusPane.updateStatus(Common.UIString('Profiling\u2026')); 657 this._statusPane.updateStatus(Common.UIString('Profiling\u2026'));
660 this._statusPane.updateProgressBar(Common.UIString('Buffer usage'), 0); 658 this._statusPane.updateProgressBar(Common.UIString('Buffer usage'), 0);
661 this._statusPane.startTimer(); 659 this._statusPane.startTimer();
662 this._hideLandingPage(); 660 this._hideLandingPage();
663 } 661 }
664 662
665 /** 663 /**
(...skipping 14 matching lines...) Expand all
680 * @param {string} tagName 678 * @param {string} tagName
681 * @param {string} contents 679 * @param {string} contents
682 */ 680 */
683 function encloseWithTag(tagName, contents) { 681 function encloseWithTag(tagName, contents) {
684 var e = createElement(tagName); 682 var e = createElement(tagName);
685 e.textContent = contents; 683 e.textContent = contents;
686 return e; 684 return e;
687 } 685 }
688 686
689 var learnMoreNode = UI.createExternalLink( 687 var learnMoreNode = UI.createExternalLink(
690 'https://developers.google.com/web/tools/chrome-devtools/evaluate-perfor mance/', Common.UIString('Learn\xa0more')); 688 'https://developers.google.com/web/tools/chrome-devtools/evaluate-perfor mance/',
689 Common.UIString('Learn\xa0more'));
691 var recordKey = 690 var recordKey =
692 encloseWithTag('b', UI.shortcutRegistry.shortcutDescriptorsForAction('ti meline.toggle-recording')[0].name); 691 encloseWithTag('b', UI.shortcutRegistry.shortcutDescriptorsForAction('ti meline.toggle-recording')[0].name);
693 var reloadKey = encloseWithTag('b', UI.shortcutRegistry.shortcutDescriptorsF orAction('main.reload')[0].name); 692 var reloadKey = encloseWithTag('b', UI.shortcutRegistry.shortcutDescriptorsF orAction('main.reload')[0].name);
694 var navigateNode = encloseWithTag('b', Common.UIString('WASD')); 693 var navigateNode = encloseWithTag('b', Common.UIString('WASD'));
695 694
696 this._landingPage = new UI.VBox(); 695 this._landingPage = new UI.VBox();
697 this._landingPage.contentElement.classList.add('timeline-landing-page', 'fil l'); 696 this._landingPage.contentElement.classList.add('timeline-landing-page', 'fil l');
698 var centered = this._landingPage.contentElement.createChild('div'); 697 var centered = this._landingPage.contentElement.createChild('div');
699 698
700 var recordButton = UI.Toolbar.createActionButton(this._toggleRecordAction).e lement; 699 var recordButton = UI.Toolbar.createActionButton(this._toggleRecordAction).e lement;
701 var reloadButton = UI.Toolbar.createActionButtonForId('main.reload').element ; 700 var reloadButton = UI.Toolbar.createActionButtonForId('main.reload').element ;
702 701
703 centered.createChild('p').appendChild(UI.formatLocalized( 702 centered.createChild('p').appendChild(UI.formatLocalized(
704 'Click the record button %s or hit %s to capture a new recording.\n' + 703 'Click the record button %s or hit %s to capture a new recording.\n' +
705 'Click the reload button %s or hit %s to record and evaluate the page lo ad.', 704 'Click the reload button %s or hit %s to record and evaluate the pag e load.',
alph 2017/02/28 03:11:25 revert?
dgozman 2017/02/28 08:59:01 That's what formatter does for me.
706 [recordButton, recordKey, reloadButton, reloadKey])); 705 [recordButton, recordKey, reloadButton, reloadKey]));
707 706
708 centered.createChild('p').appendChild(UI.formatLocalized( 707 centered.createChild('p').appendChild(UI.formatLocalized(
709 'After recording, select an area of interest in the overview by dragging .\n' + 708 'After recording, select an area of interest in the overview by dragging .\n' +
710 'Then, zoom and pan the timeline with the mousewheel or %s keys.\n%s', 709 'Then, zoom and pan the timeline with the mousewheel or %s keys.\n%s ',
alph 2017/02/28 03:11:25 ditto
711 [navigateNode, learnMoreNode])); 710 [navigateNode, learnMoreNode]));
712 711
713 var cpuProfilerHintSetting = Common.settings.createSetting('timelineShowProf ilerHint', true); 712 var cpuProfilerHintSetting = Common.settings.createSetting('timelineShowProf ilerHint', true);
714 if (cpuProfilerHintSetting.get()) { 713 if (cpuProfilerHintSetting.get()) {
715 var warning = centered.createChild('p', 'timeline-landing-warning'); 714 var warning = centered.createChild('p', 'timeline-landing-warning');
716 var closeButton = warning.createChild('div', 'timeline-landing-warning-clo se', 'dt-close-button'); 715 var closeButton = warning.createChild('div', 'timeline-landing-warning-clo se', 'dt-close-button');
717 closeButton.addEventListener('click', () => { 716 closeButton.addEventListener('click', () => {
718 warning.style.visibility = 'hidden'; 717 warning.style.visibility = 'hidden';
719 cpuProfilerHintSetting.set(false); 718 cpuProfilerHintSetting.set(false);
720 }, false); 719 }, false);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 } 822 }
824 this._overviewPane.setMarkers(markers); 823 this._overviewPane.setMarkers(markers);
825 } 824 }
826 825
827 /** 826 /**
828 * @param {!Common.Event} event 827 * @param {!Common.Event} event
829 */ 828 */
830 _pageReloadRequested(event) { 829 _pageReloadRequested(event) {
831 if (this._state !== Timeline.TimelinePanel.State.Idle || !this.isShowing()) 830 if (this._state !== Timeline.TimelinePanel.State.Idle || !this.isShowing())
832 return; 831 return;
833 this._startRecording(false); 832 var resourceTreeModel = /** @type {!SDK.ResourceTreeModel} */ (event.data);
833 resourceTreeModel.suspendReload();
834 this._startRecording(false).then(() => resourceTreeModel.resumeReload());
834 } 835 }
835 836
836 /** 837 /**
837 * @param {!Common.Event} event 838 * @param {!Common.Event} event
838 */ 839 */
839 _loadEventFired(event) { 840 _loadEventFired(event) {
840 if (this._state !== Timeline.TimelinePanel.State.Recording || !this._autoRec ordGeneration) 841 if (this._state !== Timeline.TimelinePanel.State.Recording || !this._autoRec ordGeneration)
841 return; 842 return;
842 setTimeout(stopRecordingOnReload.bind(this, this._autoRecordGeneration), thi s._millisecondsToRecordAfterLoadEvent); 843 setTimeout(stopRecordingOnReload.bind(this, this._autoRecordGeneration), thi s._millisecondsToRecordAfterLoadEvent);
843 844
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 return true; 1339 return true;
1339 case 'timeline.jump-to-next-frame': 1340 case 'timeline.jump-to-next-frame':
1340 panel._jumpToFrame(1); 1341 panel._jumpToFrame(1);
1341 return true; 1342 return true;
1342 } 1343 }
1343 return false; 1344 return false;
1344 } 1345 }
1345 }; 1346 };
1346 1347
1347 Timeline.TimelinePanel._traceProviderSettingSymbol = Symbol('traceProviderSettin g'); 1348 Timeline.TimelinePanel._traceProviderSettingSymbol = Symbol('traceProviderSettin g');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698