| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 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 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.SDKObject} | 33 * @extends {WebInspector.SDKModel} |
| 34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
| 35 * @param {!WebInspector.NetworkManager} networkManager |
| 35 */ | 36 */ |
| 36 WebInspector.NetworkLog = function(target) | 37 WebInspector.NetworkLog = function(target, networkManager) |
| 37 { | 38 { |
| 38 WebInspector.SDKObject.call(this, target); | 39 WebInspector.SDKModel.call(this, WebInspector.NetworkLog, target); |
| 39 | 40 |
| 40 this._requests = []; | 41 this._requests = []; |
| 41 this._requestForId = {}; | 42 this._requestForId = {}; |
| 42 target.networkManager.addEventListener(WebInspector.NetworkManager.EventType
s.RequestStarted, this._onRequestStarted, this); | 43 networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.Reque
stStarted, this._onRequestStarted, this); |
| 43 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.MainFrameNavigated, this._onMainFrameNavigated, this); | 44 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.MainFrameNavigated, this._onMainFrameNavigated, this); |
| 44 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.Load, this._onLoad, this); | 45 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.Load, this._onLoad, this); |
| 45 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.DOMContentLoaded, this._onDOMContentLoaded, this); | 46 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.DOMContentLoaded, this._onDOMContentLoaded, this); |
| 46 } | 47 } |
| 47 | 48 |
| 48 /** | 49 /** |
| 50 * @param {!WebInspector.Target} target |
| 51 * @return {?WebInspector.NetworkLog} |
| 52 */ |
| 53 WebInspector.NetworkLog.fromTarget = function(target) |
| 54 { |
| 55 return /** @type {?WebInspector.NetworkLog} */ (target.model(WebInspector.Ne
tworkLog)); |
| 56 } |
| 57 |
| 58 /** |
| 49 * @param {string} url | 59 * @param {string} url |
| 50 * @return {?WebInspector.NetworkRequest} | 60 * @return {?WebInspector.NetworkRequest} |
| 51 */ | 61 */ |
| 52 WebInspector.NetworkLog.requestForURL = function(url) | 62 WebInspector.NetworkLog.requestForURL = function(url) |
| 53 { | 63 { |
| 54 for (var target of WebInspector.targetManager.targets()) { | 64 for (var target of WebInspector.targetManager.targets()) { |
| 55 var result = target.networkLog.requestForURL(url); | 65 var networkLog = WebInspector.NetworkLog.fromTarget(target); |
| 66 var result = networkLog && networkLog.requestForURL(url); |
| 56 if (result) | 67 if (result) |
| 57 return result; | 68 return result; |
| 58 } | 69 } |
| 59 return null; | 70 return null; |
| 60 } | 71 } |
| 61 | 72 |
| 62 /** | 73 /** |
| 63 * @return {!Array.<!WebInspector.NetworkRequest>} | 74 * @return {!Array.<!WebInspector.NetworkRequest>} |
| 64 */ | 75 */ |
| 65 WebInspector.NetworkLog.requests = function() | 76 WebInspector.NetworkLog.requests = function() |
| 66 { | 77 { |
| 67 var result = []; | 78 var result = []; |
| 68 for (var target of WebInspector.targetManager.targets()) { | 79 for (var target of WebInspector.targetManager.targets()) { |
| 69 result = result.concat(target.networkLog.requests()); | 80 var networkLog = WebInspector.NetworkLog.fromTarget(target); |
| 81 if (networkLog) |
| 82 result = result.concat(networkLog.requests()); |
| 70 } | 83 } |
| 71 return result; | 84 return result; |
| 72 } | 85 } |
| 73 | 86 |
| 74 WebInspector.NetworkLog.prototype = { | 87 WebInspector.NetworkLog.prototype = { |
| 75 /** | 88 /** |
| 76 * @return {!Array.<!WebInspector.NetworkRequest>} | 89 * @return {!Array.<!WebInspector.NetworkRequest>} |
| 77 */ | 90 */ |
| 78 requests: function() | 91 requests: function() |
| 79 { | 92 { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 168 |
| 156 /** | 169 /** |
| 157 * @param {!NetworkAgent.RequestId} requestId | 170 * @param {!NetworkAgent.RequestId} requestId |
| 158 * @return {?WebInspector.NetworkRequest} | 171 * @return {?WebInspector.NetworkRequest} |
| 159 */ | 172 */ |
| 160 requestForId: function(requestId) | 173 requestForId: function(requestId) |
| 161 { | 174 { |
| 162 return this._requestForId[requestId]; | 175 return this._requestForId[requestId]; |
| 163 }, | 176 }, |
| 164 | 177 |
| 165 __proto__: WebInspector.SDKObject.prototype | 178 __proto__: WebInspector.SDKModel.prototype |
| 166 } | 179 } |
| 167 | 180 |
| 168 /** | 181 /** |
| 169 * @constructor | 182 * @constructor |
| 170 * @param {!WebInspector.NetworkRequest} mainRequest | 183 * @param {!WebInspector.NetworkRequest} mainRequest |
| 171 */ | 184 */ |
| 172 WebInspector.PageLoad = function(mainRequest) | 185 WebInspector.PageLoad = function(mainRequest) |
| 173 { | 186 { |
| 174 this.id = ++WebInspector.PageLoad._lastIdentifier; | 187 this.id = ++WebInspector.PageLoad._lastIdentifier; |
| 175 this.url = mainRequest.url; | 188 this.url = mainRequest.url; |
| 176 this.startTime = mainRequest.startTime; | 189 this.startTime = mainRequest.startTime; |
| 177 } | 190 } |
| 178 | 191 |
| 179 WebInspector.PageLoad._lastIdentifier = 0; | 192 WebInspector.PageLoad._lastIdentifier = 0; |
| OLD | NEW |