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

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: Pass NetworkManager as a ctor parameter, to ensure proper initialization order. 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) {
dgozman 2016/06/29 18:37:57 style: { on next line
eostroukhov-old 2016/06/29 22:54:20 Done.
58 return target[WebInspector.NetworkLog._symbol] || null;
46 } 59 }
47 60
48 /** 61 /**
49 * @param {string} url 62 * @param {string} url
50 * @return {?WebInspector.NetworkRequest} 63 * @return {?WebInspector.NetworkRequest}
51 */ 64 */
52 WebInspector.NetworkLog.requestForURL = function(url) 65 WebInspector.NetworkLog.requestForURL = function(url)
53 { 66 {
54 for (var target of WebInspector.targetManager.targets()) { 67 for (var target of WebInspector.targetManager.targets()) {
55 var result = target.networkLog.requestForURL(url); 68 var networkLog = WebInspector.NetworkLog.fromTarget(target);
69 var result = networkLog && networkLog.requestForURL(url);
56 if (result) 70 if (result)
57 return result; 71 return result;
58 } 72 }
59 return null; 73 return null;
60 } 74 }
61 75
62 /** 76 /**
63 * @return {!Array.<!WebInspector.NetworkRequest>} 77 * @return {!Array.<!WebInspector.NetworkRequest>}
64 */ 78 */
65 WebInspector.NetworkLog.requests = function() 79 WebInspector.NetworkLog.requests = function()
66 { 80 {
67 var result = []; 81 var result = [];
68 for (var target of WebInspector.targetManager.targets()) { 82 for (var target of WebInspector.targetManager.targets()) {
69 result = result.concat(target.networkLog.requests()); 83 var networkLog = WebInspector.NetworkLog.fromTarget(target);
84 if (networkLog)
85 result = result.concat(networkLog.requests());
70 } 86 }
71 return result; 87 return result;
72 } 88 }
73 89
74 WebInspector.NetworkLog.prototype = { 90 WebInspector.NetworkLog.prototype = {
75 /** 91 /**
76 * @return {!Array.<!WebInspector.NetworkRequest>} 92 * @return {!Array.<!WebInspector.NetworkRequest>}
77 */ 93 */
78 requests: function() 94 requests: function()
79 { 95 {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 * @param {!WebInspector.NetworkRequest} mainRequest 186 * @param {!WebInspector.NetworkRequest} mainRequest
171 */ 187 */
172 WebInspector.PageLoad = function(mainRequest) 188 WebInspector.PageLoad = function(mainRequest)
173 { 189 {
174 this.id = ++WebInspector.PageLoad._lastIdentifier; 190 this.id = ++WebInspector.PageLoad._lastIdentifier;
175 this.url = mainRequest.url; 191 this.url = mainRequest.url;
176 this.startTime = mainRequest.startTime; 192 this.startTime = mainRequest.startTime;
177 } 193 }
178 194
179 WebInspector.PageLoad._lastIdentifier = 0; 195 WebInspector.PageLoad._lastIdentifier = 0;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698