| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 "text/vtt": {"texttrack": true}, | 81 "text/vtt": {"texttrack": true}, |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** @typedef {{download: number, upload: number, latency: number, title: string}
} */ | 84 /** @typedef {{download: number, upload: number, latency: number, title: string}
} */ |
| 85 WebInspector.NetworkManager.Conditions; | 85 WebInspector.NetworkManager.Conditions; |
| 86 /** @type {!WebInspector.NetworkManager.Conditions} */ | 86 /** @type {!WebInspector.NetworkManager.Conditions} */ |
| 87 WebInspector.NetworkManager.NoThrottlingConditions = {title: WebInspector.UIStri
ng("No throttling"), download: -1, upload: -1, latency: 0}; | 87 WebInspector.NetworkManager.NoThrottlingConditions = {title: WebInspector.UIStri
ng("No throttling"), download: -1, upload: -1, latency: 0}; |
| 88 /** @type {!WebInspector.NetworkManager.Conditions} */ | 88 /** @type {!WebInspector.NetworkManager.Conditions} */ |
| 89 WebInspector.NetworkManager.OfflineConditions = {title: WebInspector.UIString("O
ffline"), download: 0, upload: 0, latency: 0}; | 89 WebInspector.NetworkManager.OfflineConditions = {title: WebInspector.UIString("O
ffline"), download: 0, upload: 0, latency: 0}; |
| 90 | 90 |
| 91 /** |
| 92 * @param {!WebInspector.NetworkManager.Conditions} conditions |
| 93 * @return {!NetworkAgent.ConnectionType} |
| 94 * TODO(allada): this belongs to NetworkConditionsSelector, which should hardcod
e/guess it. |
| 95 */ |
| 96 WebInspector.NetworkManager._connectionType = function(conditions) |
| 97 { |
| 98 if (!conditions.download && !conditions.upload) |
| 99 return NetworkAgent.ConnectionType.None; |
| 100 var types = WebInspector.NetworkManager._connectionTypes; |
| 101 if (!types) { |
| 102 WebInspector.NetworkManager._connectionTypes = []; |
| 103 types = WebInspector.NetworkManager._connectionTypes; |
| 104 types.push(["2g", NetworkAgent.ConnectionType.Cellular2g]); |
| 105 types.push(["3g", NetworkAgent.ConnectionType.Cellular3g]); |
| 106 types.push(["4g", NetworkAgent.ConnectionType.Cellular4g]); |
| 107 types.push(["bluetooth", NetworkAgent.ConnectionType.Bluetooth]); |
| 108 types.push(["wifi", NetworkAgent.ConnectionType.Wifi]); |
| 109 types.push(["wimax", NetworkAgent.ConnectionType.Wimax]); |
| 110 } |
| 111 for (var type of types) { |
| 112 if (conditions.title.toLowerCase().indexOf(type[0]) !== -1) |
| 113 return type[1]; |
| 114 } |
| 115 return NetworkAgent.ConnectionType.Other; |
| 116 } |
| 117 |
| 91 WebInspector.NetworkManager.prototype = { | 118 WebInspector.NetworkManager.prototype = { |
| 92 /** | 119 /** |
| 93 * @param {string} url | 120 * @param {string} url |
| 94 * @return {!WebInspector.NetworkRequest} | 121 * @return {!WebInspector.NetworkRequest} |
| 95 */ | 122 */ |
| 96 inflightRequestForURL: function(url) | 123 inflightRequestForURL: function(url) |
| 97 { | 124 { |
| 98 return this._dispatcher._inflightRequestsByURL[url]; | 125 return this._dispatcher._inflightRequestsByURL[url]; |
| 99 }, | 126 }, |
| 100 | 127 |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 794 |
| 768 /** | 795 /** |
| 769 * @param {!Protocol.NetworkAgent} networkAgent | 796 * @param {!Protocol.NetworkAgent} networkAgent |
| 770 */ | 797 */ |
| 771 _updateNetworkConditions: function(networkAgent) | 798 _updateNetworkConditions: function(networkAgent) |
| 772 { | 799 { |
| 773 var conditions = this._networkConditions; | 800 var conditions = this._networkConditions; |
| 774 if (!this.isThrottling()) { | 801 if (!this.isThrottling()) { |
| 775 networkAgent.emulateNetworkConditions(false, 0, 0, 0); | 802 networkAgent.emulateNetworkConditions(false, 0, 0, 0); |
| 776 } else { | 803 } else { |
| 777 networkAgent.emulateNetworkConditions(this.isOffline(), conditions.l
atency, conditions.download < 0 ? 0 : conditions.download, conditions.upload < 0
? 0 : conditions.upload); | 804 networkAgent.emulateNetworkConditions(this.isOffline(), conditions.l
atency, conditions.download < 0 ? 0 : conditions.download, conditions.upload < 0
? 0 : conditions.upload, WebInspector.NetworkManager._connectionType(conditions
)); |
| 778 } | 805 } |
| 779 }, | 806 }, |
| 780 | 807 |
| 781 /** | 808 /** |
| 782 * @param {!NetworkAgent.Headers} headers | 809 * @param {!NetworkAgent.Headers} headers |
| 783 */ | 810 */ |
| 784 setExtraHTTPHeaders: function(headers) | 811 setExtraHTTPHeaders: function(headers) |
| 785 { | 812 { |
| 786 this._extraHeaders = headers; | 813 this._extraHeaders = headers; |
| 787 for (var target of WebInspector.targetManager.targets()) | 814 for (var target of WebInspector.targetManager.targets()) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 WebInspector.ResourceLoader.load(url, headers, callback); | 934 WebInspector.ResourceLoader.load(url, headers, callback); |
| 908 }, | 935 }, |
| 909 | 936 |
| 910 __proto__: WebInspector.Object.prototype | 937 __proto__: WebInspector.Object.prototype |
| 911 } | 938 } |
| 912 | 939 |
| 913 /** | 940 /** |
| 914 * @type {!WebInspector.MultitargetNetworkManager} | 941 * @type {!WebInspector.MultitargetNetworkManager} |
| 915 */ | 942 */ |
| 916 WebInspector.multitargetNetworkManager; | 943 WebInspector.multitargetNetworkManager; |
| OLD | NEW |