Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/NetworkLog.js

Issue 2109813003: [DevTools] No NetworkManager and NetworkLog for v8only mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing code review comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
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.SDKObject}
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.SDKObject.call(this, 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);
47 console.assert(!target[WebInspector.NetworkLog._symbol]);
48 target[WebInspector.NetworkLog._symbol] = this;
49 }
50
51 WebInspector.NetworkLog._symbol = Symbol("NetworkLog");
52
53 /**
54 * @param {!WebInspector.Target} target
55 * @return {?WebInspector.NetworkLog}
56 */
57 WebInspector.NetworkLog.fromTarget = function(target)
58 {
59 return target[WebInspector.NetworkLog._symbol] || null;
dgozman 2016/07/05 17:54:31 Let's use target.model(WebInspector.NetworkLog). S
eostroukhov-old 2016/07/06 20:37:53 Done. Note that this required changing the supercl
46 } 60 }
47 61
48 /** 62 /**
49 * @param {string} url 63 * @param {string} url
50 * @return {?WebInspector.NetworkRequest} 64 * @return {?WebInspector.NetworkRequest}
51 */ 65 */
52 WebInspector.NetworkLog.requestForURL = function(url) 66 WebInspector.NetworkLog.requestForURL = function(url)
53 { 67 {
54 for (var target of WebInspector.targetManager.targets()) { 68 for (var target of WebInspector.targetManager.targets()) {
55 var result = target.networkLog.requestForURL(url); 69 var networkLog = WebInspector.NetworkLog.fromTarget(target);
70 var result = networkLog && networkLog.requestForURL(url);
56 if (result) 71 if (result)
57 return result; 72 return result;
58 } 73 }
59 return null; 74 return null;
60 } 75 }
61 76
62 /** 77 /**
63 * @return {!Array.<!WebInspector.NetworkRequest>} 78 * @return {!Array.<!WebInspector.NetworkRequest>}
64 */ 79 */
65 WebInspector.NetworkLog.requests = function() 80 WebInspector.NetworkLog.requests = function()
66 { 81 {
67 var result = []; 82 var result = [];
68 for (var target of WebInspector.targetManager.targets()) { 83 for (var target of WebInspector.targetManager.targets()) {
69 result = result.concat(target.networkLog.requests()); 84 var networkLog = WebInspector.NetworkLog.fromTarget(target);
85 if (networkLog)
86 result = result.concat(networkLog.requests());
70 } 87 }
71 return result; 88 return result;
72 } 89 }
73 90
74 WebInspector.NetworkLog.prototype = { 91 WebInspector.NetworkLog.prototype = {
75 /** 92 /**
76 * @return {!Array.<!WebInspector.NetworkRequest>} 93 * @return {!Array.<!WebInspector.NetworkRequest>}
77 */ 94 */
78 requests: function() 95 requests: function()
79 { 96 {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 * @param {!WebInspector.NetworkRequest} mainRequest 187 * @param {!WebInspector.NetworkRequest} mainRequest
171 */ 188 */
172 WebInspector.PageLoad = function(mainRequest) 189 WebInspector.PageLoad = function(mainRequest)
173 { 190 {
174 this.id = ++WebInspector.PageLoad._lastIdentifier; 191 this.id = ++WebInspector.PageLoad._lastIdentifier;
175 this.url = mainRequest.url; 192 this.url = mainRequest.url;
176 this.startTime = mainRequest.startTime; 193 this.startTime = mainRequest.startTime;
177 } 194 }
178 195
179 WebInspector.PageLoad._lastIdentifier = 0; 196 WebInspector.PageLoad._lastIdentifier = 0;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698