OLD | NEW |
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 this._updateUI(); | 101 this._updateUI(); |
102 | 102 |
103 SDK.targetManager.addModelListener( | 103 SDK.targetManager.addModelListener( |
104 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.WillReloadPage, this
._willReloadPage, this); | 104 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.WillReloadPage, this
._willReloadPage, this); |
105 SDK.targetManager.addModelListener(SDK.ResourceTreeModel, SDK.ResourceTreeMo
del.Events.Load, this._load, this); | 105 SDK.targetManager.addModelListener(SDK.ResourceTreeModel, SDK.ResourceTreeMo
del.Events.Load, this._load, this); |
106 this._networkLogView.addEventListener(Network.NetworkLogView.Events.RequestS
elected, this._onRequestSelected, this); | 106 this._networkLogView.addEventListener(Network.NetworkLogView.Events.RequestS
elected, this._onRequestSelected, this); |
107 this._networkLogView.addEventListener( | 107 this._networkLogView.addEventListener( |
108 Network.NetworkLogView.Events.SearchCountUpdated, this._onSearchCountUpd
ated, this); | 108 Network.NetworkLogView.Events.SearchCountUpdated, this._onSearchCountUpd
ated, this); |
109 this._networkLogView.addEventListener( | 109 this._networkLogView.addEventListener( |
110 Network.NetworkLogView.Events.SearchIndexUpdated, this._onSearchIndexUpd
ated, this); | 110 Network.NetworkLogView.Events.SearchIndexUpdated, this._onSearchIndexUpd
ated, this); |
111 this._networkLogView.addEventListener(Network.NetworkLogView.Events.UpdateRe
quest, this._onUpdateRequest, this); | 111 NetworkLog.networkLog.addEventListener(NetworkLog.NetworkLog.Events.RequestU
pdated, this._onUpdateRequest, this); |
| 112 NetworkLog.networkLog.addEventListener(NetworkLog.NetworkLog.Events.Reset, t
his._onNetworkLogReset, this); |
| 113 |
112 | 114 |
113 Components.DataSaverInfobar.maybeShowInPanel(this); | 115 Components.DataSaverInfobar.maybeShowInPanel(this); |
114 } | 116 } |
115 | 117 |
116 /** | 118 /** |
117 * @param {!Array<{filterType: !Network.NetworkLogView.FilterType, filterValue
: string}>} filters | 119 * @param {!Array<{filterType: !Network.NetworkLogView.FilterType, filterValue
: string}>} filters |
118 */ | 120 */ |
119 static revealAndFilter(filters) { | 121 static revealAndFilter(filters) { |
120 var panel = Network.NetworkPanel._instance(); | 122 var panel = Network.NetworkPanel._instance(); |
121 var filterString = ''; | 123 var filterString = ''; |
(...skipping 16 matching lines...) Expand all Loading... |
138 _onWindowChanged(event) { | 140 _onWindowChanged(event) { |
139 var startTime = Math.max(this._calculator.minimumBoundary(), event.data.star
tTime / 1000); | 141 var startTime = Math.max(this._calculator.minimumBoundary(), event.data.star
tTime / 1000); |
140 var endTime = Math.min(this._calculator.maximumBoundary(), event.data.endTim
e / 1000); | 142 var endTime = Math.min(this._calculator.maximumBoundary(), event.data.endTim
e / 1000); |
141 this._networkLogView.setWindow(startTime, endTime); | 143 this._networkLogView.setWindow(startTime, endTime); |
142 } | 144 } |
143 | 145 |
144 _createToolbarButtons() { | 146 _createToolbarButtons() { |
145 this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._tog
gleRecordAction)); | 147 this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._tog
gleRecordAction)); |
146 | 148 |
147 this._clearButton = new UI.ToolbarButton(Common.UIString('Clear'), 'largeico
n-clear'); | 149 this._clearButton = new UI.ToolbarButton(Common.UIString('Clear'), 'largeico
n-clear'); |
148 this._clearButton.addEventListener(UI.ToolbarButton.Events.Click, this._onCl
earButtonClicked, this); | 150 this._clearButton.addEventListener(UI.ToolbarButton.Events.Click, () => Netw
orkLog.networkLog.reset()); |
149 this._panelToolbar.appendToolbarItem(this._clearButton); | 151 this._panelToolbar.appendToolbarItem(this._clearButton); |
150 this._panelToolbar.appendSeparator(); | 152 this._panelToolbar.appendSeparator(); |
151 var recordFilmStripButton = new UI.ToolbarSettingToggle( | 153 var recordFilmStripButton = new UI.ToolbarSettingToggle( |
152 this._networkRecordFilmStripSetting, 'largeicon-camera', Common.UIString
('Capture screenshots')); | 154 this._networkRecordFilmStripSetting, 'largeicon-camera', Common.UIString
('Capture screenshots')); |
153 this._panelToolbar.appendToolbarItem(recordFilmStripButton); | 155 this._panelToolbar.appendToolbarItem(recordFilmStripButton); |
154 | 156 |
155 this._panelToolbar.appendToolbarItem(this._filterBar.filterButton()); | 157 this._panelToolbar.appendToolbarItem(this._filterBar.filterButton()); |
156 this._panelToolbar.appendSeparator(); | 158 this._panelToolbar.appendSeparator(); |
157 | 159 |
158 this._panelToolbar.appendText(Common.UIString('View:')); | 160 this._panelToolbar.appendText(Common.UIString('View:')); |
159 | 161 |
160 var largerRequestsButton = new UI.ToolbarSettingToggle( | 162 var largerRequestsButton = new UI.ToolbarSettingToggle( |
161 this._networkLogLargeRowsSetting, 'largeicon-large-list', Common.UIStrin
g('Use large request rows'), | 163 this._networkLogLargeRowsSetting, 'largeicon-large-list', Common.UIStrin
g('Use large request rows'), |
162 Common.UIString('Use small request rows')); | 164 Common.UIString('Use small request rows')); |
163 this._panelToolbar.appendToolbarItem(largerRequestsButton); | 165 this._panelToolbar.appendToolbarItem(largerRequestsButton); |
164 | 166 |
165 var showOverviewButton = new UI.ToolbarSettingToggle( | 167 var showOverviewButton = new UI.ToolbarSettingToggle( |
166 this._networkLogShowOverviewSetting, 'largeicon-waterfall', Common.UIStr
ing('Show overview'), | 168 this._networkLogShowOverviewSetting, 'largeicon-waterfall', Common.UIStr
ing('Show overview'), |
167 Common.UIString('Hide overview')); | 169 Common.UIString('Hide overview')); |
168 this._panelToolbar.appendToolbarItem(showOverviewButton); | 170 this._panelToolbar.appendToolbarItem(showOverviewButton); |
169 | 171 |
170 if (Runtime.experiments.isEnabled('networkGroupingRequests')) { | 172 if (Runtime.experiments.isEnabled('networkGroupingRequests')) { |
171 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox( | 173 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox( |
172 Common.moduleSetting('network.group-by-frame'), '', Common.UIString('G
roup by frame'))); | 174 Common.moduleSetting('network.group-by-frame'), '', Common.UIString('G
roup by frame'))); |
173 } | 175 } |
174 | 176 |
175 this._panelToolbar.appendSeparator(); | 177 this._panelToolbar.appendSeparator(); |
176 this._preserveLogSetting = Common.moduleSetting('network.preserve-log'); | 178 this._preserveLogSetting = Common.moduleSetting('network_log.preserve-log'); |
177 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox( | 179 this._panelToolbar.appendToolbarItem(new UI.ToolbarSettingCheckbox( |
178 this._preserveLogSetting, Common.UIString('Do not clear log on page relo
ad / navigation'), | 180 this._preserveLogSetting, Common.UIString('Do not clear log on page relo
ad / navigation'), |
179 Common.UIString('Preserve log'))); | 181 Common.UIString('Preserve log'))); |
180 | 182 |
181 this._disableCacheCheckbox = new UI.ToolbarSettingCheckbox( | 183 this._disableCacheCheckbox = new UI.ToolbarSettingCheckbox( |
182 Common.moduleSetting('cacheDisabled'), Common.UIString('Disable cache (w
hile DevTools is open)'), | 184 Common.moduleSetting('cacheDisabled'), Common.UIString('Disable cache (w
hile DevTools is open)'), |
183 Common.UIString('Disable cache')); | 185 Common.UIString('Disable cache')); |
184 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox); | 186 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox); |
185 | 187 |
186 this._panelToolbar.appendSeparator(); | 188 this._panelToolbar.appendSeparator(); |
187 this._panelToolbar.appendToolbarItem(NetworkConditions.NetworkConditionsSele
ctor.createOfflineToolbarCheckbox()); | 189 this._panelToolbar.appendToolbarItem(NetworkConditions.NetworkConditionsSele
ctor.createOfflineToolbarCheckbox()); |
188 this._panelToolbar.appendToolbarItem(this._createNetworkConditionsSelect()); | 190 this._panelToolbar.appendToolbarItem(this._createNetworkConditionsSelect()); |
189 | 191 |
190 this._panelToolbar.appendToolbarItem(new UI.ToolbarItem(this._progressBarCon
tainer)); | 192 this._panelToolbar.appendToolbarItem(new UI.ToolbarItem(this._progressBarCon
tainer)); |
191 } | 193 } |
192 | 194 |
193 /** | 195 /** |
194 * @return {!UI.ToolbarComboBox} | 196 * @return {!UI.ToolbarComboBox} |
195 */ | 197 */ |
196 _createNetworkConditionsSelect() { | 198 _createNetworkConditionsSelect() { |
197 var toolbarItem = new UI.ToolbarComboBox(null); | 199 var toolbarItem = new UI.ToolbarComboBox(null); |
198 toolbarItem.setMaxWidth(140); | 200 toolbarItem.setMaxWidth(140); |
199 NetworkConditions.NetworkConditionsSelector.decorateSelect(toolbarItem.selec
tElement()); | 201 NetworkConditions.NetworkConditionsSelector.decorateSelect(toolbarItem.selec
tElement()); |
200 return toolbarItem; | 202 return toolbarItem; |
201 } | 203 } |
202 | 204 |
203 _toggleRecording() { | 205 _toggleRecording() { |
204 if (!this._preserveLogSetting.get() && !this._toggleRecordAction.toggled()) | 206 if (!this._preserveLogSetting.get() && !this._toggleRecordAction.toggled()) |
205 this._reset(); | 207 NetworkLog.networkLog.reset(); |
206 this._toggleRecord(!this._toggleRecordAction.toggled()); | 208 this._toggleRecord(!this._toggleRecordAction.toggled()); |
207 } | 209 } |
208 | 210 |
209 /** | 211 /** |
210 * @param {boolean} toggled | 212 * @param {boolean} toggled |
211 */ | 213 */ |
212 _toggleRecord(toggled) { | 214 _toggleRecord(toggled) { |
213 this._toggleRecordAction.setToggled(toggled); | 215 this._toggleRecordAction.setToggled(toggled); |
214 this._networkLogView.setRecording(toggled); | 216 this._networkLogView.setRecording(toggled); |
215 if (!toggled && this._filmStripRecorder) | 217 if (!toggled && this._filmStripRecorder) |
216 this._filmStripRecorder.stopRecording(this._filmStripAvailable.bind(this))
; | 218 this._filmStripRecorder.stopRecording(this._filmStripAvailable.bind(this))
; |
| 219 // TODO(einbinder) This should be moved to a setting/action that NetworkLog
owns but NetworkPanel controls, but |
| 220 // always be present in the command menu. |
| 221 NetworkLog.networkLog.setRecording(toggled); |
217 } | 222 } |
218 | 223 |
219 /** | 224 /** |
220 * @param {?SDK.FilmStripModel} filmStripModel | 225 * @param {?SDK.FilmStripModel} filmStripModel |
221 */ | 226 */ |
222 _filmStripAvailable(filmStripModel) { | 227 _filmStripAvailable(filmStripModel) { |
223 if (!filmStripModel) | 228 if (!filmStripModel) |
224 return; | 229 return; |
225 var calculator = this._networkLogView.timeCalculator(); | 230 var calculator = this._networkLogView.timeCalculator(); |
226 this._filmStripView.setModel(filmStripModel, calculator.minimumBoundary() *
1000, calculator.boundarySpan() * 1000); | 231 this._filmStripView.setModel(filmStripModel, calculator.minimumBoundary() *
1000, calculator.boundarySpan() * 1000); |
227 this._networkOverview.setFilmStripModel(filmStripModel); | 232 this._networkOverview.setFilmStripModel(filmStripModel); |
228 var timestamps = filmStripModel.frames().map(mapTimestamp); | 233 var timestamps = filmStripModel.frames().map(mapTimestamp); |
229 | 234 |
230 /** | 235 /** |
231 * @param {!SDK.FilmStripModel.Frame} frame | 236 * @param {!SDK.FilmStripModel.Frame} frame |
232 * @return {number} | 237 * @return {number} |
233 */ | 238 */ |
234 function mapTimestamp(frame) { | 239 function mapTimestamp(frame) { |
235 return frame.timestamp / 1000; | 240 return frame.timestamp / 1000; |
236 } | 241 } |
237 | 242 |
238 this._networkLogView.addFilmStripFrames(timestamps); | 243 this._networkLogView.addFilmStripFrames(timestamps); |
239 } | 244 } |
240 | 245 |
241 /** | 246 _onNetworkLogReset() { |
242 * @param {!Common.Event} event | |
243 */ | |
244 _onClearButtonClicked(event) { | |
245 this._reset(); | |
246 } | |
247 | |
248 _reset() { | |
249 this._calculator.reset(); | 247 this._calculator.reset(); |
250 this._overviewPane.reset(); | 248 this._overviewPane.reset(); |
251 this._networkLogView.reset(); | |
252 Network.BlockedURLsPane.reset(); | 249 Network.BlockedURLsPane.reset(); |
253 if (this._filmStripView) | 250 if (this._filmStripView) |
254 this._resetFilmStripView(); | 251 this._resetFilmStripView(); |
255 } | 252 } |
256 | 253 |
257 /** | 254 /** |
258 * @param {!Common.Event} event | 255 * @param {!Common.Event} event |
259 */ | 256 */ |
260 _willReloadPage(event) { | 257 _willReloadPage(event) { |
261 if (!this._preserveLogSetting.get()) | |
262 this._reset(); | |
263 this._toggleRecord(true); | 258 this._toggleRecord(true); |
264 if (this._pendingStopTimer) { | 259 if (this._pendingStopTimer) { |
265 clearTimeout(this._pendingStopTimer); | 260 clearTimeout(this._pendingStopTimer); |
266 delete this._pendingStopTimer; | 261 delete this._pendingStopTimer; |
267 } | 262 } |
268 if (this.isShowing() && this._filmStripRecorder) | 263 if (this.isShowing() && this._filmStripRecorder) |
269 this._filmStripRecorder.startRecording(); | 264 this._filmStripRecorder.startRecording(); |
270 } | 265 } |
271 | 266 |
272 /** | 267 /** |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 * @param {string} actionId | 706 * @param {string} actionId |
712 * @return {boolean} | 707 * @return {boolean} |
713 */ | 708 */ |
714 handleAction(context, actionId) { | 709 handleAction(context, actionId) { |
715 var panel = UI.context.flavor(Network.NetworkPanel); | 710 var panel = UI.context.flavor(Network.NetworkPanel); |
716 console.assert(panel && panel instanceof Network.NetworkPanel); | 711 console.assert(panel && panel instanceof Network.NetworkPanel); |
717 panel._toggleRecording(); | 712 panel._toggleRecording(); |
718 return true; | 713 return true; |
719 } | 714 } |
720 }; | 715 }; |
OLD | NEW |