Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** @typedef {!{value: boolean, title: string, description: string, setting: str ing}} */ | |
| 6 Timeline.RecordingOption; | |
| 7 | |
| 8 /** @type {!Object<string, !Timeline.RecordingOption>} */ | |
| 9 Timeline.RecordingConfig = { | |
| 10 network: { | |
| 11 id: 'network', | |
| 12 value: false, | |
|
caseq
2016/12/09 02:11:12
s/value/forceEnable/?
alph
2016/12/09 21:36:10
Done.
| |
| 13 title: Common.UIString('Network'), | |
| 14 description: Common.UIString('Capture network requests information.'), | |
| 15 setting: 'timelineCaptureNetwork' | |
| 16 }, | |
| 17 javascript: { | |
| 18 id: 'javascript', | |
| 19 value: true, | |
| 20 title: Common.UIString('JavaScript'), | |
| 21 description: Common.UIString('Use sampling CPU profiler to collect JavaScrip t stacks.'), | |
| 22 setting: 'timelineEnableJSSampling' | |
| 23 }, | |
| 24 screenshots: { | |
| 25 id: 'screenshots', | |
| 26 value: false, | |
| 27 title: Common.UIString('Screenshots'), | |
| 28 description: | |
| 29 Common.UIString('Collect page screenshots, so you can observe how the pa ge was evolving during recording.'), | |
| 30 setting: 'timelineCaptureFilmStrip' | |
| 31 }, | |
| 32 paints: { | |
| 33 id: 'paints', | |
| 34 value: false, | |
| 35 title: Common.UIString('Paints'), | |
| 36 description: Common.UIString( | |
| 37 'Capture graphics layer positions and rasterization draw calls (moderate performance overhead).'), | |
| 38 setting: 'timelineCaptureLayersAndPictures' | |
| 39 }, | |
| 40 memory: { | |
| 41 id: 'memory', | |
| 42 value: true, | |
| 43 title: Common.UIString('Memory'), | |
| 44 description: Common.UIString('Capture memory information on every timeline e vent.'), | |
| 45 setting: 'timelineCaptureMemory' | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 Timeline.Perspective = class extends UI.VBox { | |
| 50 /** | |
| 51 * @param {string} description | |
| 52 * @param {!Array<string>=} visibleOptions | |
| 53 * @param {!Array<string>=} enabledOptions | |
| 54 */ | |
| 55 constructor(description, visibleOptions, enabledOptions) { | |
| 56 super(false); | |
| 57 this.contentElement.classList.add('timeline-perspective-body'); | |
| 58 this.contentElement.createChild('div', 'timeline-perspective-description').t extContent = description; | |
| 59 for (const id of visibleOptions || []) { | |
| 60 const config = Timeline.RecordingConfig[id]; | |
| 61 const enable = config.value || enabledOptions && enabledOptions.indexOf(id ) !== -1; | |
| 62 this._createSettingCheckBox(this.contentElement, config, enable); | |
|
caseq
2016/12/09 02:11:12
This queitly looses the "forceEnable" value semant
alph
2016/12/09 21:36:10
Done.
| |
| 63 } | |
| 64 const actionButton = this.contentElement.createChild('div').createChild('but ton', 'action-button'); | |
| 65 actionButton.textContent = Common.UIString('Start'); | |
| 66 actionButton.addEventListener('click', () => this.action()); | |
| 67 } | |
| 68 | |
| 69 /** | |
| 70 * @param {!Element} parent | |
| 71 * @param {!Timeline.RecordingOption} config | |
| 72 * @param {boolean} defaultValue | |
| 73 */ | |
| 74 _createSettingCheckBox(parent, config, defaultValue) { | |
| 75 const setting = config.setting ? Common.settings.createSetting(config.settin g, defaultValue) : null; | |
| 76 const div = parent.createChild('div', 'recording-setting'); | |
| 77 const label = div.createChild('label'); | |
| 78 const checkbox = label.createChild('input'); | |
| 79 checkbox.setAttribute('type', 'checkbox'); | |
| 80 checkbox.setAttribute('id', config.id); | |
| 81 if (setting ? setting.get() : defaultValue) | |
| 82 checkbox.setAttribute('checked', true); | |
| 83 if (setting) | |
| 84 checkbox.addEventListener('change', event => setting.set(event.target.chec ked)); | |
| 85 label.createTextChild(config.title); | |
| 86 if (config.description) | |
| 87 div.createChild('div', 'recording-setting-description').textContent = conf ig.description; | |
| 88 } | |
| 89 | |
| 90 action() { | |
| 91 UI.actionRegistry.action('timeline.toggle-recording').execute(); | |
| 92 } | |
| 93 }; | |
| 94 | |
| 95 Timeline.LoadPerspective = class extends Timeline.Perspective { | |
| 96 constructor() { | |
| 97 super( | |
| 98 Common.UIString( | |
| 99 'Page Load mode allows you to analyze how fast the page is loaded an d becomes responsive.\n' + | |
| 100 'In this mode the page is automatically reloaded right after the rec ording has started. ' + | |
| 101 'During recording it collects information about network requests, sc reen state updates, ' + | |
| 102 'and CPU threads acivity along with JavaScript stacks. ' + | |
| 103 'Recording is stopped automatically shortly after the page processes load event.'), | |
| 104 [Timeline.RecordingConfig.screenshots.id], | |
|
caseq
2016/12/09 02:11:12
Let's pass Timeline.RecordingConfig.screenshots, T
alph
2016/12/09 21:36:10
Done.
| |
| 105 [Timeline.RecordingConfig.network.id, Timeline.RecordingConfig.screensho ts.id]); | |
| 106 } | |
| 107 | |
| 108 /** | |
| 109 * @override | |
| 110 */ | |
| 111 action() { | |
| 112 SDK.targetManager.reloadPage(); | |
| 113 } | |
| 114 }; | |
| 115 | |
| 116 Timeline.ResponsivenessPerspective = class extends Timeline.Perspective { | |
| 117 constructor() { | |
| 118 super( | |
| 119 Common.UIString('Record page responsiveness.'), [Timeline.RecordingConfi g.screenshots.id], | |
| 120 [Timeline.RecordingConfig.network.id]); | |
| 121 } | |
| 122 }; | |
| 123 | |
| 124 Timeline.JavaScriptPerspective = class extends Timeline.Perspective { | |
| 125 constructor() { | |
| 126 super(Common.UIString( | |
| 127 'This mode is useful when you want to focus on JavaScript performance. ' + | |
| 128 'All the options besides sampling CPU profiler are turned off to minimiz e measurement errors.')); | |
| 129 } | |
| 130 }; | |
| 131 | |
| 132 Timeline.CustomPerspective = class extends Timeline.Perspective { | |
| 133 constructor() { | |
| 134 const config = Timeline.RecordingConfig; | |
| 135 super( | |
| 136 Common.UIString('Advanced mode that allows you to customize recording op tions.'), | |
| 137 [config.network.id, config.javascript.id, config.screenshots.id, config. memory.id, config.paints.id], | |
| 138 [config.network.id, config.screenshots.id]); | |
| 139 } | |
| 140 }; | |
| 141 | |
| 142 Timeline.LandingPage = class extends UI.VBox { | |
| 143 constructor() { | |
| 144 super(true); | |
| 145 this.registerRequiredCSS('timeline/timelineLandingPage.css'); | |
| 146 this.contentElement.classList.add('timeline-landing-page', 'fill'); | |
| 147 const perspectives = Timeline.TimelinePanel.Perspectives; | |
| 148 this._tabbedPane = new UI.TabbedPane(); | |
| 149 this._tabbedPane.registerRequiredCSS('timeline/timelineLandingPage.css'); | |
| 150 this._tabbedPane.registerRequiredCSS('ui_lazy/dialog.css'); | |
| 151 this._tabbedPane.contentElement.classList.add('timeline-landing-page'); | |
| 152 this._tabbedPane.setTabSlider(true); | |
| 153 this._tabbedPane.appendTab(perspectives.Load, Common.UIString('Page Load'), new Timeline.LoadPerspective()); | |
| 154 this._tabbedPane.appendTab( | |
| 155 perspectives.Responsiveness, Common.UIString('Responsiveness'), new Time line.ResponsivenessPerspective()); | |
| 156 this._tabbedPane.appendTab( | |
| 157 perspectives.JavaScript, Common.UIString('JavaScript'), new Timeline.Jav aScriptPerspective()); | |
| 158 this._tabbedPane.appendTab(perspectives.Custom, Common.UIString('Custom'), n ew Timeline.CustomPerspective()); | |
| 159 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this); | |
| 160 this._tabbedPane.show(this.contentElement); | |
| 161 this._perspectiveSetting = | |
| 162 Common.settings.createSetting('timelinePerspective', Timeline.TimelinePa nel.Perspectives.Load); | |
| 163 this._perspectiveSetting.addChangeListener(this._perspectiveChanged, this); | |
| 164 } | |
| 165 | |
| 166 /** | |
| 167 * @param {!Common.Event} event | |
| 168 */ | |
| 169 _tabSelected(event) { | |
| 170 if (this._perspectiveSetting.get() !== event.data.tabId) | |
| 171 this._perspectiveSetting.set(event.data.tabId); | |
| 172 } | |
| 173 | |
| 174 _perspectiveChanged() { | |
| 175 this._tabbedPane.selectTab(this._perspectiveSetting.get()); | |
| 176 } | |
| 177 }; | |
| OLD | NEW |