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 */ |
| 95 WebInspector.NetworkManager._connectionType = function(conditions) |
| 96 { |
| 97 if (!conditions.download && !conditions.upload) |
| 98 return NetworkAgent.ConnectionType.None; |
| 99 var types = WebInspector.NetworkManager._connectionTypes; |
| 100 if (!types) { |
| 101 WebInspector.NetworkManager._connectionTypes = []; |
| 102 types = WebInspector.NetworkManager._connectionTypes; |
| 103 types.push(["2g", NetworkAgent.ConnectionType.Cellular2g]); |
| 104 types.push(["3g", NetworkAgent.ConnectionType.Cellular3g]); |
| 105 types.push(["4g", NetworkAgent.ConnectionType.Cellular4g]); |
| 106 types.push(["bluetooth", NetworkAgent.ConnectionType.Bluetooth]); |
| 107 types.push(["wifi", NetworkAgent.ConnectionType.Wifi]); |
| 108 types.push(["wimax", NetworkAgent.ConnectionType.Wimax]); |
| 109 } |
| 110 for (var type of types) { |
| 111 if (conditions.title.toLowerCase().indexOf(type[0]) !== -1) |
| 112 return type[1]; |
| 113 } |
| 114 return NetworkAgent.ConnectionType.Other; |
| 115 } |
| 116 |
91 WebInspector.NetworkManager.prototype = { | 117 WebInspector.NetworkManager.prototype = { |
92 /** | 118 /** |
93 * @param {string} url | 119 * @param {string} url |
94 * @return {!WebInspector.NetworkRequest} | 120 * @return {!WebInspector.NetworkRequest} |
95 */ | 121 */ |
96 inflightRequestForURL: function(url) | 122 inflightRequestForURL: function(url) |
97 { | 123 { |
98 return this._dispatcher._inflightRequestsByURL[url]; | 124 return this._dispatcher._inflightRequestsByURL[url]; |
99 }, | 125 }, |
100 | 126 |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 | 793 |
768 /** | 794 /** |
769 * @param {!Protocol.NetworkAgent} networkAgent | 795 * @param {!Protocol.NetworkAgent} networkAgent |
770 */ | 796 */ |
771 _updateNetworkConditions: function(networkAgent) | 797 _updateNetworkConditions: function(networkAgent) |
772 { | 798 { |
773 var conditions = this._networkConditions; | 799 var conditions = this._networkConditions; |
774 if (!this.isThrottling()) { | 800 if (!this.isThrottling()) { |
775 networkAgent.emulateNetworkConditions(false, 0, 0, 0); | 801 networkAgent.emulateNetworkConditions(false, 0, 0, 0); |
776 } else { | 802 } else { |
777 networkAgent.emulateNetworkConditions(this.isOffline(), conditions.l
atency, conditions.download < 0 ? 0 : conditions.download, conditions.upload < 0
? 0 : conditions.upload); | 803 networkAgent.emulateNetworkConditions(this.isOffline(), conditions.l
atency, conditions.download < 0 ? 0 : conditions.download, conditions.upload < 0
? 0 : conditions.upload, WebInspector.NetworkManager._connectionType(conditions
)); |
778 } | 804 } |
779 }, | 805 }, |
780 | 806 |
781 /** | 807 /** |
782 * @param {!NetworkAgent.Headers} headers | 808 * @param {!NetworkAgent.Headers} headers |
783 */ | 809 */ |
784 setExtraHTTPHeaders: function(headers) | 810 setExtraHTTPHeaders: function(headers) |
785 { | 811 { |
786 this._extraHeaders = headers; | 812 this._extraHeaders = headers; |
787 for (var target of WebInspector.targetManager.targets()) | 813 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); | 933 WebInspector.ResourceLoader.load(url, headers, callback); |
908 }, | 934 }, |
909 | 935 |
910 __proto__: WebInspector.Object.prototype | 936 __proto__: WebInspector.Object.prototype |
911 } | 937 } |
912 | 938 |
913 /** | 939 /** |
914 * @type {!WebInspector.MultitargetNetworkManager} | 940 * @type {!WebInspector.MultitargetNetworkManager} |
915 */ | 941 */ |
916 WebInspector.multitargetNetworkManager; | 942 WebInspector.multitargetNetworkManager; |
OLD | NEW |