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 value: false, | |
|
caseq
2016/12/08 17:59:04
So what do these values mean? They are global and
alph
2016/12/08 21:45:48
These are meta defaults. I have to pass a default
| |
| 12 title: Common.UIString('Network'), | |
| 13 description: Common.UIString('Capture network requests information.'), | |
| 14 setting: 'timelineCaptureNetwork' | |
| 15 }, | |
| 16 'javascript': { | |
| 17 value: true, | |
| 18 title: Common.UIString('JavaScript'), | |
| 19 description: Common.UIString('Use sampling CPU profiler to collect JavaScrip t stacks.'), | |
| 20 setting: 'timelineEnableJSSampling' | |
| 21 }, | |
| 22 'screenshots': { | |
| 23 value: false, | |
| 24 title: Common.UIString('Screenshots'), | |
| 25 description: | |
| 26 Common.UIString('Collect page screenshots, so you can observe how the pa ge was evolving during recording.'), | |
| 27 setting: 'timelineCaptureFilmStrip' | |
| 28 }, | |
| 29 'paints': { | |
| 30 value: false, | |
| 31 title: Common.UIString('Paints'), | |
| 32 description: Common.UIString( | |
| 33 'Capture graphics layer positions and rasterization draw calls (moderate performance overhead).'), | |
| 34 setting: 'timelineCaptureLayersAndPictures' | |
| 35 }, | |
| 36 'memory': { | |
| 37 value: true, | |
| 38 title: Common.UIString('Memory'), | |
| 39 description: Common.UIString('Capture memory information on every timeline e vent.'), | |
| 40 setting: 'timelineCaptureMemory' | |
| 41 } | |
| 42 }; | |
| 43 | |
| 44 Timeline.Perspective = class extends UI.VBox { | |
| 45 /** | |
| 46 * @param {string} id | |
| 47 * @param {string} title | |
| 48 * @param {string} description | |
| 49 * @param {!Array<string>=} visibleOptions | |
| 50 */ | |
| 51 constructor(id, title, description, visibleOptions) { | |
| 52 super(false); | |
| 53 this.id = id; | |
|
caseq
2016/12/08 17:59:04
is this used?
alph
2016/12/08 21:45:48
Done.
| |
| 54 this.title = title; | |
|
caseq
2016/12/08 17:59:04
ditto.
alph
2016/12/08 21:45:48
Done.
| |
| 55 this.description = description; | |
|
caseq
2016/12/08 17:59:04
do we need it as a member?
alph
2016/12/08 21:45:48
Done.
| |
| 56 this._visibleOptions = visibleOptions || []; | |
|
caseq
2016/12/08 17:59:04
why is this necessary?
alph
2016/12/08 21:45:48
Done.
| |
| 57 this.contentElement.classList.add('timeline-perspective-body'); | |
| 58 this.contentElement.createChild('div', 'timeline-perspective-description').t extContent = this.description; | |
| 59 for (let id of this._visibleOptions) | |
|
caseq
2016/12/08 17:59:04
this shadows a function parameter, can we have a d
alph
2016/12/08 21:45:48
Done.
| |
| 60 this._createSettingCheckBox(this.contentElement, id, Timeline.RecordingCon fig[id]); | |
| 61 const footer = this.contentElement.createChild('div', 'timeline-perspective- footer'); | |
| 62 const actionButton = footer.createChild('button'); | |
| 63 actionButton.textContent = Common.UIString('Start'); | |
| 64 actionButton.addEventListener('click', () => this.action()); | |
| 65 } | |
| 66 | |
| 67 /** | |
| 68 * @param {!Element} parent | |
| 69 * @param {string} id | |
| 70 * @param {!Timeline.RecordingOption} config | |
| 71 */ | |
| 72 _createSettingCheckBox(parent, id, config) { | |
| 73 const setting = config.setting ? Common.settings.createSetting(config.settin g, config.value) : null; | |
| 74 const div = parent.createChild('div', 'recording-setting'); | |
| 75 const label = div.createChild('label'); | |
| 76 const checkbox = label.createChild('input'); | |
| 77 checkbox.setAttribute('type', 'checkbox'); | |
| 78 checkbox.setAttribute('id', id); | |
| 79 if (setting ? setting.get() : config.value) | |
| 80 checkbox.setAttribute('checked', true); | |
| 81 if (setting) | |
| 82 checkbox.addEventListener('change', event => setting.set(event.target.chec ked)); | |
| 83 label.createTextChild(config.title); | |
| 84 if (config.description) | |
| 85 div.createChild('div', 'recording-setting-description').textContent = conf ig.description; | |
| 86 } | |
| 87 | |
| 88 action() { | |
| 89 UI.actionRegistry.action('timeline.toggle-recording').execute(); | |
| 90 } | |
| 91 }; | |
| 92 | |
| 93 Timeline.LoadPerspective = class extends Timeline.Perspective { | |
| 94 constructor() { | |
| 95 super( | |
| 96 Timeline.TimelinePanel.Perspectives.Load, Common.UIString('Page Load'), | |
| 97 Common.UIString( | |
| 98 'Page Load mode allows you to analyze how fast the page is loaded an d becomes responsive.\n' + | |
| 99 'In this mode the page is automatically reloaded right after the rec ording has started. ' + | |
| 100 'During recording it collects information about network requests, sc reen state updates, ' + | |
| 101 'and CPU threads acivity along with JavaScript stacks. ' + | |
| 102 'Recording is stopped automatically shortly after the page processes load event.'), | |
| 103 ['screenshots']); | |
| 104 Timeline.RecordingConfig.network.value = true; | |
|
caseq
2016/12/08 17:59:04
Does it actually have any effect?
alph
2016/12/08 21:45:48
Done.
| |
| 105 Timeline.RecordingConfig.screenshots.value = true; | |
| 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 Timeline.TimelinePanel.Perspectives.Responsiveness, Common.UIString('Res ponsiveness'), | |
| 120 Common.UIString('Record page responsiveness.'), ['screenshots']); | |
| 121 Timeline.RecordingConfig.network.value = true; | |
| 122 } | |
| 123 }; | |
| 124 | |
| 125 Timeline.JavaScriptPerspective = class extends Timeline.Perspective { | |
| 126 constructor() { | |
| 127 super( | |
| 128 Timeline.TimelinePanel.Perspectives.JavaScript, Common.UIString('JavaScr ipt'), | |
| 129 Common.UIString( | |
| 130 'This mode is useful when you want to focus on JavaScript performanc e. ' + | |
| 131 'All the options besides sampling CPU profiler are turned off to min imize measurement errors.')); | |
| 132 } | |
| 133 }; | |
| 134 | |
| 135 Timeline.CustomPerspective = class extends Timeline.Perspective { | |
| 136 constructor() { | |
| 137 super( | |
| 138 Timeline.TimelinePanel.Perspectives.Custom, Common.UIString('Custom'), | |
| 139 Common.UIString('Advanced mode that allows you to customize recording op tions.'), | |
| 140 ['network', 'javascript', 'screenshots', 'memory', 'paints']); | |
|
caseq
2016/12/08 17:59:04
I'd prefer variables instead of strings there, so
alph
2016/12/08 21:45:48
Done.
| |
| 141 } | |
| 142 }; | |
| 143 | |
| 144 Timeline.LandingPage = class extends UI.VBox { | |
| 145 constructor() { | |
| 146 super(true); | |
| 147 this.registerRequiredCSS('timeline/timelineLandingPage.css'); | |
| 148 this.contentElement.classList.add('timeline-landing-page', 'fill'); | |
| 149 this._tabbedLocation = UI.viewManager.createTabbedLocation(() => {}, 'timeli ne-landing-page'); | |
| 150 this._tabbedPane = this._tabbedLocation.tabbedPane(); | |
| 151 this._tabbedPane.registerRequiredCSS('timeline/timelineLandingPage.css'); | |
| 152 this._tabbedPane.registerRequiredCSS('ui_lazy/dialog.css'); | |
| 153 this._tabbedPane.contentElement.classList.add('timeline-landing-page'); | |
| 154 this._tabbedPane.setTabSlider(true); | |
| 155 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this); | |
| 156 this._tabbedPane.show(this.contentElement); | |
| 157 this._perspectiveSetting = Common.settings.createSetting('timelinePerspectiv e', 'load'); | |
| 158 this._perspectiveSetting.addChangeListener(this._perspectiveChanged, this); | |
| 159 } | |
| 160 | |
| 161 /** | |
| 162 * @param {!Common.Event} event | |
| 163 */ | |
| 164 _tabSelected(event) { | |
| 165 this._perspectiveSetting.set(event.data.tabId) | |
| 166 } | |
| 167 | |
| 168 _perspectiveChanged() { | |
| 169 this._tabbedPane.selectTab(this._perspectiveSetting.get()); | |
| 170 } | |
| 171 }; | |
| OLD | NEW |