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

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

Issue 1186083003: [DevTools] Move network throttling to network panel. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged in device mode Created 5 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 | Annotate | Revision Log
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 * @return {?WebInspector.SourceFrame} 107 * @return {?WebInspector.SourceFrame}
108 */ 108 */
109 function sourceFrameGetter() 109 function sourceFrameGetter()
110 { 110 {
111 return this._networkItemView.currentSourceFrame(); 111 return this._networkItemView.currentSourceFrame();
112 } 112 }
113 WebInspector.GoToLineDialog.install(this, sourceFrameGetter.bind(this)); 113 WebInspector.GoToLineDialog.install(this, sourceFrameGetter.bind(this));
114 WebInspector.DataSaverInfobar.maybeShowInPanel(this); 114 WebInspector.DataSaverInfobar.maybeShowInPanel(this);
115 } 115 }
116 116
117 /** @type {!Array.<!{title: string, value: !WebInspector.NetworkManager.Conditio ns}>} */
118 WebInspector.NetworkPanel._networkConditionsPresets = [
119 {title: "Offline", value: {throughput: 0 * 1024 / 8, latency: 0}},
120 {title: "GPRS", value: {throughput: 50 * 1024 / 8, latency: 500}},
121 {title: "Regular 2G", value: {throughput: 250 * 1024 / 8, latency: 300}},
122 {title: "Good 2G", value: {throughput: 450 * 1024 / 8, latency: 150}},
123 {title: "Regular 3G", value: {throughput: 750 * 1024 / 8, latency: 100}},
124 {title: "Good 3G", value: {throughput: 1.5 * 1024 * 1024 / 8, latency: 40}},
125 {title: "Regular 4G", value: {throughput: 4 * 1024 * 1024 / 8, latency: 20}} ,
126 {title: "DSL", value: {throughput: 2 * 1024 * 1024 / 8, latency: 5}},
127 {title: "WiFi", value: {throughput: 30 * 1024 * 1024 / 8, latency: 2}},
128 {title: "No throttling", value: {throughput: -1, latency: 0}}
129 ];
130
117 WebInspector.NetworkPanel.prototype = { 131 WebInspector.NetworkPanel.prototype = {
118 /** 132 /**
119 * @param {!WebInspector.Event} event 133 * @param {!WebInspector.Event} event
120 */ 134 */
121 _onWindowChanged: function(event) 135 _onWindowChanged: function(event)
122 { 136 {
123 var startTime = Math.max(this._calculator.minimumBoundary(), event.data. startTime / 1000); 137 var startTime = Math.max(this._calculator.minimumBoundary(), event.data. startTime / 1000);
124 var endTime = Math.min(this._calculator.maximumBoundary(), event.data.en dTime / 1000); 138 var endTime = Math.min(this._calculator.maximumBoundary(), event.data.en dTime / 1000);
125 this._networkLogView.setWindow(startTime, endTime); 139 this._networkLogView.setWindow(startTime, endTime);
126 }, 140 },
(...skipping 27 matching lines...) Expand all
154 this._panelToolbar.appendToolbarItem(showOverviewButton); 168 this._panelToolbar.appendToolbarItem(showOverviewButton);
155 this._panelToolbar.appendSeparator(); 169 this._panelToolbar.appendSeparator();
156 170
157 this._preserveLogCheckbox = new WebInspector.ToolbarCheckbox(WebInspecto r.UIString("Preserve log"), WebInspector.UIString("Do not clear log on page relo ad / navigation")); 171 this._preserveLogCheckbox = new WebInspector.ToolbarCheckbox(WebInspecto r.UIString("Preserve log"), WebInspector.UIString("Do not clear log on page relo ad / navigation"));
158 this._preserveLogCheckbox.inputElement.addEventListener("change", this._ onPreserveLogCheckboxChanged.bind(this), false); 172 this._preserveLogCheckbox.inputElement.addEventListener("change", this._ onPreserveLogCheckboxChanged.bind(this), false);
159 this._panelToolbar.appendToolbarItem(this._preserveLogCheckbox); 173 this._panelToolbar.appendToolbarItem(this._preserveLogCheckbox);
160 174
161 this._disableCacheCheckbox = new WebInspector.ToolbarCheckbox(WebInspect or.UIString("Disable cache"), WebInspector.UIString("Disable cache (while DevToo ls is open)"), WebInspector.moduleSetting("cacheDisabled")); 175 this._disableCacheCheckbox = new WebInspector.ToolbarCheckbox(WebInspect or.UIString("Disable cache"), WebInspector.UIString("Disable cache (while DevToo ls is open)"), WebInspector.moduleSetting("cacheDisabled"));
162 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox); 176 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox);
163 177
178 this._panelToolbar.appendSeparator();
179 this._panelToolbar.appendToolbarItem(this._createNetworkConditionsSelect ());
164 this._panelToolbar.appendToolbarItem(new WebInspector.ToolbarItem(this._ progressBarContainer)); 180 this._panelToolbar.appendToolbarItem(new WebInspector.ToolbarItem(this._ progressBarContainer));
165 }, 181 },
166 182
167 /** 183 /**
184 * @return {!WebInspector.ToolbarComboBox}
185 */
186 _createNetworkConditionsSelect: function()
187 {
188 var presets = WebInspector.NetworkPanel._networkConditionsPresets;
189 var networkConditionsSelect = new WebInspector.ToolbarComboBox(optionSel ected);
190 networkConditionsSelect.setMaxWidth(140);
191
192 for (var i = 0; i < presets.length; ++i) {
193 var preset = presets[i];
194 var throughputInKbps = preset.value.throughput / (1024 / 8);
195 var isThrottling = (throughputInKbps > 0) || preset.value.latency;
196 var option;
197 if (!isThrottling) {
198 option = new Option(preset.title, preset.title);
199 } else {
200 var throughputText = (throughputInKbps < 1024) ? WebInspector.UI String("%d Kbps", throughputInKbps) : WebInspector.UIString("%d Mbps", (throughp utInKbps / 1024) | 0);
201 var title = WebInspector.UIString("%s (%s %dms RTT)", preset.tit le, throughputText, preset.value.latency);
202 option = new Option(title, preset.title);
203 option.title = WebInspector.UIString("Maximum download throughpu t: %s.\r\nMinimum round-trip time: %dms.", throughputText, preset.value.latency) ;
204 }
205 option.settingValue = preset.value;
206 networkConditionsSelect.addOption(option);
207 }
208
209 var setting = WebInspector.moduleSetting("networkConditions");
210 setting.addChangeListener(settingChanged);
211 settingChanged();
212
213 function optionSelected()
214 {
215 setting.removeChangeListener(settingChanged);
216 setting.set(networkConditionsSelect.selectedOption().settingValue);
217 setting.addChangeListener(settingChanged);
218 }
219
220 function settingChanged()
221 {
222 var value = setting.get();
223 for (var option of networkConditionsSelect.options()) {
224 if (option.settingValue.throughput === value.throughput && optio n.settingValue.latency === value.latency)
225 networkConditionsSelect.select(option);
226 }
227 }
228
229 return networkConditionsSelect;
230 },
231
232 /**
168 * @param {!WebInspector.Event} event 233 * @param {!WebInspector.Event} event
169 */ 234 */
170 _onRecordButtonClicked: function(event) 235 _onRecordButtonClicked: function(event)
171 { 236 {
172 if (!this._preserveLogCheckbox.checked() && !this._recordButton.toggled( )) 237 if (!this._preserveLogCheckbox.checked() && !this._recordButton.toggled( ))
173 this._reset(); 238 this._reset();
174 this._toggleRecordButton(!this._recordButton.toggled()); 239 this._toggleRecordButton(!this._recordButton.toggled());
175 }, 240 },
176 241
177 /** 242 /**
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 { 786 {
722 if (!this._target) 787 if (!this._target)
723 return; 788 return;
724 789
725 this._target.tracingManager.stop(); 790 this._target.tracingManager.stop();
726 this._target = null; 791 this._target = null;
727 this._callback = callback; 792 this._callback = callback;
728 this._filmStripView.setFetching(); 793 this._filmStripView.setFetching();
729 } 794 }
730 } 795 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/main/module.json ('k') | Source/devtools/front_end/sdk/NetworkManager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698