OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 /** | 30 /** |
31 * @implements {Common.ContentProvider} | 31 * @implements {Common.ContentProvider} |
32 * @unrestricted | 32 * @unrestricted |
33 */ | 33 */ |
34 SDK.NetworkRequest = class extends Common.Object { | 34 SDK.NetworkRequest = class extends Common.Object { |
35 /** | 35 /** |
36 * @param {!SDK.NetworkManager} networkManager | |
37 * @param {!Protocol.Network.RequestId} requestId | 36 * @param {!Protocol.Network.RequestId} requestId |
38 * @param {string} url | 37 * @param {string} url |
39 * @param {string} documentURL | 38 * @param {string} documentURL |
40 * @param {!Protocol.Page.FrameId} frameId | 39 * @param {!Protocol.Page.FrameId} frameId |
41 * @param {!Protocol.Network.LoaderId} loaderId | 40 * @param {!Protocol.Network.LoaderId} loaderId |
42 * @param {?Protocol.Network.Initiator} initiator | 41 * @param {?Protocol.Network.Initiator} initiator |
43 */ | 42 */ |
44 constructor(networkManager, requestId, url, documentURL, frameId, loaderId, in
itiator) { | 43 constructor(requestId, url, documentURL, frameId, loaderId, initiator) { |
45 super(); | 44 super(); |
46 | 45 |
47 this._networkManager = networkManager; | |
48 this._requestId = requestId; | 46 this._requestId = requestId; |
49 this.setUrl(url); | 47 this.setUrl(url); |
50 this._documentURL = documentURL; | 48 this._documentURL = documentURL; |
51 this._frameId = frameId; | 49 this._frameId = frameId; |
52 this._loaderId = loaderId; | 50 this._loaderId = loaderId; |
53 /** @type {?Protocol.Network.Initiator} */ | 51 /** @type {?Protocol.Network.Initiator} */ |
54 this._initiator = initiator; | 52 this._initiator = initiator; |
55 /** @type {?SDK.NetworkRequest} */ | 53 /** @type {?SDK.NetworkRequest} */ |
56 this._redirectSource = null; | 54 this._redirectSource = null; |
57 this._issueTime = -1; | 55 this._issueTime = -1; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 _parseNameAndPathFromURL() { | 522 _parseNameAndPathFromURL() { |
525 if (this._parsedURL.isDataURL()) { | 523 if (this._parsedURL.isDataURL()) { |
526 this._name = this._parsedURL.dataURLDisplayName(); | 524 this._name = this._parsedURL.dataURLDisplayName(); |
527 this._path = ''; | 525 this._path = ''; |
528 } else if (this._parsedURL.isAboutBlank()) { | 526 } else if (this._parsedURL.isAboutBlank()) { |
529 this._name = this._parsedURL.url; | 527 this._name = this._parsedURL.url; |
530 this._path = ''; | 528 this._path = ''; |
531 } else { | 529 } else { |
532 this._path = this._parsedURL.host + this._parsedURL.folderPathComponents; | 530 this._path = this._parsedURL.host + this._parsedURL.folderPathComponents; |
533 | 531 |
534 var inspectedURL = this._networkManager.target().inspectedURL().asParsedUR
L(); | 532 var networkManager = SDK.NetworkManager.forRequest(this); |
| 533 var inspectedURL = networkManager ? networkManager.target().inspectedURL()
.asParsedURL() : null; |
535 this._path = this._path.trimURL(inspectedURL ? inspectedURL.host : ''); | 534 this._path = this._path.trimURL(inspectedURL ? inspectedURL.host : ''); |
536 if (this._parsedURL.lastPathComponent || this._parsedURL.queryParams) { | 535 if (this._parsedURL.lastPathComponent || this._parsedURL.queryParams) { |
537 this._name = | 536 this._name = |
538 this._parsedURL.lastPathComponent + (this._parsedURL.queryParams ? '
?' + this._parsedURL.queryParams : ''); | 537 this._parsedURL.lastPathComponent + (this._parsedURL.queryParams ? '
?' + this._parsedURL.queryParams : ''); |
539 } else if (this._parsedURL.folderPathComponents) { | 538 } else if (this._parsedURL.folderPathComponents) { |
540 this._name = | 539 this._name = |
541 this._parsedURL.folderPathComponents.substring(this._parsedURL.folde
rPathComponents.lastIndexOf('/') + 1) + | 540 this._parsedURL.folderPathComponents.substring(this._parsedURL.folde
rPathComponents.lastIndexOf('/') + 1) + |
542 '/'; | 541 '/'; |
543 this._path = this._path.substring(0, this._path.lastIndexOf('/')); | 542 this._path = this._path.substring(0, this._path.lastIndexOf('/')); |
544 } else { | 543 } else { |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 * @param {number} time | 1080 * @param {number} time |
1082 * @param {string} eventName | 1081 * @param {string} eventName |
1083 * @param {string} eventId | 1082 * @param {string} eventId |
1084 * @param {string} data | 1083 * @param {string} data |
1085 */ | 1084 */ |
1086 addEventSourceMessage(time, eventName, eventId, data) { | 1085 addEventSourceMessage(time, eventName, eventId, data) { |
1087 var message = {time: this.pseudoWallTime(time), eventName: eventName, eventI
d: eventId, data: data}; | 1086 var message = {time: this.pseudoWallTime(time), eventName: eventName, eventI
d: eventId, data: data}; |
1088 this._eventSourceMessages.push(message); | 1087 this._eventSourceMessages.push(message); |
1089 this.dispatchEventToListeners(SDK.NetworkRequest.Events.EventSourceMessageAd
ded, message); | 1088 this.dispatchEventToListeners(SDK.NetworkRequest.Events.EventSourceMessageAd
ded, message); |
1090 } | 1089 } |
1091 | |
1092 /** | |
1093 * @return {!SDK.NetworkManager} | |
1094 */ | |
1095 networkManager() { | |
1096 return this._networkManager; | |
1097 } | |
1098 }; | 1090 }; |
1099 | 1091 |
1100 /** @enum {symbol} */ | 1092 /** @enum {symbol} */ |
1101 SDK.NetworkRequest.Events = { | 1093 SDK.NetworkRequest.Events = { |
1102 FinishedLoading: Symbol('FinishedLoading'), | 1094 FinishedLoading: Symbol('FinishedLoading'), |
1103 TimingChanged: Symbol('TimingChanged'), | 1095 TimingChanged: Symbol('TimingChanged'), |
1104 RemoteAddressChanged: Symbol('RemoteAddressChanged'), | 1096 RemoteAddressChanged: Symbol('RemoteAddressChanged'), |
1105 RequestHeadersChanged: Symbol('RequestHeadersChanged'), | 1097 RequestHeadersChanged: Symbol('RequestHeadersChanged'), |
1106 ResponseHeadersChanged: Symbol('ResponseHeadersChanged'), | 1098 ResponseHeadersChanged: Symbol('ResponseHeadersChanged'), |
1107 WebsocketFrameAdded: Symbol('WebsocketFrameAdded'), | 1099 WebsocketFrameAdded: Symbol('WebsocketFrameAdded'), |
(...skipping 20 matching lines...) Expand all Loading... |
1128 }; | 1120 }; |
1129 | 1121 |
1130 /** @typedef {!{type: SDK.NetworkRequest.WebSocketFrameType, time: number, text:
string, opCode: number, mask: boolean}} */ | 1122 /** @typedef {!{type: SDK.NetworkRequest.WebSocketFrameType, time: number, text:
string, opCode: number, mask: boolean}} */ |
1131 SDK.NetworkRequest.WebSocketFrame; | 1123 SDK.NetworkRequest.WebSocketFrame; |
1132 | 1124 |
1133 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}}
*/ | 1125 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}}
*/ |
1134 SDK.NetworkRequest.EventSourceMessage; | 1126 SDK.NetworkRequest.EventSourceMessage; |
1135 | 1127 |
1136 /** @typedef {!{error: ?string, content: ?string, encoded: boolean}} */ | 1128 /** @typedef {!{error: ?string, content: ?string, encoded: boolean}} */ |
1137 SDK.NetworkRequest.ContentData; | 1129 SDK.NetworkRequest.ContentData; |
OLD | NEW |