Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 27 matching lines...) Expand all Loading... | |
| 38 * @param {string} displayName | 38 * @param {string} displayName |
| 39 */ | 39 */ |
| 40 WebInspector.ContentProviderBasedProject = function(workspace, id, type, display Name) | 40 WebInspector.ContentProviderBasedProject = function(workspace, id, type, display Name) |
| 41 { | 41 { |
| 42 WebInspector.ProjectStore.call(this, workspace, id, type, displayName); | 42 WebInspector.ProjectStore.call(this, workspace, id, type, displayName); |
| 43 /** @type {!Object.<string, !WebInspector.ContentProvider>} */ | 43 /** @type {!Object.<string, !WebInspector.ContentProvider>} */ |
| 44 this._contentProviders = {}; | 44 this._contentProviders = {}; |
| 45 workspace.addProject(this); | 45 workspace.addProject(this); |
| 46 } | 46 } |
| 47 | 47 |
| 48 WebInspector.ContentProviderBasedProject._metadata = Symbol("ContentProviderBase dProject.Metadata"); | |
| 49 | |
| 48 WebInspector.ContentProviderBasedProject.prototype = { | 50 WebInspector.ContentProviderBasedProject.prototype = { |
| 49 /** | 51 /** |
| 50 * @override | 52 * @override |
| 51 * @param {!WebInspector.UISourceCode} uiSourceCode | 53 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 52 * @param {function(?string)} callback | 54 * @param {function(?string)} callback |
| 53 */ | 55 */ |
| 54 requestFileContent: function(uiSourceCode, callback) | 56 requestFileContent: function(uiSourceCode, callback) |
| 55 { | 57 { |
| 56 var contentProvider = this._contentProviders[uiSourceCode.url()]; | 58 var contentProvider = this._contentProviders[uiSourceCode.url()]; |
| 57 contentProvider.requestContent().then(callback); | 59 contentProvider.requestContent().then(callback); |
| 58 }, | 60 }, |
| 59 | 61 |
| 60 /** | 62 /** |
| 61 * @override | 63 * @override |
| 62 * @param {!WebInspector.UISourceCode} uiSourceCode | 64 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 63 * @return {!Promise<?WebInspector.UISourceCodeMetadata>} | 65 * @return {!Promise<?WebInspector.UISourceCodeMetadata>} |
| 64 */ | 66 */ |
| 65 requestMetadata: function(uiSourceCode) | 67 requestMetadata: function(uiSourceCode) |
| 66 { | 68 { |
| 67 return Promise.resolve(/** @type {?WebInspector.UISourceCodeMetadata} */ (null)); | 69 return Promise.resolve(uiSourceCode[WebInspector.ContentProviderBasedPro ject._metadata]); |
| 68 }, | 70 }, |
| 69 | 71 |
| 70 /** | 72 /** |
| 71 * @override | 73 * @override |
| 72 * @return {boolean} | 74 * @return {boolean} |
| 73 */ | 75 */ |
| 74 canSetFileContent: function() | 76 canSetFileContent: function() |
| 75 { | 77 { |
| 76 return false; | 78 return false; |
| 77 }, | 79 }, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 * @param {!WebInspector.Progress} progress | 270 * @param {!WebInspector.Progress} progress |
| 269 */ | 271 */ |
| 270 indexContent: function(progress) | 272 indexContent: function(progress) |
| 271 { | 273 { |
| 272 setImmediate(progress.done.bind(progress)); | 274 setImmediate(progress.done.bind(progress)); |
| 273 }, | 275 }, |
| 274 | 276 |
| 275 /** | 277 /** |
| 276 * @param {!WebInspector.UISourceCode} uiSourceCode | 278 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 277 * @param {!WebInspector.ContentProvider} contentProvider | 279 * @param {!WebInspector.ContentProvider} contentProvider |
| 280 * @param {?WebInspector.UISourceCodeMetadata} metadata | |
| 278 */ | 281 */ |
| 279 addUISourceCodeWithProvider: function(uiSourceCode, contentProvider) | 282 addUISourceCodeWithProvider: function(uiSourceCode, contentProvider, metadat a) |
| 280 { | 283 { |
| 281 this._contentProviders[uiSourceCode.url()] = contentProvider; | 284 this._contentProviders[uiSourceCode.url()] = contentProvider; |
| 285 uiSourceCode[WebInspector.ContentProviderBasedProject._metadata] = metad ata || null; | |
|
dgozman
2016/10/14 21:49:20
nit: no need for || null
lushnikov
2016/10/14 22:46:39
Done.
| |
| 282 this.addUISourceCode(uiSourceCode, true); | 286 this.addUISourceCode(uiSourceCode, true); |
| 283 }, | 287 }, |
| 284 | 288 |
| 285 /** | 289 /** |
| 286 * @param {string} url | 290 * @param {string} url |
| 287 * @param {!WebInspector.ContentProvider} contentProvider | 291 * @param {!WebInspector.ContentProvider} contentProvider |
| 288 * @return {!WebInspector.UISourceCode} | 292 * @return {!WebInspector.UISourceCode} |
| 289 */ | 293 */ |
| 290 addContentProvider: function(url, contentProvider) | 294 addContentProvider: function(url, contentProvider) |
|
dgozman
2016/10/14 21:49:20
Why no metadata here?
lushnikov
2016/10/14 22:46:39
This method doesn't have any clients who're intere
| |
| 291 { | 295 { |
| 292 var uiSourceCode = this.createUISourceCode(url, contentProvider.contentT ype()); | 296 var uiSourceCode = this.createUISourceCode(url, contentProvider.contentT ype()); |
| 293 this.addUISourceCodeWithProvider(uiSourceCode, contentProvider); | 297 this.addUISourceCodeWithProvider(uiSourceCode, contentProvider, null); |
| 294 return uiSourceCode; | 298 return uiSourceCode; |
| 295 }, | 299 }, |
| 296 | 300 |
| 297 /** | 301 /** |
| 298 * @param {string} path | 302 * @param {string} path |
| 299 */ | 303 */ |
| 300 removeFile: function(path) | 304 removeFile: function(path) |
| 301 { | 305 { |
| 302 delete this._contentProviders[path]; | 306 delete this._contentProviders[path]; |
| 303 this.removeUISourceCode(path); | 307 this.removeUISourceCode(path); |
| 304 }, | 308 }, |
| 305 | 309 |
| 306 reset: function() | 310 reset: function() |
| 307 { | 311 { |
| 308 this._contentProviders = {}; | 312 this._contentProviders = {}; |
| 309 this.removeProject(); | 313 this.removeProject(); |
| 310 this.workspace().addProject(this); | 314 this.workspace().addProject(this); |
| 311 }, | 315 }, |
| 312 | 316 |
| 313 dispose: function() | 317 dispose: function() |
| 314 { | 318 { |
| 315 this._contentProviders = {}; | 319 this._contentProviders = {}; |
| 316 this.removeProject(); | 320 this.removeProject(); |
| 317 }, | 321 }, |
| 318 | 322 |
| 319 __proto__: WebInspector.ProjectStore.prototype | 323 __proto__: WebInspector.ProjectStore.prototype |
| 320 } | 324 } |
| OLD | NEW |