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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js

Issue 2938503002: DevTools: unify Network & CPU throttling (Closed)
Patch Set: fmt 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) 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 /** 68 /**
69 * @param {!SDK.NetworkRequest} request 69 * @param {!SDK.NetworkRequest} request
70 */ 70 */
71 static replayRequest(request) { 71 static replayRequest(request) {
72 // TODO(allada) networkAgent() will be removed from NetworkRequest, but in t he mean time we extract it from request. 72 // TODO(allada) networkAgent() will be removed from NetworkRequest, but in t he mean time we extract it from request.
73 request.networkManager()._networkAgent.replayXHR(request.requestId()); 73 request.networkManager()._networkAgent.replayXHR(request.requestId());
74 } 74 }
75 75
76 /** 76 /**
77 * @param {!SDK.NetworkManager.Conditions} conditions 77 * @param {!SDK.MobileThrottling.Conditions} conditions
78 * @return {!Protocol.Network.ConnectionType} 78 * @return {!Protocol.Network.ConnectionType}
79 * TODO(allada): this belongs to NetworkConditionsSelector, which should hardc ode/guess it. 79 * TODO(allada): this belongs to NetworkConditionsSelector, which should hardc ode/guess it.
80 */ 80 */
81 static _connectionType(conditions) { 81 static _connectionType(conditions) {
82 if (!conditions.download && !conditions.upload) 82 if (!conditions.download && !conditions.upload)
83 return Protocol.Network.ConnectionType.None; 83 return Protocol.Network.ConnectionType.None;
84 var types = SDK.NetworkManager._connectionTypes; 84 var types = SDK.NetworkManager._connectionTypes;
85 if (!types) { 85 if (!types) {
86 SDK.NetworkManager._connectionTypes = []; 86 SDK.NetworkManager._connectionTypes = [];
87 types = SDK.NetworkManager._connectionTypes; 87 types = SDK.NetworkManager._connectionTypes;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 'text/html': {'document': true}, 147 'text/html': {'document': true},
148 'text/xml': {'document': true}, 148 'text/xml': {'document': true},
149 'text/plain': {'document': true}, 149 'text/plain': {'document': true},
150 'application/xhtml+xml': {'document': true}, 150 'application/xhtml+xml': {'document': true},
151 'image/svg+xml': {'document': true}, 151 'image/svg+xml': {'document': true},
152 'text/css': {'stylesheet': true}, 152 'text/css': {'stylesheet': true},
153 'text/xsl': {'stylesheet': true}, 153 'text/xsl': {'stylesheet': true},
154 'text/vtt': {'texttrack': true}, 154 'text/vtt': {'texttrack': true},
155 }; 155 };
156 156
157
158 /** @typedef {{download: number, upload: number, latency: number, title: string} } */
159 SDK.NetworkManager.Conditions;
160 /** @type {!SDK.NetworkManager.Conditions} */
161 SDK.NetworkManager.NoThrottlingConditions = {
162 title: Common.UIString('No throttling'),
163 download: -1,
164 upload: -1,
165 latency: 0
166 };
167 /** @type {!SDK.NetworkManager.Conditions} */
168 SDK.NetworkManager.OfflineConditions = {
169 title: Common.UIString('Offline'),
170 download: 0,
171 upload: 0,
172 latency: 0
173 };
174 /** @typedef {{url: string, enabled: boolean}} */ 157 /** @typedef {{url: string, enabled: boolean}} */
175 SDK.NetworkManager.BlockedPattern; 158 SDK.NetworkManager.BlockedPattern;
176 159
177 160
178 /** 161 /**
179 * @implements {Protocol.NetworkDispatcher} 162 * @implements {Protocol.NetworkDispatcher}
180 * @unrestricted 163 * @unrestricted
181 */ 164 */
182 SDK.NetworkDispatcher = class { 165 SDK.NetworkDispatcher = class {
183 constructor(manager) { 166 constructor(manager) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 /** 675 /**
693 * @implements {SDK.TargetManager.Observer} 676 * @implements {SDK.TargetManager.Observer}
694 * @unrestricted 677 * @unrestricted
695 */ 678 */
696 SDK.MultitargetNetworkManager = class extends Common.Object { 679 SDK.MultitargetNetworkManager = class extends Common.Object {
697 constructor() { 680 constructor() {
698 super(); 681 super();
699 this._userAgentOverride = ''; 682 this._userAgentOverride = '';
700 /** @type {!Set<!Protocol.NetworkAgent>} */ 683 /** @type {!Set<!Protocol.NetworkAgent>} */
701 this._agents = new Set(); 684 this._agents = new Set();
702 /** @type {!SDK.NetworkManager.Conditions} */ 685 /** @type {!SDK.MobileThrottling.Conditions} */
703 this._networkConditions = SDK.NetworkManager.NoThrottlingConditions; 686 this._networkConditions = SDK.MobileThrottling.NoThrottlingConditions;
704 687
705 this._blockingEnabledSetting = Common.moduleSetting('requestBlockingEnabled' ); 688 this._blockingEnabledSetting = Common.moduleSetting('requestBlockingEnabled' );
706 this._blockedPatternsSetting = Common.settings.createSetting('networkBlocked Patterns', []); 689 this._blockedPatternsSetting = Common.settings.createSetting('networkBlocked Patterns', []);
707 this._effectiveBlockedURLs = []; 690 this._effectiveBlockedURLs = [];
708 this._updateBlockedPatterns(); 691 this._updateBlockedPatterns();
709 692
710 SDK.targetManager.observeTargets(this, SDK.Target.Capability.Network); 693 SDK.targetManager.observeTargets(this, SDK.Target.Capability.Network);
711 } 694 }
712 695
713 /** 696 /**
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 740 }
758 741
759 /** 742 /**
760 * @return {boolean} 743 * @return {boolean}
761 */ 744 */
762 isOffline() { 745 isOffline() {
763 return !this._networkConditions.download && !this._networkConditions.upload; 746 return !this._networkConditions.download && !this._networkConditions.upload;
764 } 747 }
765 748
766 /** 749 /**
767 * @param {!SDK.NetworkManager.Conditions} conditions 750 * @param {!SDK.MobileThrottling.Conditions} conditions
768 */ 751 */
769 setNetworkConditions(conditions) { 752 setNetworkConditions(conditions) {
770 this._networkConditions = conditions; 753 this._networkConditions = conditions;
771 for (var agent of this._agents) 754 for (var agent of this._agents)
772 this._updateNetworkConditions(agent); 755 this._updateNetworkConditions(agent);
773 this.dispatchEventToListeners(SDK.MultitargetNetworkManager.Events.Condition sChanged); 756 this.dispatchEventToListeners(SDK.MultitargetNetworkManager.Events.Condition sChanged);
774 } 757 }
775 758
776 /** 759 /**
777 * @return {!SDK.NetworkManager.Conditions} 760 * @return {!SDK.MobileThrottling.Conditions}
778 */ 761 */
779 networkConditions() { 762 networkConditions() {
780 return this._networkConditions; 763 return this._networkConditions;
781 } 764 }
782 765
783 /** 766 /**
784 * @param {!Protocol.NetworkAgent} networkAgent 767 * @param {!Protocol.NetworkAgent} networkAgent
785 */ 768 */
786 _updateNetworkConditions(networkAgent) { 769 _updateNetworkConditions(networkAgent) {
787 var conditions = this._networkConditions; 770 var conditions = this._networkConditions;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 SDK.MultitargetNetworkManager.Events = { 924 SDK.MultitargetNetworkManager.Events = {
942 BlockedPatternsChanged: Symbol('BlockedPatternsChanged'), 925 BlockedPatternsChanged: Symbol('BlockedPatternsChanged'),
943 ConditionsChanged: Symbol('ConditionsChanged'), 926 ConditionsChanged: Symbol('ConditionsChanged'),
944 UserAgentChanged: Symbol('UserAgentChanged') 927 UserAgentChanged: Symbol('UserAgentChanged')
945 }; 928 };
946 929
947 /** 930 /**
948 * @type {!SDK.MultitargetNetworkManager} 931 * @type {!SDK.MultitargetNetworkManager}
949 */ 932 */
950 SDK.multitargetNetworkManager; 933 SDK.multitargetNetworkManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698