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

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

Issue 2626553002: [Devtools][Code health] Changed NetworkRequest.url to proper getter/setter (Closed)
Patch Set: changes Created 3 years, 11 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) 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 29 matching lines...) Expand all
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(target, requestId, url, documentURL, frameId, loaderId, initiator) {
45 super(target); 45 super(target);
46 46
47 this._networkLog = /** @type {!SDK.NetworkLog} */ (SDK.NetworkLog.fromTarget (target)); 47 this._networkLog = /** @type {!SDK.NetworkLog} */ (SDK.NetworkLog.fromTarget (target));
48 this._networkManager = /** @type {!SDK.NetworkManager} */ (SDK.NetworkManage r.fromTarget(target)); 48 this._networkManager = /** @type {!SDK.NetworkManager} */ (SDK.NetworkManage r.fromTarget(target));
49 this._requestId = requestId; 49 this._requestId = requestId;
50 this.url = url; 50 this.setUrl(url);
51 this._documentURL = documentURL; 51 this._documentURL = documentURL;
52 this._frameId = frameId; 52 this._frameId = frameId;
53 this._loaderId = loaderId; 53 this._loaderId = loaderId;
54 /** @type {?Protocol.Network.Initiator} */ 54 /** @type {?Protocol.Network.Initiator} */
55 this._initiator = initiator; 55 this._initiator = initiator;
56 this._issueTime = -1; 56 this._issueTime = -1;
57 this._startTime = -1; 57 this._startTime = -1;
58 this._endTime = -1; 58 this._endTime = -1;
59 /** @type {!Protocol.Network.BlockedReason|undefined} */ 59 /** @type {!Protocol.Network.BlockedReason|undefined} */
60 this._blockedReason = undefined; 60 this._blockedReason = undefined;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 /** 116 /**
117 * @param {!Protocol.Network.RequestId} requestId 117 * @param {!Protocol.Network.RequestId} requestId
118 */ 118 */
119 setRequestId(requestId) { 119 setRequestId(requestId) {
120 this._requestId = requestId; 120 this._requestId = requestId;
121 } 121 }
122 122
123 /** 123 /**
124 * @return {string} 124 * @return {string}
125 */ 125 */
126 get url() { 126 url() {
127 return this._url; 127 return this._url;
128 } 128 }
129 129
130 /** 130 /**
131 * @param {string} x 131 * @param {string} x
132 */ 132 */
133 set url(x) { 133 setUrl(x) {
134 if (this._url === x) 134 if (this._url === x)
135 return; 135 return;
136 136
137 this._url = x; 137 this._url = x;
138 this._parsedURL = new Common.ParsedURL(x); 138 this._parsedURL = new Common.ParsedURL(x);
139 delete this._queryString; 139 delete this._queryString;
140 delete this._parsedQueryParameters; 140 delete this._parsedQueryParameters;
141 delete this._name; 141 delete this._name;
142 delete this._path; 142 delete this._path;
143 } 143 }
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 755 }
756 756
757 /** 757 /**
758 * @return {?string} 758 * @return {?string}
759 */ 759 */
760 queryString() { 760 queryString() {
761 if (this._queryString !== undefined) 761 if (this._queryString !== undefined)
762 return this._queryString; 762 return this._queryString;
763 763
764 var queryString = null; 764 var queryString = null;
765 var url = this.url; 765 var url = this.url();
766 var questionMarkPosition = url.indexOf('?'); 766 var questionMarkPosition = url.indexOf('?');
767 if (questionMarkPosition !== -1) { 767 if (questionMarkPosition !== -1) {
768 queryString = url.substring(questionMarkPosition + 1); 768 queryString = url.substring(questionMarkPosition + 1);
769 var hashSignPosition = queryString.indexOf('#'); 769 var hashSignPosition = queryString.indexOf('#');
770 if (hashSignPosition !== -1) 770 if (hashSignPosition !== -1)
771 queryString = queryString.substring(0, hashSignPosition); 771 queryString = queryString.substring(0, hashSignPosition);
772 } 772 }
773 this._queryString = queryString; 773 this._queryString = queryString;
774 return this._queryString; 774 return this._queryString;
775 } 775 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 * @param {function(!Array.<!Common.ContentProvider.SearchMatch>)} callback 915 * @param {function(!Array.<!Common.ContentProvider.SearchMatch>)} callback
916 */ 916 */
917 searchInContent(query, caseSensitive, isRegex, callback) { 917 searchInContent(query, caseSensitive, isRegex, callback) {
918 callback([]); 918 callback([]);
919 } 919 }
920 920
921 /** 921 /**
922 * @return {boolean} 922 * @return {boolean}
923 */ 923 */
924 isHttpFamily() { 924 isHttpFamily() {
925 return !!this.url.match(/^https?:/i); 925 return !!this.url().match(/^https?:/i);
926 } 926 }
927 927
928 /** 928 /**
929 * @return {string|undefined} 929 * @return {string|undefined}
930 */ 930 */
931 requestContentType() { 931 requestContentType() {
932 return this.requestHeaderValue('Content-Type'); 932 return this.requestHeaderValue('Content-Type');
933 } 933 }
934 934
935 /** 935 /**
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1038
1039 var type = SDK.NetworkRequest.InitiatorType.Other; 1039 var type = SDK.NetworkRequest.InitiatorType.Other;
1040 var url = ''; 1040 var url = '';
1041 var lineNumber = -Infinity; 1041 var lineNumber = -Infinity;
1042 var columnNumber = -Infinity; 1042 var columnNumber = -Infinity;
1043 var scriptId = null; 1043 var scriptId = null;
1044 var initiator = this._initiator; 1044 var initiator = this._initiator;
1045 1045
1046 if (this.redirectSource) { 1046 if (this.redirectSource) {
1047 type = SDK.NetworkRequest.InitiatorType.Redirect; 1047 type = SDK.NetworkRequest.InitiatorType.Redirect;
1048 url = this.redirectSource.url; 1048 url = this.redirectSource.url();
1049 } else if (initiator) { 1049 } else if (initiator) {
1050 if (initiator.type === Protocol.Network.InitiatorType.Parser) { 1050 if (initiator.type === Protocol.Network.InitiatorType.Parser) {
1051 type = SDK.NetworkRequest.InitiatorType.Parser; 1051 type = SDK.NetworkRequest.InitiatorType.Parser;
1052 url = initiator.url ? initiator.url : url; 1052 url = initiator.url ? initiator.url : url;
1053 lineNumber = initiator.lineNumber ? initiator.lineNumber : lineNumber; 1053 lineNumber = initiator.lineNumber ? initiator.lineNumber : lineNumber;
1054 } else if (initiator.type === Protocol.Network.InitiatorType.Script) { 1054 } else if (initiator.type === Protocol.Network.InitiatorType.Script) {
1055 for (var stack = initiator.stack; stack; stack = stack.parent) { 1055 for (var stack = initiator.stack; stack; stack = stack.parent) {
1056 var topFrame = stack.callFrames.length ? stack.callFrames[0] : null; 1056 var topFrame = stack.callFrames.length ? stack.callFrames[0] : null;
1057 if (!topFrame) 1057 if (!topFrame)
1058 continue; 1058 continue;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 }; 1222 };
1223 1223
1224 /** @typedef {!{type: SDK.NetworkRequest.WebSocketFrameType, time: number, text: string, opCode: number, mask: boolean}} */ 1224 /** @typedef {!{type: SDK.NetworkRequest.WebSocketFrameType, time: number, text: string, opCode: number, mask: boolean}} */
1225 SDK.NetworkRequest.WebSocketFrame; 1225 SDK.NetworkRequest.WebSocketFrame;
1226 1226
1227 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}} */ 1227 /** @typedef {!{time: number, eventName: string, eventId: string, data: string}} */
1228 SDK.NetworkRequest.EventSourceMessage; 1228 SDK.NetworkRequest.EventSourceMessage;
1229 1229
1230 /** @typedef {!{initiators: !Set<!SDK.NetworkRequest>, initiated: !Set<!SDK.Netw orkRequest>}} */ 1230 /** @typedef {!{initiators: !Set<!SDK.NetworkRequest>, initiated: !Set<!SDK.Netw orkRequest>}} */
1231 SDK.NetworkRequest.InitiatorGraph; 1231 SDK.NetworkRequest.InitiatorGraph;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698