OLD | NEW |
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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 * @override | 926 * @override |
927 * @return {!WebInspector.ResourceType} | 927 * @return {!WebInspector.ResourceType} |
928 */ | 928 */ |
929 contentType: function() | 929 contentType: function() |
930 { | 930 { |
931 return this._resourceType; | 931 return this._resourceType; |
932 }, | 932 }, |
933 | 933 |
934 /** | 934 /** |
935 * @override | 935 * @override |
936 * @param {function(?string)} callback | 936 * @return {!Promise<?string>} |
937 */ | 937 */ |
938 requestContent: function(callback) | 938 requestContent: function() |
939 { | 939 { |
940 // We do not support content retrieval for WebSockets at the moment. | 940 // We do not support content retrieval for WebSockets at the moment. |
941 // Since WebSockets are potentially long-living, fail requests immediate
ly | 941 // Since WebSockets are potentially long-living, fail requests immediate
ly |
942 // to prevent caller blocking until resource is marked as finished. | 942 // to prevent caller blocking until resource is marked as finished. |
943 if (this._resourceType === WebInspector.resourceTypes.WebSocket) { | 943 if (this._resourceType === WebInspector.resourceTypes.WebSocket) |
944 callback(null); | 944 return Promise.resolve(/** @type {?string} */(null)); |
945 return; | 945 if (typeof this._content !== "undefined") |
946 } | 946 return Promise.resolve(/** @type {?string} */(this.content || null))
; |
947 if (typeof this._content !== "undefined") { | 947 var callback; |
948 callback(this.content || null); | 948 var promise = new Promise(fulfill => callback = fulfill); |
949 return; | |
950 } | |
951 this._pendingContentCallbacks.push(callback); | 949 this._pendingContentCallbacks.push(callback); |
952 if (this.finished) | 950 if (this.finished) |
953 this._innerRequestContent(); | 951 this._innerRequestContent(); |
| 952 return promise; |
954 }, | 953 }, |
955 | 954 |
956 /** | 955 /** |
957 * @override | 956 * @override |
958 * @param {string} query | 957 * @param {string} query |
959 * @param {boolean} caseSensitive | 958 * @param {boolean} caseSensitive |
960 * @param {boolean} isRegex | 959 * @param {boolean} isRegex |
961 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback | 960 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback |
962 */ | 961 */ |
963 searchInContent: function(query, caseSensitive, isRegex, callback) | 962 searchInContent: function(query, caseSensitive, isRegex, callback) |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.EventSo
urceMessageAdded, message); | 1181 this.dispatchEventToListeners(WebInspector.NetworkRequest.Events.EventSo
urceMessageAdded, message); |
1183 }, | 1182 }, |
1184 | 1183 |
1185 replayXHR: function() | 1184 replayXHR: function() |
1186 { | 1185 { |
1187 this.target().networkAgent().replayXHR(this.requestId); | 1186 this.target().networkAgent().replayXHR(this.requestId); |
1188 }, | 1187 }, |
1189 | 1188 |
1190 __proto__: WebInspector.SDKObject.prototype | 1189 __proto__: WebInspector.SDKObject.prototype |
1191 } | 1190 } |
OLD | NEW |