| OLD | NEW |
| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return; | 125 return; |
| 126 this._relativeSourceURL.set(client, sourceURL); | 126 this._relativeSourceURL.set(client, sourceURL); |
| 127 this._relativeSourceMapURL.set(client, sourceMapURL); | 127 this._relativeSourceMapURL.set(client, sourceMapURL); |
| 128 this._resolvedSourceMapURL.set(client, resolvedURLs.sourceMapURL); | 128 this._resolvedSourceMapURL.set(client, resolvedURLs.sourceMapURL); |
| 129 | 129 |
| 130 sourceURL = resolvedURLs.sourceURL; | 130 sourceURL = resolvedURLs.sourceURL; |
| 131 sourceMapURL = resolvedURLs.sourceMapURL; | 131 sourceMapURL = resolvedURLs.sourceMapURL; |
| 132 if (!this._isEnabled) | 132 if (!this._isEnabled) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 this.dispatchEventToListeners( |
| 136 SDK.SourceMapManager.Events.SourceMapWillAttach, {client: client, source
MapURL: sourceMapURL}); |
| 137 |
| 135 if (this._sourceMapByURL.has(sourceMapURL)) { | 138 if (this._sourceMapByURL.has(sourceMapURL)) { |
| 136 attach.call(this, sourceMapURL, client); | 139 attach.call(this, sourceMapURL, client); |
| 137 return; | 140 return; |
| 138 } | 141 } |
| 139 if (!this._sourceMapURLToLoadingClients.has(sourceMapURL)) { | 142 if (!this._sourceMapURLToLoadingClients.has(sourceMapURL)) { |
| 140 SDK.TextSourceMap.load(sourceMapURL, sourceURL) | 143 SDK.TextSourceMap.load(sourceMapURL, sourceURL) |
| 141 .then(onTextSourceMapLoaded.bind(this, sourceMapURL)) | 144 .then(onTextSourceMapLoaded.bind(this, sourceMapURL)) |
| 142 .then(onSourceMap.bind(this, sourceMapURL)); | 145 .then(onSourceMap.bind(this, sourceMapURL)); |
| 143 } | 146 } |
| 144 this._sourceMapURLToLoadingClients.set(sourceMapURL, client); | 147 this._sourceMapURLToLoadingClients.set(sourceMapURL, client); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 163 | 166 |
| 164 /** | 167 /** |
| 165 * @param {string} sourceMapURL | 168 * @param {string} sourceMapURL |
| 166 * @param {?SDK.SourceMap} sourceMap | 169 * @param {?SDK.SourceMap} sourceMap |
| 167 * @this {SDK.SourceMapManager} | 170 * @this {SDK.SourceMapManager} |
| 168 */ | 171 */ |
| 169 function onSourceMap(sourceMapURL, sourceMap) { | 172 function onSourceMap(sourceMapURL, sourceMap) { |
| 170 this._sourceMapLoadedForTest(); | 173 this._sourceMapLoadedForTest(); |
| 171 var clients = this._sourceMapURLToLoadingClients.get(sourceMapURL); | 174 var clients = this._sourceMapURLToLoadingClients.get(sourceMapURL); |
| 172 this._sourceMapURLToLoadingClients.removeAll(sourceMapURL); | 175 this._sourceMapURLToLoadingClients.removeAll(sourceMapURL); |
| 173 if (!sourceMap || !clients.size) | 176 if (!clients.size) |
| 174 return; | 177 return; |
| 178 if (!sourceMap) { |
| 179 for (var client of clients) { |
| 180 this.dispatchEventToListeners( |
| 181 SDK.SourceMapManager.Events.SourceMapFailedToAttach, {client: clie
nt, sourceMapURL: sourceMapURL}); |
| 182 } |
| 183 return; |
| 184 } |
| 175 this._sourceMapByURL.set(sourceMapURL, sourceMap); | 185 this._sourceMapByURL.set(sourceMapURL, sourceMap); |
| 176 for (var client of clients) | 186 for (var client of clients) |
| 177 attach.call(this, sourceMapURL, client); | 187 attach.call(this, sourceMapURL, client); |
| 178 } | 188 } |
| 179 | 189 |
| 180 /** | 190 /** |
| 181 * @param {string} sourceMapURL | 191 * @param {string} sourceMapURL |
| 182 * @param {!T} client | 192 * @param {!T} client |
| 183 * @this {SDK.SourceMapManager} | 193 * @this {SDK.SourceMapManager} |
| 184 */ | 194 */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 211 */ | 221 */ |
| 212 detachSourceMap(client) { | 222 detachSourceMap(client) { |
| 213 var sourceMapURL = this._resolvedSourceMapURL.get(client); | 223 var sourceMapURL = this._resolvedSourceMapURL.get(client); |
| 214 this._relativeSourceURL.delete(client); | 224 this._relativeSourceURL.delete(client); |
| 215 this._relativeSourceMapURL.delete(client); | 225 this._relativeSourceMapURL.delete(client); |
| 216 this._resolvedSourceMapURL.delete(client); | 226 this._resolvedSourceMapURL.delete(client); |
| 217 | 227 |
| 218 if (!sourceMapURL) | 228 if (!sourceMapURL) |
| 219 return; | 229 return; |
| 220 if (!this._sourceMapURLToClients.hasValue(sourceMapURL, client)) { | 230 if (!this._sourceMapURLToClients.hasValue(sourceMapURL, client)) { |
| 221 this._sourceMapURLToLoadingClients.remove(sourceMapURL, client); | 231 if (this._sourceMapURLToLoadingClients.remove(sourceMapURL, client)) { |
| 232 this.dispatchEventToListeners( |
| 233 SDK.SourceMapManager.Events.SourceMapFailedToAttach, {client: client
, sourceMapURL: sourceMapURL}); |
| 234 } |
| 222 return; | 235 return; |
| 223 } | 236 } |
| 224 this._sourceMapURLToClients.remove(sourceMapURL, client); | 237 this._sourceMapURLToClients.remove(sourceMapURL, client); |
| 225 var sourceMap = this._sourceMapByURL.get(sourceMapURL); | 238 var sourceMap = this._sourceMapByURL.get(sourceMapURL); |
| 226 if (!this._sourceMapURLToClients.has(sourceMapURL)) | 239 if (!this._sourceMapURLToClients.has(sourceMapURL)) |
| 227 this._sourceMapByURL.delete(sourceMapURL); | 240 this._sourceMapByURL.delete(sourceMapURL); |
| 228 this.dispatchEventToListeners( | 241 this.dispatchEventToListeners( |
| 229 SDK.SourceMapManager.Events.SourceMapDetached, {client: client, sourceMa
p: sourceMap}); | 242 SDK.SourceMapManager.Events.SourceMapDetached, {client: client, sourceMa
p: sourceMap}); |
| 230 } | 243 } |
| 231 | 244 |
| 232 _sourceMapLoadedForTest() { | 245 _sourceMapLoadedForTest() { |
| 233 } | 246 } |
| 234 | 247 |
| 235 dispose() { | 248 dispose() { |
| 236 SDK.targetManager.removeEventListener( | 249 SDK.targetManager.removeEventListener( |
| 237 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged,
this); | 250 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged,
this); |
| 238 } | 251 } |
| 239 }; | 252 }; |
| 240 | 253 |
| 241 SDK.SourceMapManager.Events = { | 254 SDK.SourceMapManager.Events = { |
| 255 SourceMapWillAttach: Symbol('SourceMapWillAttach'), |
| 256 SourceMapFailedToAttach: Symbol('SourceMapFailedToAttach'), |
| 242 SourceMapAttached: Symbol('SourceMapAttached'), | 257 SourceMapAttached: Symbol('SourceMapAttached'), |
| 243 SourceMapDetached: Symbol('SourceMapDetached'), | 258 SourceMapDetached: Symbol('SourceMapDetached'), |
| 244 SourceMapChanged: Symbol('SourceMapChanged') | 259 SourceMapChanged: Symbol('SourceMapChanged') |
| 245 }; | 260 }; |
| OLD | NEW |