Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.TargetManager} targetManager | 7 * @param {!WebInspector.TargetManager} targetManager |
| 8 * @param {!WebInspector.Workspace} workspace | 8 * @param {!WebInspector.Workspace} workspace |
| 9 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding | 9 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding |
| 10 * @param {!WebInspector.FileSystemMapping} fileSystemMapping | 10 * @param {!WebInspector.FileSystemMapping} fileSystemMapping |
| 11 */ | 11 */ |
| 12 WebInspector.NetworkMapping = function(targetManager, workspace, fileSystemWorks paceBinding, fileSystemMapping) | 12 WebInspector.NetworkMapping = function(targetManager, workspace, fileSystemWorks paceBinding, fileSystemMapping) |
| 13 { | 13 { |
| 14 this._targetManager = targetManager; | 14 this._targetManager = targetManager; |
| 15 this._workspace = workspace; | 15 this._workspace = workspace; |
| 16 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; | 16 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; |
| 17 this._fileSystemMapping = fileSystemMapping; | 17 this._fileSystemMapping = fileSystemMapping; |
| 18 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.RevealSourceLine, this._revealSourceLine, this); | 18 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.RevealSourceLine, this._revealSourceLine, this); |
| 19 | 19 |
| 20 // For now, following block is here primarily for testing since in the real life, network manager is created early enough to capture those events. | 20 // For now, following block is here primarily for testing since in the real life, network manager is created early enough to capture those events. |
| 21 var fileSystemManager = fileSystemWorkspaceBinding.fileSystemManager(); | 21 var fileSystemManager = fileSystemWorkspaceBinding.fileSystemManager(); |
| 22 for (var path of fileSystemManager.fileSystemPaths()) { | 22 for (var fileSystem of fileSystemManager.fileSystems()) |
| 23 var fileSystem = fileSystemManager.fileSystem(path); | 23 this._addMappingsForFilesystem(fileSystem); |
|
dgozman
2016/08/31 00:08:35
You don't issue fileSystemMappingChanged here anym
lushnikov
2016/08/31 00:19:30
it is an event listener
| |
| 24 this._fileSystemAdded(new WebInspector.Event(fileSystemManager, WebInspe ctor.IsolatedFileSystemManager.Events.FileSystemAdded, fileSystem)); | |
| 25 } | |
| 26 if (fileSystemManager.fileSystemsLoaded()) | 24 if (fileSystemManager.fileSystemsLoaded()) |
| 27 this._fileSystemsLoaded(); | 25 this._fileSystemsLoaded(); |
| 28 | 26 |
| 29 this._eventListeners = [ | 27 this._eventListeners = [ |
| 30 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage r.Events.FileSystemAdded, this._fileSystemAdded, this), | 28 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage r.Events.FileSystemAdded, this._fileSystemAdded, this), |
| 31 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage r.Events.FileSystemRemoved, this._fileSystemRemoved, this), | 29 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage r.Events.FileSystemRemoved, this._fileSystemRemoved, this), |
| 32 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage r.Events.FileSystemsLoaded, this._fileSystemsLoaded, this), | 30 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage r.Events.FileSystemsLoaded, this._fileSystemsLoaded, this), |
| 33 this._fileSystemMapping.addEventListener(WebInspector.FileSystemMapping. Events.FileMappingAdded, this._fileSystemMappingChanged, this), | 31 this._fileSystemMapping.addEventListener(WebInspector.FileSystemMapping. Events.FileMappingAdded, this._fileSystemMappingChanged, this), |
| 34 this._fileSystemMapping.addEventListener(WebInspector.FileSystemMapping. Events.FileMappingRemoved, this._fileSystemMappingChanged, this) | 32 this._fileSystemMapping.addEventListener(WebInspector.FileSystemMapping. Events.FileMappingRemoved, this._fileSystemMappingChanged, this) |
| 35 ]; | 33 ]; |
| 36 } | 34 } |
| 37 | 35 |
| 38 WebInspector.NetworkMapping.prototype = { | 36 WebInspector.NetworkMapping.prototype = { |
| 39 /** | 37 /** |
| 40 * @param {!WebInspector.Event} event | 38 * @param {!WebInspector.Event} event |
| 41 */ | 39 */ |
| 42 _fileSystemAdded: function(event) | 40 _fileSystemAdded: function(event) |
| 43 { | 41 { |
| 42 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); | |
| 43 this._addMappingsForFilesystem(fileSystem); | |
| 44 this._fileSystemMappingChanged(); | |
| 45 }, | |
| 46 | |
| 47 /** | |
| 48 * @param {!WebInspector.IsolatedFileSystem} fileSystem | |
| 49 */ | |
| 50 _addMappingsForFilesystem: function(fileSystem) | |
| 51 { | |
| 44 this._addingFileSystem = true; | 52 this._addingFileSystem = true; |
| 45 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); | |
| 46 this._fileSystemMapping.addFileSystem(fileSystem.path()); | 53 this._fileSystemMapping.addFileSystem(fileSystem.path()); |
| 47 | 54 |
| 48 var mappings = fileSystem.projectProperty("mappings"); | 55 var mappings = fileSystem.projectProperty("mappings"); |
| 49 for (var i = 0; Array.isArray(mappings) && i < mappings.length; ++i) { | 56 for (var i = 0; Array.isArray(mappings) && i < mappings.length; ++i) { |
| 50 var mapping = mappings[i]; | 57 var mapping = mappings[i]; |
| 51 if (!mapping || typeof mapping !== "object") | 58 if (!mapping || typeof mapping !== "object") |
| 52 continue; | 59 continue; |
| 53 var folder = mapping["folder"]; | 60 var folder = mapping["folder"]; |
| 54 var url = mapping["url"]; | 61 var url = mapping["url"]; |
| 55 if (typeof folder !== "string" || typeof url !== "string") | 62 if (typeof folder !== "string" || typeof url !== "string") |
| 56 continue; | 63 continue; |
| 57 this._fileSystemMapping.addNonConfigurableFileMapping(fileSystem.pat h(), url, folder); | 64 this._fileSystemMapping.addNonConfigurableFileMapping(fileSystem.pat h(), url, folder); |
| 58 } | 65 } |
| 59 this._addingFileSystem = false; | 66 this._addingFileSystem = false; |
| 60 this._fileSystemMappingChanged(); | |
| 61 }, | 67 }, |
| 62 | 68 |
| 63 /** | 69 /** |
| 64 * @param {!WebInspector.Event} event | 70 * @param {!WebInspector.Event} event |
| 65 */ | 71 */ |
| 66 _fileSystemRemoved: function(event) | 72 _fileSystemRemoved: function(event) |
| 67 { | 73 { |
| 68 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); | 74 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); |
| 69 this._fileSystemMapping.removeFileSystem(fileSystem.path()); | 75 this._fileSystemMapping.removeFileSystem(fileSystem.path()); |
| 70 this._fileSystemMappingChanged(); | 76 this._fileSystemMappingChanged(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 dispose: function() | 253 dispose: function() |
| 248 { | 254 { |
| 249 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 255 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
| 250 } | 256 } |
| 251 } | 257 } |
| 252 | 258 |
| 253 /** | 259 /** |
| 254 * @type {!WebInspector.NetworkMapping} | 260 * @type {!WebInspector.NetworkMapping} |
| 255 */ | 261 */ |
| 256 WebInspector.networkMapping; | 262 WebInspector.networkMapping; |
| OLD | NEW |