| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 SDK.SDKObject { | 34 SDK.NetworkRequest = class extends Common.Object { |
| 35 /** | 35 /** |
| 36 * @param {!SDK.NetworkManager} networkManager |
| 36 * @param {!Protocol.Network.RequestId} requestId | 37 * @param {!Protocol.Network.RequestId} requestId |
| 37 * @param {!SDK.Target} target | |
| 38 * @param {string} url | 38 * @param {string} url |
| 39 * @param {string} documentURL | 39 * @param {string} documentURL |
| 40 * @param {!Protocol.Page.FrameId} frameId | 40 * @param {!Protocol.Page.FrameId} frameId |
| 41 * @param {!Protocol.Network.LoaderId} loaderId | 41 * @param {!Protocol.Network.LoaderId} loaderId |
| 42 * @param {?Protocol.Network.Initiator} initiator | 42 * @param {?Protocol.Network.Initiator} initiator |
| 43 */ | 43 */ |
| 44 constructor(target, requestId, url, documentURL, frameId, loaderId, initiator)
{ | 44 constructor(networkManager, requestId, url, documentURL, frameId, loaderId, in
itiator) { |
| 45 super(target); | 45 super(); |
| 46 | 46 |
| 47 this._networkManager = /** @type {!SDK.NetworkManager} */ (target.model(SDK.
NetworkManager)); | 47 this._networkManager = networkManager; |
| 48 this._requestId = requestId; | 48 this._requestId = requestId; |
| 49 this.setUrl(url); | 49 this.setUrl(url); |
| 50 this._documentURL = documentURL; | 50 this._documentURL = documentURL; |
| 51 this._frameId = frameId; | 51 this._frameId = frameId; |
| 52 this._loaderId = loaderId; | 52 this._loaderId = loaderId; |
| 53 /** @type {?Protocol.Network.Initiator} */ | 53 /** @type {?Protocol.Network.Initiator} */ |
| 54 this._initiator = initiator; | 54 this._initiator = initiator; |
| 55 this._issueTime = -1; | 55 this._issueTime = -1; |
| 56 this._startTime = -1; | 56 this._startTime = -1; |
| 57 this._endTime = -1; | 57 this._endTime = -1; |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 _parseNameAndPathFromURL() { | 524 _parseNameAndPathFromURL() { |
| 525 if (this._parsedURL.isDataURL()) { | 525 if (this._parsedURL.isDataURL()) { |
| 526 this._name = this._parsedURL.dataURLDisplayName(); | 526 this._name = this._parsedURL.dataURLDisplayName(); |
| 527 this._path = ''; | 527 this._path = ''; |
| 528 } else if (this._parsedURL.isAboutBlank()) { | 528 } else if (this._parsedURL.isAboutBlank()) { |
| 529 this._name = this._parsedURL.url; | 529 this._name = this._parsedURL.url; |
| 530 this._path = ''; | 530 this._path = ''; |
| 531 } else { | 531 } else { |
| 532 this._path = this._parsedURL.host + this._parsedURL.folderPathComponents; | 532 this._path = this._parsedURL.host + this._parsedURL.folderPathComponents; |
| 533 | 533 |
| 534 var inspectedURL = this.target().inspectedURL().asParsedURL(); | 534 var inspectedURL = this._networkManager.target().inspectedURL().asParsedUR
L(); |
| 535 this._path = this._path.trimURL(inspectedURL ? inspectedURL.host : ''); | 535 this._path = this._path.trimURL(inspectedURL ? inspectedURL.host : ''); |
| 536 if (this._parsedURL.lastPathComponent || this._parsedURL.queryParams) { | 536 if (this._parsedURL.lastPathComponent || this._parsedURL.queryParams) { |
| 537 this._name = | 537 this._name = |
| 538 this._parsedURL.lastPathComponent + (this._parsedURL.queryParams ? '
?' + this._parsedURL.queryParams : ''); | 538 this._parsedURL.lastPathComponent + (this._parsedURL.queryParams ? '
?' + this._parsedURL.queryParams : ''); |
| 539 } else if (this._parsedURL.folderPathComponents) { | 539 } else if (this._parsedURL.folderPathComponents) { |
| 540 this._name = | 540 this._name = |
| 541 this._parsedURL.folderPathComponents.substring(this._parsedURL.folde
rPathComponents.lastIndexOf('/') + 1) + | 541 this._parsedURL.folderPathComponents.substring(this._parsedURL.folde
rPathComponents.lastIndexOf('/') + 1) + |
| 542 '/'; | 542 '/'; |
| 543 this._path = this._path.substring(0, this._path.lastIndexOf('/')); | 543 this._path = this._path.substring(0, this._path.lastIndexOf('/')); |
| 544 } else { | 544 } else { |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 function onResourceContent(error, content, contentEncoded) { | 1027 function onResourceContent(error, content, contentEncoded) { |
| 1028 this._content = error ? null : content; | 1028 this._content = error ? null : content; |
| 1029 this._contentError = error; | 1029 this._contentError = error; |
| 1030 this._contentEncoded = contentEncoded; | 1030 this._contentEncoded = contentEncoded; |
| 1031 var callbacks = this._pendingContentCallbacks.slice(); | 1031 var callbacks = this._pendingContentCallbacks.slice(); |
| 1032 for (var i = 0; i < callbacks.length; ++i) | 1032 for (var i = 0; i < callbacks.length; ++i) |
| 1033 callbacks[i](this._content); | 1033 callbacks[i](this._content); |
| 1034 this._pendingContentCallbacks.length = 0; | 1034 this._pendingContentCallbacks.length = 0; |
| 1035 delete this._contentRequested; | 1035 delete this._contentRequested; |
| 1036 } | 1036 } |
| 1037 this.target().networkAgent().getResponseBody(this._requestId, onResourceCont
ent.bind(this)); | 1037 this._networkManager.target().networkAgent().getResponseBody(this._requestId
, onResourceContent.bind(this)); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 /** | 1040 /** |
| 1041 * @return {?Protocol.Network.Initiator} | 1041 * @return {?Protocol.Network.Initiator} |
| 1042 */ | 1042 */ |
| 1043 initiator() { | 1043 initiator() { |
| 1044 return this._initiator; | 1044 return this._initiator; |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 /** | 1047 /** |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 * @param {string} eventId | 1102 * @param {string} eventId |
| 1103 * @param {string} data | 1103 * @param {string} data |
| 1104 */ | 1104 */ |
| 1105 addEventSourceMessage(time, eventName, eventId, data) { | 1105 addEventSourceMessage(time, eventName, eventId, data) { |
| 1106 var message = {time: this.pseudoWallTime(time), eventName: eventName, eventI
d: eventId, data: data}; | 1106 var message = {time: this.pseudoWallTime(time), eventName: eventName, eventI
d: eventId, data: data}; |
| 1107 this._eventSourceMessages.push(message); | 1107 this._eventSourceMessages.push(message); |
| 1108 this.dispatchEventToListeners(SDK.NetworkRequest.Events.EventSourceMessageAd
ded, message); | 1108 this.dispatchEventToListeners(SDK.NetworkRequest.Events.EventSourceMessageAd
ded, message); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 replayXHR() { | 1111 replayXHR() { |
| 1112 this.target().networkAgent().replayXHR(this._requestId); | 1112 this._networkManager.target().networkAgent().replayXHR(this._requestId); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 /** | 1115 /** |
| 1116 * @return {!SDK.NetworkManager} | 1116 * @return {!SDK.NetworkManager} |
| 1117 */ | 1117 */ |
| 1118 networkManager() { | 1118 networkManager() { |
| 1119 return this._networkManager; | 1119 return this._networkManager; |
| 1120 } | 1120 } |
| 1121 }; | 1121 }; |
| 1122 | 1122 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1148 Send: 'send', | 1148 Send: 'send', |
| 1149 Receive: 'receive', | 1149 Receive: 'receive', |
| 1150 Error: 'error' | 1150 Error: 'error' |
| 1151 }; | 1151 }; |
| 1152 | 1152 |
| 1153 /** @typedef {!{type: SDK.NetworkRequest.WebSocketFrameType, time: number, text:
string, opCode: number, mask: boolean}} */ | 1153 /** @typedef {!{type: SDK.NetworkRequest.WebSocketFrameType, time: number, text:
string, opCode: number, mask: boolean}} */ |
| 1154 SDK.NetworkRequest.WebSocketFrame; | 1154 SDK.NetworkRequest.WebSocketFrame; |
| 1155 | 1155 |
| 1156 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}}
*/ | 1156 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}}
*/ |
| 1157 SDK.NetworkRequest.EventSourceMessage; | 1157 SDK.NetworkRequest.EventSourceMessage; |
| OLD | NEW |