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

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

Issue 1609973002: DevTools: promisify ContentProvider.requestContent and all its clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 * @override 131 * @override
132 * @return {!WebInspector.ResourceType} 132 * @return {!WebInspector.ResourceType}
133 */ 133 */
134 contentType: function() 134 contentType: function()
135 { 135 {
136 return WebInspector.resourceTypes.Script; 136 return WebInspector.resourceTypes.Script;
137 }, 137 },
138 138
139 /** 139 /**
140 * @override 140 * @override
141 * @param {function(?string)} callback 141 * @return {!Promise<?string>}
142 */ 142 */
143 requestContent: function(callback) 143 requestContent: function()
144 { 144 {
145 if (this._source) { 145 if (this._source)
146 callback(this._source); 146 return Promise.resolve(this._source);
147 return; 147 if (!this.scriptId)
148 } 148 return Promise.resolve(/** @type {?string} */(""));
149
150 var callback;
151 var promise = new Promise(fulfill => callback = fulfill);
152 this.target().debuggerAgent().getScriptSource(this.scriptId, didGetScrip tSource.bind(this));
153 return promise;
149 154
150 /** 155 /**
151 * @this {WebInspector.Script} 156 * @this {WebInspector.Script}
152 * @param {?Protocol.Error} error 157 * @param {?Protocol.Error} error
153 * @param {string} source 158 * @param {string} source
154 */ 159 */
155 function didGetScriptSource(error, source) 160 function didGetScriptSource(error, source)
156 { 161 {
157 this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source); 162 this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source);
158 callback(this._source); 163 callback(this._source);
159 } 164 }
160 if (this.scriptId) {
161 // Script failed to parse.
162 this.target().debuggerAgent().getScriptSource(this.scriptId, didGetS criptSource.bind(this));
163 } else
164 callback("");
165 }, 165 },
166 166
167 /** 167 /**
168 * @override 168 * @override
169 * @param {string} query 169 * @param {string} query
170 * @param {boolean} caseSensitive 170 * @param {boolean} caseSensitive
171 * @param {boolean} isRegex 171 * @param {boolean} isRegex
172 * @param {function(!Array.<!DebuggerAgent.SearchMatch>)} callback 172 * @param {function(!Array.<!DebuggerAgent.SearchMatch>)} callback
173 */ 173 */
174 searchInContent: function(query, caseSensitive, isRegex, callback) 174 searchInContent: function(query, caseSensitive, isRegex, callback)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 /** 284 /**
285 * @return {boolean} 285 * @return {boolean}
286 */ 286 */
287 isInlineScriptWithSourceURL: function() 287 isInlineScriptWithSourceURL: function()
288 { 288 {
289 return !!this.hasSourceURL && this.isInlineScript(); 289 return !!this.hasSourceURL && this.isInlineScript();
290 }, 290 },
291 291
292 __proto__: WebInspector.SDKObject.prototype 292 __proto__: WebInspector.SDKObject.prototype
293 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698