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

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

Issue 2784413003: DevTools: carefully cleanup javascript sourcemaps (Closed)
Patch Set: 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
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(
135 SDK.SourceMapManager.Events.SourceMapWillAttach, {client: client, source MapURL: sourceMapURL});
dgozman 2017/03/31 21:57:41 drop sourceMapURL
lushnikov 2017/03/31 23:53:10 Done.
136
134 if (this._sourceMapByURL.has(sourceMapURL)) { 137 if (this._sourceMapByURL.has(sourceMapURL)) {
135 attach.call(this, sourceMapURL, client); 138 attach.call(this, sourceMapURL, client);
136 return; 139 return;
137 } 140 }
138 if (!this._sourceMapURLToLoadingClients.has(sourceMapURL)) { 141 if (!this._sourceMapURLToLoadingClients.has(sourceMapURL)) {
139 SDK.TextSourceMap.load(sourceMapURL, sourceURL) 142 SDK.TextSourceMap.load(sourceMapURL, sourceURL)
140 .then(onTextSourceMapLoaded.bind(this, sourceMapURL)) 143 .then(onTextSourceMapLoaded.bind(this, sourceMapURL))
141 .then(onSourceMap.bind(this, sourceMapURL)); 144 .then(onSourceMap.bind(this, sourceMapURL));
142 } 145 }
143 this._sourceMapURLToLoadingClients.set(sourceMapURL, client); 146 this._sourceMapURLToLoadingClients.set(sourceMapURL, client);
(...skipping 18 matching lines...) Expand all
162 165
163 /** 166 /**
164 * @param {string} sourceMapURL 167 * @param {string} sourceMapURL
165 * @param {?SDK.SourceMap} sourceMap 168 * @param {?SDK.SourceMap} sourceMap
166 * @this {SDK.SourceMapManager} 169 * @this {SDK.SourceMapManager}
167 */ 170 */
168 function onSourceMap(sourceMapURL, sourceMap) { 171 function onSourceMap(sourceMapURL, sourceMap) {
169 this._sourceMapLoadedForTest(); 172 this._sourceMapLoadedForTest();
170 var clients = this._sourceMapURLToLoadingClients.get(sourceMapURL); 173 var clients = this._sourceMapURLToLoadingClients.get(sourceMapURL);
171 this._sourceMapURLToLoadingClients.removeAll(sourceMapURL); 174 this._sourceMapURLToLoadingClients.removeAll(sourceMapURL);
172 if (!sourceMap || !clients.size) 175 if (!clients.size)
173 return; 176 return;
177 if (!sourceMap) {
178 for (var client of clients) {
179 this.dispatchEventToListeners(
180 SDK.SourceMapManager.Events.SourceMapFailedToAttach, {client: clie nt, sourceMapURL: sourceMapURL});
dgozman 2017/03/31 21:57:41 drop sourceMapURL
lushnikov 2017/03/31 23:53:10 Done.
181 }
182 return;
183 }
174 this._sourceMapByURL.set(sourceMapURL, sourceMap); 184 this._sourceMapByURL.set(sourceMapURL, sourceMap);
175 for (var client of clients) 185 for (var client of clients)
176 attach.call(this, sourceMapURL, client); 186 attach.call(this, sourceMapURL, client);
177 } 187 }
178 188
179 /** 189 /**
180 * @param {string} sourceMapURL 190 * @param {string} sourceMapURL
181 * @param {!T} client 191 * @param {!T} client
182 * @this {SDK.SourceMapManager} 192 * @this {SDK.SourceMapManager}
183 */ 193 */
(...skipping 26 matching lines...) Expand all
210 */ 220 */
211 detachSourceMap(client) { 221 detachSourceMap(client) {
212 var sourceMapURL = this._resolvedSourceMapURL.get(client); 222 var sourceMapURL = this._resolvedSourceMapURL.get(client);
213 this._relativeSourceURL.delete(client); 223 this._relativeSourceURL.delete(client);
214 this._relativeSourceMapURL.delete(client); 224 this._relativeSourceMapURL.delete(client);
215 this._resolvedSourceMapURL.delete(client); 225 this._resolvedSourceMapURL.delete(client);
216 226
217 if (!sourceMapURL) 227 if (!sourceMapURL)
218 return; 228 return;
219 if (!this._sourceMapURLToClients.hasValue(sourceMapURL, client)) { 229 if (!this._sourceMapURLToClients.hasValue(sourceMapURL, client)) {
220 this._sourceMapURLToLoadingClients.remove(sourceMapURL, client); 230 if (this._sourceMapURLToLoadingClients.remove(sourceMapURL, client)) {
231 this.dispatchEventToListeners(
232 SDK.SourceMapManager.Events.SourceMapFailedToAttach, {client: client , sourceMapURL: sourceMapURL});
dgozman 2017/03/31 21:57:41 drop sourceMapURL
lushnikov 2017/03/31 23:53:10 Done.
233 }
221 return; 234 return;
222 } 235 }
223 this._sourceMapURLToClients.remove(sourceMapURL, client); 236 this._sourceMapURLToClients.remove(sourceMapURL, client);
224 var sourceMap = this._sourceMapByURL.get(sourceMapURL); 237 var sourceMap = this._sourceMapByURL.get(sourceMapURL);
225 if (!this._sourceMapURLToClients.has(sourceMapURL)) 238 if (!this._sourceMapURLToClients.has(sourceMapURL))
226 this._sourceMapByURL.delete(sourceMapURL); 239 this._sourceMapByURL.delete(sourceMapURL);
227 this.dispatchEventToListeners( 240 this.dispatchEventToListeners(
228 SDK.SourceMapManager.Events.SourceMapDetached, {client: client, sourceMa p: sourceMap}); 241 SDK.SourceMapManager.Events.SourceMapDetached, {client: client, sourceMa p: sourceMap});
229 } 242 }
230 243
231 _sourceMapLoadedForTest() { 244 _sourceMapLoadedForTest() {
232 } 245 }
233 246
234 dispose() { 247 dispose() {
235 SDK.targetManager.removeEventListener( 248 SDK.targetManager.removeEventListener(
236 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged, this); 249 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged, this);
237 } 250 }
238 }; 251 };
239 252
240 SDK.SourceMapManager.Events = { 253 SDK.SourceMapManager.Events = {
254 SourceMapWillAttach: Symbol('SourceMapWillAttach'),
dgozman 2017/03/31 21:57:41 SourceMapWillBeAttached
lushnikov 2017/03/31 23:53:10 Decided to keep this as-is: renamed event looked l
255 SourceMapFailedToAttach: Symbol('SourceMapFailedToAttach'),
241 SourceMapAttached: Symbol('SourceMapAttached'), 256 SourceMapAttached: Symbol('SourceMapAttached'),
242 SourceMapDetached: Symbol('SourceMapDetached'), 257 SourceMapDetached: Symbol('SourceMapDetached'),
243 SourceMapChanged: Symbol('SourceMapChanged') 258 SourceMapChanged: Symbol('SourceMapChanged')
244 }; 259 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698