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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 this._bypassServiceWorkerSetting = Common.settings.createSetting('bypassServ iceWorker', false); | 52 this._bypassServiceWorkerSetting = Common.settings.createSetting('bypassServ iceWorker', false); |
53 if (this._bypassServiceWorkerSetting.get()) | 53 if (this._bypassServiceWorkerSetting.get()) |
54 this._bypassServiceWorkerChanged(); | 54 this._bypassServiceWorkerChanged(); |
55 this._bypassServiceWorkerSetting.addChangeListener(this._bypassServiceWorker Changed, this); | 55 this._bypassServiceWorkerSetting.addChangeListener(this._bypassServiceWorker Changed, this); |
56 | 56 |
57 Common.moduleSetting('cacheDisabled').addChangeListener(this._cacheDisabledS ettingChanged, this); | 57 Common.moduleSetting('cacheDisabled').addChangeListener(this._cacheDisabledS ettingChanged, this); |
58 } | 58 } |
59 | 59 |
60 /** | 60 /** |
61 * @param {!SDK.NetworkRequest} request | 61 * @param {!SDK.NetworkRequest} request |
62 * @return {?SDK.NetworkManager} | |
63 */ | |
64 static managerForRequest(request) { | |
dgozman
2017/06/06 20:54:40
We usually do just forRequest or fromRequest.
allada
2017/06/08 00:42:06
Done.
| |
65 return request[SDK.NetworkManager._networkManagerForRequestSymbol]; | |
66 } | |
67 | |
68 /** | |
69 * @param {!SDK.NetworkRequest} request | |
62 * @return {boolean} | 70 * @return {boolean} |
63 */ | 71 */ |
64 static canReplayRequest(request) { | 72 static canReplayRequest(request) { |
65 return request.resourceType() === Common.resourceTypes.XHR; | 73 return !!request[SDK.NetworkManager._networkManagerForRequestSymbol] && |
74 request.resourceType() === Common.resourceTypes.XHR; | |
66 } | 75 } |
67 | 76 |
68 /** | 77 /** |
69 * @param {!SDK.NetworkRequest} request | 78 * @param {!SDK.NetworkRequest} request |
70 */ | 79 */ |
71 static replayRequest(request) { | 80 static replayRequest(request) { |
72 // TODO(allada) networkAgent() will be removed from NetworkRequest, but in t he mean time we extract it from request. | 81 var manager = request[SDK.NetworkManager._networkManagerForRequestSymbol]; |
73 request.networkManager()._networkAgent.replayXHR(request.requestId()); | 82 if (!manager) |
83 return; | |
84 manager.target().networkAgent().replayXHR(request.requestId()); | |
dgozman
2017/06/06 20:54:41
manager._networkAgent...
allada
2017/06/08 00:42:06
Done.
| |
74 } | 85 } |
75 | 86 |
76 /** | 87 /** |
77 * @param {!SDK.NetworkManager.Conditions} conditions | 88 * @param {!SDK.NetworkManager.Conditions} conditions |
78 * @return {!Protocol.Network.ConnectionType} | 89 * @return {!Protocol.Network.ConnectionType} |
79 * TODO(allada): this belongs to NetworkConditionsSelector, which should hardc ode/guess it. | 90 * TODO(allada): this belongs to NetworkConditionsSelector, which should hardc ode/guess it. |
80 */ | 91 */ |
81 static _connectionType(conditions) { | 92 static _connectionType(conditions) { |
82 if (!conditions.download && !conditions.upload) | 93 if (!conditions.download && !conditions.upload) |
83 return Protocol.Network.ConnectionType.None; | 94 return Protocol.Network.ConnectionType.None; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 /** @type {!SDK.NetworkManager.Conditions} */ | 178 /** @type {!SDK.NetworkManager.Conditions} */ |
168 SDK.NetworkManager.OfflineConditions = { | 179 SDK.NetworkManager.OfflineConditions = { |
169 title: Common.UIString('Offline'), | 180 title: Common.UIString('Offline'), |
170 download: 0, | 181 download: 0, |
171 upload: 0, | 182 upload: 0, |
172 latency: 0 | 183 latency: 0 |
173 }; | 184 }; |
174 /** @typedef {{url: string, enabled: boolean}} */ | 185 /** @typedef {{url: string, enabled: boolean}} */ |
175 SDK.NetworkManager.BlockedPattern; | 186 SDK.NetworkManager.BlockedPattern; |
176 | 187 |
188 SDK.NetworkManager._networkManagerForRequestSymbol = Symbol('NetworkManager'); | |
177 | 189 |
178 /** | 190 /** |
179 * @implements {Protocol.NetworkDispatcher} | 191 * @implements {Protocol.NetworkDispatcher} |
180 * @unrestricted | 192 * @unrestricted |
181 */ | 193 */ |
182 SDK.NetworkDispatcher = class { | 194 SDK.NetworkDispatcher = class { |
195 /** | |
196 * @param {!SDK.NetworkManager} manager | |
197 */ | |
183 constructor(manager) { | 198 constructor(manager) { |
184 this._manager = manager; | 199 this._manager = manager; |
185 /** @type {!Object<!Protocol.Network.RequestId, !SDK.NetworkRequest>} */ | 200 /** @type {!Object<!Protocol.Network.RequestId, !SDK.NetworkRequest>} */ |
186 this._inflightRequestsById = {}; | 201 this._inflightRequestsById = {}; |
187 /** @type {!Object<string, !SDK.NetworkRequest>} */ | 202 /** @type {!Object<string, !SDK.NetworkRequest>} */ |
188 this._inflightRequestsByURL = {}; | 203 this._inflightRequestsByURL = {}; |
189 } | 204 } |
190 | 205 |
191 /** | 206 /** |
192 * @param {!Protocol.Network.Headers} headersMap | 207 * @param {!Protocol.Network.Headers} headersMap |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 this._finishNetworkRequest(networkRequest, time, -1); | 481 this._finishNetworkRequest(networkRequest, time, -1); |
467 } | 482 } |
468 | 483 |
469 /** | 484 /** |
470 * @override | 485 * @override |
471 * @param {!Protocol.Network.RequestId} requestId | 486 * @param {!Protocol.Network.RequestId} requestId |
472 * @param {string} requestURL | 487 * @param {string} requestURL |
473 * @param {!Protocol.Network.Initiator=} initiator | 488 * @param {!Protocol.Network.Initiator=} initiator |
474 */ | 489 */ |
475 webSocketCreated(requestId, requestURL, initiator) { | 490 webSocketCreated(requestId, requestURL, initiator) { |
476 var networkRequest = new SDK.NetworkRequest(this._manager, requestId, reques tURL, '', '', '', initiator || null); | 491 var networkRequest = new SDK.NetworkRequest(requestId, requestURL, '', '', ' ', initiator || null); |
492 networkRequest[SDK.NetworkManager._networkManagerForRequestSymbol] = this._m anager; | |
477 networkRequest.setResourceType(Common.resourceTypes.WebSocket); | 493 networkRequest.setResourceType(Common.resourceTypes.WebSocket); |
478 this._startNetworkRequest(networkRequest); | 494 this._startNetworkRequest(networkRequest); |
479 } | 495 } |
480 | 496 |
481 /** | 497 /** |
482 * @override | 498 * @override |
483 * @param {!Protocol.Network.RequestId} requestId | 499 * @param {!Protocol.Network.RequestId} requestId |
484 * @param {!Protocol.Network.Timestamp} time | 500 * @param {!Protocol.Network.Timestamp} time |
485 * @param {!Protocol.Network.Timestamp} wallTime | 501 * @param {!Protocol.Network.Timestamp} wallTime |
486 * @param {!Protocol.Network.WebSocketRequest} request | 502 * @param {!Protocol.Network.WebSocketRequest} request |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 | 681 |
666 /** | 682 /** |
667 * @param {!Protocol.Network.RequestId} requestId | 683 * @param {!Protocol.Network.RequestId} requestId |
668 * @param {string} frameId | 684 * @param {string} frameId |
669 * @param {!Protocol.Network.LoaderId} loaderId | 685 * @param {!Protocol.Network.LoaderId} loaderId |
670 * @param {string} url | 686 * @param {string} url |
671 * @param {string} documentURL | 687 * @param {string} documentURL |
672 * @param {?Protocol.Network.Initiator} initiator | 688 * @param {?Protocol.Network.Initiator} initiator |
673 */ | 689 */ |
674 _createNetworkRequest(requestId, frameId, loaderId, url, documentURL, initiato r) { | 690 _createNetworkRequest(requestId, frameId, loaderId, url, documentURL, initiato r) { |
675 return new SDK.NetworkRequest(this._manager, requestId, url, documentURL, fr ameId, loaderId, initiator); | 691 var request = new SDK.NetworkRequest(requestId, url, documentURL, frameId, l oaderId, initiator); |
692 request[SDK.NetworkManager._networkManagerForRequestSymbol] = this._manager; | |
693 return request; | |
676 } | 694 } |
677 }; | 695 }; |
678 | 696 |
679 /** | 697 /** |
680 * @implements {SDK.TargetManager.Observer} | 698 * @implements {SDK.TargetManager.Observer} |
681 * @unrestricted | 699 * @unrestricted |
682 */ | 700 */ |
683 SDK.MultitargetNetworkManager = class extends Common.Object { | 701 SDK.MultitargetNetworkManager = class extends Common.Object { |
684 constructor() { | 702 constructor() { |
685 super(); | 703 super(); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
937 SDK.MultitargetNetworkManager.Events = { | 955 SDK.MultitargetNetworkManager.Events = { |
938 BlockedPatternsChanged: Symbol('BlockedPatternsChanged'), | 956 BlockedPatternsChanged: Symbol('BlockedPatternsChanged'), |
939 ConditionsChanged: Symbol('ConditionsChanged'), | 957 ConditionsChanged: Symbol('ConditionsChanged'), |
940 UserAgentChanged: Symbol('UserAgentChanged') | 958 UserAgentChanged: Symbol('UserAgentChanged') |
941 }; | 959 }; |
942 | 960 |
943 /** | 961 /** |
944 * @type {!SDK.MultitargetNetworkManager} | 962 * @type {!SDK.MultitargetNetworkManager} |
945 */ | 963 */ |
946 SDK.multitargetNetworkManager; | 964 SDK.multitargetNetworkManager; |
OLD | NEW |