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

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

Issue 2784413003: DevTools: carefully cleanup javascript sourcemaps (Closed)
Patch Set: address comments Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/Script.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @template T 6 * @template T
7 */ 7 */
8 SDK.SourceMapManager = class extends SDK.SDKObject { 8 SDK.SourceMapManager = class extends SDK.SDKObject {
9 /** 9 /**
10 * @param {!SDK.Target} target 10 * @param {!SDK.Target} target
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return; 124 return;
125 this._relativeSourceURL.set(client, sourceURL); 125 this._relativeSourceURL.set(client, sourceURL);
126 this._relativeSourceMapURL.set(client, sourceMapURL); 126 this._relativeSourceMapURL.set(client, sourceMapURL);
127 this._resolvedSourceMapURL.set(client, resolvedURLs.sourceMapURL); 127 this._resolvedSourceMapURL.set(client, resolvedURLs.sourceMapURL);
128 128
129 sourceURL = resolvedURLs.sourceURL; 129 sourceURL = resolvedURLs.sourceURL;
130 sourceMapURL = resolvedURLs.sourceMapURL; 130 sourceMapURL = resolvedURLs.sourceMapURL;
131 if (!this._isEnabled) 131 if (!this._isEnabled)
132 return; 132 return;
133 133
134 this.dispatchEventToListeners(SDK.SourceMapManager.Events.SourceMapWillAttac h, client);
135
134 if (this._sourceMapByURL.has(sourceMapURL)) { 136 if (this._sourceMapByURL.has(sourceMapURL)) {
135 attach.call(this, sourceMapURL, client); 137 attach.call(this, sourceMapURL, client);
136 return; 138 return;
137 } 139 }
138 if (!this._sourceMapURLToLoadingClients.has(sourceMapURL)) { 140 if (!this._sourceMapURLToLoadingClients.has(sourceMapURL)) {
139 SDK.TextSourceMap.load(sourceMapURL, sourceURL) 141 SDK.TextSourceMap.load(sourceMapURL, sourceURL)
140 .then(onTextSourceMapLoaded.bind(this, sourceMapURL)) 142 .then(onTextSourceMapLoaded.bind(this, sourceMapURL))
141 .then(onSourceMap.bind(this, sourceMapURL)); 143 .then(onSourceMap.bind(this, sourceMapURL));
142 } 144 }
143 this._sourceMapURLToLoadingClients.set(sourceMapURL, client); 145 this._sourceMapURLToLoadingClients.set(sourceMapURL, client);
(...skipping 18 matching lines...) Expand all
162 164
163 /** 165 /**
164 * @param {string} sourceMapURL 166 * @param {string} sourceMapURL
165 * @param {?SDK.SourceMap} sourceMap 167 * @param {?SDK.SourceMap} sourceMap
166 * @this {SDK.SourceMapManager} 168 * @this {SDK.SourceMapManager}
167 */ 169 */
168 function onSourceMap(sourceMapURL, sourceMap) { 170 function onSourceMap(sourceMapURL, sourceMap) {
169 this._sourceMapLoadedForTest(); 171 this._sourceMapLoadedForTest();
170 var clients = this._sourceMapURLToLoadingClients.get(sourceMapURL); 172 var clients = this._sourceMapURLToLoadingClients.get(sourceMapURL);
171 this._sourceMapURLToLoadingClients.removeAll(sourceMapURL); 173 this._sourceMapURLToLoadingClients.removeAll(sourceMapURL);
172 if (!sourceMap || !clients.size) 174 if (!clients.size)
173 return; 175 return;
176 if (!sourceMap) {
177 for (var client of clients)
178 this.dispatchEventToListeners(SDK.SourceMapManager.Events.SourceMapFai ledToAttach, client);
179 return;
180 }
174 this._sourceMapByURL.set(sourceMapURL, sourceMap); 181 this._sourceMapByURL.set(sourceMapURL, sourceMap);
175 for (var client of clients) 182 for (var client of clients)
176 attach.call(this, sourceMapURL, client); 183 attach.call(this, sourceMapURL, client);
177 } 184 }
178 185
179 /** 186 /**
180 * @param {string} sourceMapURL 187 * @param {string} sourceMapURL
181 * @param {!T} client 188 * @param {!T} client
182 * @this {SDK.SourceMapManager} 189 * @this {SDK.SourceMapManager}
183 */ 190 */
(...skipping 26 matching lines...) Expand all
210 */ 217 */
211 detachSourceMap(client) { 218 detachSourceMap(client) {
212 var sourceMapURL = this._resolvedSourceMapURL.get(client); 219 var sourceMapURL = this._resolvedSourceMapURL.get(client);
213 this._relativeSourceURL.delete(client); 220 this._relativeSourceURL.delete(client);
214 this._relativeSourceMapURL.delete(client); 221 this._relativeSourceMapURL.delete(client);
215 this._resolvedSourceMapURL.delete(client); 222 this._resolvedSourceMapURL.delete(client);
216 223
217 if (!sourceMapURL) 224 if (!sourceMapURL)
218 return; 225 return;
219 if (!this._sourceMapURLToClients.hasValue(sourceMapURL, client)) { 226 if (!this._sourceMapURLToClients.hasValue(sourceMapURL, client)) {
220 this._sourceMapURLToLoadingClients.remove(sourceMapURL, client); 227 if (this._sourceMapURLToLoadingClients.remove(sourceMapURL, client))
228 this.dispatchEventToListeners(SDK.SourceMapManager.Events.SourceMapFaile dToAttach, client);
221 return; 229 return;
222 } 230 }
223 this._sourceMapURLToClients.remove(sourceMapURL, client); 231 this._sourceMapURLToClients.remove(sourceMapURL, client);
224 var sourceMap = this._sourceMapByURL.get(sourceMapURL); 232 var sourceMap = this._sourceMapByURL.get(sourceMapURL);
225 if (!this._sourceMapURLToClients.has(sourceMapURL)) 233 if (!this._sourceMapURLToClients.has(sourceMapURL))
226 this._sourceMapByURL.delete(sourceMapURL); 234 this._sourceMapByURL.delete(sourceMapURL);
227 this.dispatchEventToListeners( 235 this.dispatchEventToListeners(
228 SDK.SourceMapManager.Events.SourceMapDetached, {client: client, sourceMa p: sourceMap}); 236 SDK.SourceMapManager.Events.SourceMapDetached, {client: client, sourceMa p: sourceMap});
229 } 237 }
230 238
231 _sourceMapLoadedForTest() { 239 _sourceMapLoadedForTest() {
232 } 240 }
233 241
234 dispose() { 242 dispose() {
235 SDK.targetManager.removeEventListener( 243 SDK.targetManager.removeEventListener(
236 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged, this); 244 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged, this);
237 } 245 }
238 }; 246 };
239 247
240 SDK.SourceMapManager.Events = { 248 SDK.SourceMapManager.Events = {
249 SourceMapWillAttach: Symbol('SourceMapWillAttach'),
250 SourceMapFailedToAttach: Symbol('SourceMapFailedToAttach'),
241 SourceMapAttached: Symbol('SourceMapAttached'), 251 SourceMapAttached: Symbol('SourceMapAttached'),
242 SourceMapDetached: Symbol('SourceMapDetached'), 252 SourceMapDetached: Symbol('SourceMapDetached'),
243 SourceMapChanged: Symbol('SourceMapChanged') 253 SourceMapChanged: Symbol('SourceMapChanged')
244 }; 254 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/Script.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698