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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkPanel.js

Issue 2914033002: [Devtools] NetworkLogView now uses NetworkLog as source of truth. (Closed)
Patch Set: changes 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 22 matching lines...) Expand all
33 * @unrestricted 33 * @unrestricted
34 */ 34 */
35 Network.NetworkPanel = class extends UI.Panel { 35 Network.NetworkPanel = class extends UI.Panel {
36 constructor() { 36 constructor() {
37 super('network'); 37 super('network');
38 this.registerRequiredCSS('network/networkPanel.css'); 38 this.registerRequiredCSS('network/networkPanel.css');
39 39
40 this._networkLogShowOverviewSetting = Common.settings.createSetting('network LogShowOverview', true); 40 this._networkLogShowOverviewSetting = Common.settings.createSetting('network LogShowOverview', true);
41 this._networkLogLargeRowsSetting = Common.settings.createSetting('networkLog LargeRows', false); 41 this._networkLogLargeRowsSetting = Common.settings.createSetting('networkLog LargeRows', false);
42 this._networkRecordFilmStripSetting = Common.settings.createSetting('network RecordFilmStripSetting', false); 42 this._networkRecordFilmStripSetting = Common.settings.createSetting('network RecordFilmStripSetting', false);
43
43 this._toggleRecordAction = /** @type {!UI.Action }*/ (UI.actionRegistry.acti on('network.toggle-recording')); 44 this._toggleRecordAction = /** @type {!UI.Action }*/ (UI.actionRegistry.acti on('network.toggle-recording'));
44 45
45 /** @type {?PerfUI.FilmStripView} */ 46 /** @type {?PerfUI.FilmStripView} */
46 this._filmStripView = null; 47 this._filmStripView = null;
47 /** @type {?Network.NetworkPanel.FilmStripRecorder} */ 48 /** @type {?Network.NetworkPanel.FilmStripRecorder} */
48 this._filmStripRecorder = null; 49 this._filmStripRecorder = null;
49 50
50 this._panelToolbar = new UI.Toolbar('', this.element); 51 this._panelToolbar = new UI.Toolbar('', this.element);
51 this._filterBar = new UI.FilterBar('networkPanel', true); 52 this._filterBar = new UI.FilterBar('networkPanel', true);
52 this._filterBar.show(this.element); 53 this._filterBar.show(this.element);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 this._updateUI(); 103 this._updateUI();
103 104
104 SDK.targetManager.addModelListener( 105 SDK.targetManager.addModelListener(
105 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.WillReloadPage, this ._willReloadPage, this); 106 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.WillReloadPage, this ._willReloadPage, this);
106 SDK.targetManager.addModelListener(SDK.ResourceTreeModel, SDK.ResourceTreeMo del.Events.Load, this._load, this); 107 SDK.targetManager.addModelListener(SDK.ResourceTreeModel, SDK.ResourceTreeMo del.Events.Load, this._load, this);
107 this._networkLogView.addEventListener(Network.NetworkLogView.Events.RequestS elected, this._onRequestSelected, this); 108 this._networkLogView.addEventListener(Network.NetworkLogView.Events.RequestS elected, this._onRequestSelected, this);
108 this._networkLogView.addEventListener( 109 this._networkLogView.addEventListener(
109 Network.NetworkLogView.Events.SearchCountUpdated, this._onSearchCountUpd ated, this); 110 Network.NetworkLogView.Events.SearchCountUpdated, this._onSearchCountUpd ated, this);
110 this._networkLogView.addEventListener( 111 this._networkLogView.addEventListener(
111 Network.NetworkLogView.Events.SearchIndexUpdated, this._onSearchIndexUpd ated, this); 112 Network.NetworkLogView.Events.SearchIndexUpdated, this._onSearchIndexUpd ated, this);
112 this._networkLogView.addEventListener(Network.NetworkLogView.Events.UpdateRe quest, this._onUpdateRequest, this); 113 NetworkLog.networkLog.addEventListener(NetworkLog.NetworkLog.Events.RequestA dded, this._onUpdateRequest, this);
114 NetworkLog.networkLog.addEventListener(NetworkLog.NetworkLog.Events.RequestU pdated, this._onUpdateRequest, this);
115 NetworkLog.networkLog.addEventListener(NetworkLog.NetworkLog.Events.Reset, t his._onNetworkLogReset, this);
113 116
114 Components.DataSaverInfobar.maybeShowInPanel(this); 117 Components.DataSaverInfobar.maybeShowInPanel(this);
115 } 118 }
116 119
117 /** 120 /**
118 * @param {!Array<{filterType: !Network.NetworkLogView.FilterType, filterValue : string}>} filters 121 * @param {!Array<{filterType: !Network.NetworkLogView.FilterType, filterValue : string}>} filters
119 */ 122 */
120 static revealAndFilter(filters) { 123 static revealAndFilter(filters) {
121 var panel = Network.NetworkPanel._instance(); 124 var panel = Network.NetworkPanel._instance();
122 var filterString = ''; 125 var filterString = '';
(...skipping 16 matching lines...) Expand all
139 _onWindowChanged(event) { 142 _onWindowChanged(event) {
140 var startTime = Math.max(this._calculator.minimumBoundary(), event.data.star tTime / 1000); 143 var startTime = Math.max(this._calculator.minimumBoundary(), event.data.star tTime / 1000);
141 var endTime = Math.min(this._calculator.maximumBoundary(), event.data.endTim e / 1000); 144 var endTime = Math.min(this._calculator.maximumBoundary(), event.data.endTim e / 1000);
142 this._networkLogView.setWindow(startTime, endTime); 145 this._networkLogView.setWindow(startTime, endTime);
143 } 146 }
144 147
145 _createToolbarButtons() { 148 _createToolbarButtons() {
146 this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._tog gleRecordAction)); 149 this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._tog gleRecordAction));
147 150
148 this._clearButton = new UI.ToolbarButton(Common.UIString('Clear'), 'largeico n-clear'); 151 this._clearButton = new UI.ToolbarButton(Common.UIString('Clear'), 'largeico n-clear');
149 this._clearButton.addEventListener(UI.ToolbarButton.Events.Click, this._onCl earButtonClicked, this); 152 this._clearButton.addEventListener(UI.ToolbarButton.Events.Click, () => Netw orkLog.networkLog.reset(), this);
150 this._panelToolbar.appendToolbarItem(this._clearButton); 153 this._panelToolbar.appendToolbarItem(this._clearButton);
151 this._panelToolbar.appendSeparator(); 154 this._panelToolbar.appendSeparator();
152 var recordFilmStripButton = new UI.ToolbarSettingToggle( 155 var recordFilmStripButton = new UI.ToolbarSettingToggle(
153 this._networkRecordFilmStripSetting, 'largeicon-camera', Common.UIString ('Capture screenshots')); 156 this._networkRecordFilmStripSetting, 'largeicon-camera', Common.UIString ('Capture screenshots'));
154 this._panelToolbar.appendToolbarItem(recordFilmStripButton); 157 this._panelToolbar.appendToolbarItem(recordFilmStripButton);
155 158
156 this._panelToolbar.appendToolbarItem(this._filterBar.filterButton()); 159 this._panelToolbar.appendToolbarItem(this._filterBar.filterButton());
157 this._panelToolbar.appendSeparator(); 160 this._panelToolbar.appendSeparator();
158 161
159 this._panelToolbar.appendText(Common.UIString('View:')); 162 this._panelToolbar.appendText(Common.UIString('View:'));
160 163
161 var largerRequestsButton = new UI.ToolbarSettingToggle( 164 var largerRequestsButton = new UI.ToolbarSettingToggle(
162 this._networkLogLargeRowsSetting, 'largeicon-large-list', Common.UIStrin g('Use large request rows'), 165 this._networkLogLargeRowsSetting, 'largeicon-large-list', Common.UIStrin g('Use large request rows'),
163 Common.UIString('Use small request rows')); 166 Common.UIString('Use small request rows'));
164 this._panelToolbar.appendToolbarItem(largerRequestsButton); 167 this._panelToolbar.appendToolbarItem(largerRequestsButton);
165 168
166 var showOverviewButton = new UI.ToolbarSettingToggle( 169 var showOverviewButton = new UI.ToolbarSettingToggle(
167 this._networkLogShowOverviewSetting, 'largeicon-waterfall', Common.UIStr ing('Show overview'), 170 this._networkLogShowOverviewSetting, 'largeicon-waterfall', Common.UIStr ing('Show overview'),
168 Common.UIString('Hide overview')); 171 Common.UIString('Hide overview'));
169 this._panelToolbar.appendToolbarItem(showOverviewButton); 172 this._panelToolbar.appendToolbarItem(showOverviewButton);
170 173
171 if (Runtime.experiments.isEnabled('networkGroupingRequests')) { 174 if (Runtime.experiments.isEnabled('networkGroupingRequests')) {
172 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox( 175 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox(
173 Common.moduleSetting('network.group-by-frame'), '', Common.UIString('G roup by frame'))); 176 Common.moduleSetting('network.group-by-frame'), '', Common.UIString('G roup by frame')));
174 } 177 }
175 178
176 this._panelToolbar.appendSeparator(); 179 this._panelToolbar.appendSeparator();
177 this._preserveLogSetting = Common.moduleSetting('network.preserve-log'); 180 this._preserveLogSetting = Common.moduleSetting('network_log.preserve-log');
178 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox( 181 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox(
179 this._preserveLogSetting, Common.UIString('Do not clear log on page relo ad / navigation'), 182 this._preserveLogSetting, Common.UIString('Do not clear log on page relo ad / navigation'),
180 Common.UIString('Preserve log'))); 183 Common.UIString('Preserve log')));
181 184
182 this._disableCacheCheckbox = new UI.ToolbarSettingCheckbox( 185 this._disableCacheCheckbox = new UI.ToolbarSettingCheckbox(
183 Common.moduleSetting('cacheDisabled'), Common.UIString('Disable cache (w hile DevTools is open)'), 186 Common.moduleSetting('cacheDisabled'), Common.UIString('Disable cache (w hile DevTools is open)'),
184 Common.UIString('Disable cache')); 187 Common.UIString('Disable cache'));
185 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox); 188 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox);
186 189
187 this._panelToolbar.appendSeparator(); 190 this._panelToolbar.appendSeparator();
188 this._panelToolbar.appendToolbarItem(MobileThrottling.NetworkConditionsSelec tor.createOfflineToolbarCheckbox()); 191 this._panelToolbar.appendToolbarItem(MobileThrottling.NetworkConditionsSelec tor.createOfflineToolbarCheckbox());
189 this._panelToolbar.appendToolbarItem(this._createNetworkConditionsSelect()); 192 this._panelToolbar.appendToolbarItem(this._createNetworkConditionsSelect());
190 193
191 this._panelToolbar.appendToolbarItem(new UI.ToolbarItem(this._progressBarCon tainer)); 194 this._panelToolbar.appendToolbarItem(new UI.ToolbarItem(this._progressBarCon tainer));
192 } 195 }
193 196
194 /** 197 /**
195 * @return {!UI.ToolbarComboBox} 198 * @return {!UI.ToolbarComboBox}
196 */ 199 */
197 _createNetworkConditionsSelect() { 200 _createNetworkConditionsSelect() {
198 var toolbarItem = new UI.ToolbarComboBox(null); 201 var toolbarItem = new UI.ToolbarComboBox(null);
199 toolbarItem.setMaxWidth(140); 202 toolbarItem.setMaxWidth(140);
200 MobileThrottling.NetworkConditionsSelector.decorateSelect(toolbarItem.select Element()); 203 MobileThrottling.NetworkConditionsSelector.decorateSelect(toolbarItem.select Element());
201 return toolbarItem; 204 return toolbarItem;
202 } 205 }
203 206
204 _toggleRecording() { 207 _toggleRecording() {
205 if (!this._preserveLogSetting.get() && !this._toggleRecordAction.toggled()) 208 if (!this._preserveLogSetting.get() && !this._toggleRecordAction.toggled())
206 this._reset(); 209 NetworkLog.networkLog.reset();
207 this._toggleRecord(!this._toggleRecordAction.toggled()); 210 this._toggleRecord(!this._toggleRecordAction.toggled());
208 } 211 }
209 212
210 /** 213 /**
211 * @param {boolean} toggled 214 * @param {boolean} toggled
212 */ 215 */
213 _toggleRecord(toggled) { 216 _toggleRecord(toggled) {
214 this._toggleRecordAction.setToggled(toggled); 217 this._toggleRecordAction.setToggled(toggled);
215 this._networkLogView.setRecording(toggled); 218 this._networkLogView.setRecording(toggled);
216 if (!toggled && this._filmStripRecorder) 219 if (!toggled && this._filmStripRecorder)
217 this._filmStripRecorder.stopRecording(this._filmStripAvailable.bind(this)) ; 220 this._filmStripRecorder.stopRecording(this._filmStripAvailable.bind(this)) ;
221 // TODO(einbinder) This should be moved to a setting/action that NetworkLog owns but NetworkPanel controls, but
222 // always be present in the command menu.
223 NetworkLog.networkLog.setIsRecording(toggled);
218 } 224 }
219 225
220 /** 226 /**
221 * @param {?SDK.FilmStripModel} filmStripModel 227 * @param {?SDK.FilmStripModel} filmStripModel
222 */ 228 */
223 _filmStripAvailable(filmStripModel) { 229 _filmStripAvailable(filmStripModel) {
224 if (!filmStripModel) 230 if (!filmStripModel)
225 return; 231 return;
226 var calculator = this._networkLogView.timeCalculator(); 232 var calculator = this._networkLogView.timeCalculator();
227 this._filmStripView.setModel(filmStripModel, calculator.minimumBoundary() * 1000, calculator.boundarySpan() * 1000); 233 this._filmStripView.setModel(filmStripModel, calculator.minimumBoundary() * 1000, calculator.boundarySpan() * 1000);
228 this._networkOverview.setFilmStripModel(filmStripModel); 234 this._networkOverview.setFilmStripModel(filmStripModel);
229 var timestamps = filmStripModel.frames().map(mapTimestamp); 235 var timestamps = filmStripModel.frames().map(mapTimestamp);
230 236
231 /** 237 /**
232 * @param {!SDK.FilmStripModel.Frame} frame 238 * @param {!SDK.FilmStripModel.Frame} frame
233 * @return {number} 239 * @return {number}
234 */ 240 */
235 function mapTimestamp(frame) { 241 function mapTimestamp(frame) {
236 return frame.timestamp / 1000; 242 return frame.timestamp / 1000;
237 } 243 }
238 244
239 this._networkLogView.addFilmStripFrames(timestamps); 245 this._networkLogView.addFilmStripFrames(timestamps);
240 } 246 }
241 247
242 /** 248 _onNetworkLogReset() {
243 * @param {!Common.Event} event
244 */
245 _onClearButtonClicked(event) {
246 this._reset();
247 }
248
249 _reset() {
250 this._calculator.reset();
251 this._overviewPane.reset();
252 this._networkLogView.reset();
253 Network.BlockedURLsPane.reset(); 249 Network.BlockedURLsPane.reset();
250 if (!this._preserveLogSetting.get()) {
251 this._calculator.reset();
252 this._overviewPane.reset();
253 }
254 if (this._filmStripView) 254 if (this._filmStripView)
255 this._resetFilmStripView(); 255 this._resetFilmStripView();
256 } 256 }
257 257
258 /** 258 /**
259 * @param {!Common.Event} event 259 * @param {!Common.Event} event
260 */ 260 */
261 _willReloadPage(event) { 261 _willReloadPage(event) {
262 if (!this._preserveLogSetting.get())
263 this._reset();
264 this._toggleRecord(true); 262 this._toggleRecord(true);
265 if (this._pendingStopTimer) { 263 if (this._pendingStopTimer) {
266 clearTimeout(this._pendingStopTimer); 264 clearTimeout(this._pendingStopTimer);
267 delete this._pendingStopTimer; 265 delete this._pendingStopTimer;
268 } 266 }
269 if (this.isShowing() && this._filmStripRecorder) 267 if (this.isShowing() && this._filmStripRecorder)
270 this._filmStripRecorder.startRecording(); 268 this._filmStripRecorder.startRecording();
271 } 269 }
272 270
273 /** 271 /**
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 * @param {string} actionId 710 * @param {string} actionId
713 * @return {boolean} 711 * @return {boolean}
714 */ 712 */
715 handleAction(context, actionId) { 713 handleAction(context, actionId) {
716 var panel = UI.context.flavor(Network.NetworkPanel); 714 var panel = UI.context.flavor(Network.NetworkPanel);
717 console.assert(panel && panel instanceof Network.NetworkPanel); 715 console.assert(panel && panel instanceof Network.NetworkPanel);
718 panel._toggleRecording(); 716 panel._toggleRecording();
719 return true; 717 return true;
720 } 718 }
721 }; 719 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698