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 27 matching lines...) Expand all Loading... |
38 WebInspector.NetworkLog = function(target, resourceTreeModel, networkManager) | 38 WebInspector.NetworkLog = function(target, resourceTreeModel, networkManager) |
39 { | 39 { |
40 WebInspector.SDKModel.call(this, WebInspector.NetworkLog, target); | 40 WebInspector.SDKModel.call(this, WebInspector.NetworkLog, target); |
41 | 41 |
42 this._requests = []; | 42 this._requests = []; |
43 this._requestForId = {}; | 43 this._requestForId = {}; |
44 networkManager.addEventListener(WebInspector.NetworkManager.Events.RequestSt
arted, this._onRequestStarted, this); | 44 networkManager.addEventListener(WebInspector.NetworkManager.Events.RequestSt
arted, this._onRequestStarted, this); |
45 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Mai
nFrameNavigated, this._onMainFrameNavigated, this); | 45 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Mai
nFrameNavigated, this._onMainFrameNavigated, this); |
46 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Loa
d, this._onLoad, this); | 46 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Loa
d, this._onLoad, this); |
47 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.DOM
ContentLoaded, this._onDOMContentLoaded, this); | 47 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.DOM
ContentLoaded, this._onDOMContentLoaded, this); |
48 } | 48 }; |
49 | 49 |
50 /** | 50 /** |
51 * @param {!WebInspector.Target} target | 51 * @param {!WebInspector.Target} target |
52 * @return {?WebInspector.NetworkLog} | 52 * @return {?WebInspector.NetworkLog} |
53 */ | 53 */ |
54 WebInspector.NetworkLog.fromTarget = function(target) | 54 WebInspector.NetworkLog.fromTarget = function(target) |
55 { | 55 { |
56 return /** @type {?WebInspector.NetworkLog} */ (target.model(WebInspector.Ne
tworkLog)); | 56 return /** @type {?WebInspector.NetworkLog} */ (target.model(WebInspector.Ne
tworkLog)); |
57 } | 57 }; |
58 | 58 |
59 /** | 59 /** |
60 * @param {string} url | 60 * @param {string} url |
61 * @return {?WebInspector.NetworkRequest} | 61 * @return {?WebInspector.NetworkRequest} |
62 */ | 62 */ |
63 WebInspector.NetworkLog.requestForURL = function(url) | 63 WebInspector.NetworkLog.requestForURL = function(url) |
64 { | 64 { |
65 for (var target of WebInspector.targetManager.targets()) { | 65 for (var target of WebInspector.targetManager.targets()) { |
66 var networkLog = WebInspector.NetworkLog.fromTarget(target); | 66 var networkLog = WebInspector.NetworkLog.fromTarget(target); |
67 var result = networkLog && networkLog.requestForURL(url); | 67 var result = networkLog && networkLog.requestForURL(url); |
68 if (result) | 68 if (result) |
69 return result; | 69 return result; |
70 } | 70 } |
71 return null; | 71 return null; |
72 } | 72 }; |
73 | 73 |
74 /** | 74 /** |
75 * @return {!Array.<!WebInspector.NetworkRequest>} | 75 * @return {!Array.<!WebInspector.NetworkRequest>} |
76 */ | 76 */ |
77 WebInspector.NetworkLog.requests = function() | 77 WebInspector.NetworkLog.requests = function() |
78 { | 78 { |
79 var result = []; | 79 var result = []; |
80 for (var target of WebInspector.targetManager.targets()) { | 80 for (var target of WebInspector.targetManager.targets()) { |
81 var networkLog = WebInspector.NetworkLog.fromTarget(target); | 81 var networkLog = WebInspector.NetworkLog.fromTarget(target); |
82 if (networkLog) | 82 if (networkLog) |
83 result = result.concat(networkLog.requests()); | 83 result = result.concat(networkLog.requests()); |
84 } | 84 } |
85 return result; | 85 return result; |
86 } | 86 }; |
87 | 87 |
88 WebInspector.NetworkLog.prototype = { | 88 WebInspector.NetworkLog.prototype = { |
89 /** | 89 /** |
90 * @return {!Array.<!WebInspector.NetworkRequest>} | 90 * @return {!Array.<!WebInspector.NetworkRequest>} |
91 */ | 91 */ |
92 requests: function() | 92 requests: function() |
93 { | 93 { |
94 return this._requests; | 94 return this._requests; |
95 }, | 95 }, |
96 | 96 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 /** | 170 /** |
171 * @param {!NetworkAgent.RequestId} requestId | 171 * @param {!NetworkAgent.RequestId} requestId |
172 * @return {?WebInspector.NetworkRequest} | 172 * @return {?WebInspector.NetworkRequest} |
173 */ | 173 */ |
174 requestForId: function(requestId) | 174 requestForId: function(requestId) |
175 { | 175 { |
176 return this._requestForId[requestId]; | 176 return this._requestForId[requestId]; |
177 }, | 177 }, |
178 | 178 |
179 __proto__: WebInspector.SDKModel.prototype | 179 __proto__: WebInspector.SDKModel.prototype |
180 } | 180 }; |
181 | 181 |
182 /** | 182 /** |
183 * @constructor | 183 * @constructor |
184 * @param {!WebInspector.NetworkRequest} mainRequest | 184 * @param {!WebInspector.NetworkRequest} mainRequest |
185 */ | 185 */ |
186 WebInspector.PageLoad = function(mainRequest) | 186 WebInspector.PageLoad = function(mainRequest) |
187 { | 187 { |
188 this.id = ++WebInspector.PageLoad._lastIdentifier; | 188 this.id = ++WebInspector.PageLoad._lastIdentifier; |
189 this.url = mainRequest.url; | 189 this.url = mainRequest.url; |
190 this.startTime = mainRequest.startTime; | 190 this.startTime = mainRequest.startTime; |
191 } | 191 }; |
192 | 192 |
193 WebInspector.PageLoad._lastIdentifier = 0; | 193 WebInspector.PageLoad._lastIdentifier = 0; |
OLD | NEW |