Title: [143327] trunk
Revision
143327
Author
vse...@chromium.org
Date
2013-02-19 06:59:38 -0800 (Tue, 19 Feb 2013)

Log Message

Web Inspector: Decouple various file system project implementation parts for better testability and cover with tests.
https://bugs.webkit.org/show_bug.cgi?id=110204

Reviewed by Pavel Feldman.

Source/WebCore:

Extracted FileSystemWorkspaceProvider from IsolatedFileSystemManager to take care of managing workspace projects and projectDelegates.
Replaced FileMapping.urlForURI with urlForPath method that does not need any information about workspace structure anymore.

Test: inspector/file-system-project.html

* inspector/front-end/FileMapping.js:
(WebInspector.FileMapping.prototype.urlForPath):
* inspector/front-end/FileSystemProjectDelegate.js:
(WebInspector.FileSystemProjectDelegate):
(WebInspector.FileSystemProjectDelegate.prototype.populate.filesLoaded):
(WebInspector.FileSystemProjectDelegate.prototype.populate):
(WebInspector.FileSystemWorkspaceProvider):
(WebInspector.FileSystemWorkspaceProvider.prototype._fileSystemAdded):
(WebInspector.FileSystemWorkspaceProvider.prototype._fileSystemRemoved):
* inspector/front-end/IsolatedFileSystem.js:
(WebInspector.IsolatedFileSystem):
(WebInspector.IsolatedFileSystem.prototype.name):
(WebInspector.IsolatedFileSystem.prototype.rootURL):
* inspector/front-end/IsolatedFileSystemManager.js:
(WebInspector.IsolatedFileSystemManager):
(WebInspector.IsolatedFileSystemManager.prototype._innerAddFileSystem):
(WebInspector.IsolatedFileSystemManager.prototype._fileSystemRemoved):
(WebInspector.IsolatedFileSystemManager.prototype._isolatedFileSystem):
(WebInspector.IsolatedFileSystemManager.prototype.requestDOMFileSystem):
* inspector/front-end/inspector.js:

LayoutTests:

* http/tests/inspector/inspector-test.js:
(initialize_InspectorTest):
(initialize_InspectorTest.):
* http/tests/inspector/workspace-test.js:
(initialize_WorkspaceTest.uiSourceCodeAdded):
(initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeAddedEvent):
(initialize_WorkspaceTest.InspectorTest._defaultUISourceCodeProviderEventHandler):
* inspector/file-mapping-expected.txt:
* inspector/file-mapping.html:
* inspector/file-system-project-expected.txt: Added.
* inspector/file-system-project.html: Added.
* inspector/version-controller.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (143326 => 143327)


--- trunk/LayoutTests/ChangeLog	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/LayoutTests/ChangeLog	2013-02-19 14:59:38 UTC (rev 143327)
@@ -1,3 +1,23 @@
+2013-02-19  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Decouple various file system project implementation parts for better testability and cover with tests.
+        https://bugs.webkit.org/show_bug.cgi?id=110204
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/inspector-test.js:
+        (initialize_InspectorTest):
+        (initialize_InspectorTest.):
+        * http/tests/inspector/workspace-test.js:
+        (initialize_WorkspaceTest.uiSourceCodeAdded):
+        (initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeAddedEvent):
+        (initialize_WorkspaceTest.InspectorTest._defaultUISourceCodeProviderEventHandler):
+        * inspector/file-mapping-expected.txt:
+        * inspector/file-mapping.html:
+        * inspector/file-system-project-expected.txt: Added.
+        * inspector/file-system-project.html: Added.
+        * inspector/version-controller.html:
+
 2013-02-19  Andrey Adaikin  <aand...@chromium.org>
 
         Web Inspector: [Canvas] UI: tweak replay control buttons behavior

Modified: trunk/LayoutTests/http/tests/inspector/inspector-test.js (143326 => 143327)


--- trunk/LayoutTests/http/tests/inspector/inspector-test.js	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/LayoutTests/http/tests/inspector/inspector-test.js	2013-02-19 14:59:38 UTC (rev 143327)
@@ -400,8 +400,23 @@
     }
 };
 
+InspectorTest.MockSetting = function(value)
+{
+    this._value = value;
 };
 
+InspectorTest.MockSetting.prototype = {
+    get: function() {
+        return this._value;
+    },
+
+    set: function(value) {
+        this._value = value;
+    }
+};
+
+};
+
 var initializeCallId = 0;
 var runTestCallId = 1;
 var completeTestCallId = 2;

Modified: trunk/LayoutTests/http/tests/inspector/workspace-test.js (143326 => 143327)


--- trunk/LayoutTests/http/tests/inspector/workspace-test.js	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/LayoutTests/http/tests/inspector/workspace-test.js	2013-02-19 14:59:38 UTC (rev 143327)
@@ -9,15 +9,18 @@
     InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, InspectorTest._defaultUISourceCodeProviderEventHandler);
 }
 
-InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback)
+InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback, count)
 {
+    InspectorTest.uiSourceCodeAddedEventsLeft = count || 1;
     InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
     InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
 
     function uiSourceCodeAdded(event)
     {
-        InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
-        InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
+        if (!(--InspectorTest.uiSourceCodeAddedEventsLeft)) {
+            InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
+            InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
+        }
         callback(event.data);
     }
 }
@@ -31,7 +34,8 @@
 
 InspectorTest._defaultUISourceCodeProviderEventHandler = function(event)
 {
-    throw new Error("Unexpected UISourceCodeProvider event: " + event.type + ".");
+    var uiSourceCode = event.data;
+    throw new Error("Unexpected UISourceCodeProvider event: " + event.type + ": " + uiSourceCode.uri() + ".");
 }
 
 InspectorTest.dumpUISourceCode = function(uiSourceCode, callback)

Modified: trunk/LayoutTests/inspector/file-mapping-expected.txt (143326 => 143327)


--- trunk/LayoutTests/inspector/file-mapping-expected.txt	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/LayoutTests/inspector/file-mapping-expected.txt	2013-02-19 14:59:38 UTC (rev 143327)
@@ -10,7 +10,5 @@
 http://www.example.com/
 http://localhost/index.html
 http://localhost/foo/index.html
-
-
 All mappings were correct.
 

Modified: trunk/LayoutTests/inspector/file-mapping.html (143326 => 143327)


--- trunk/LayoutTests/inspector/file-mapping.html	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/LayoutTests/inspector/file-mapping.html	2013-02-19 14:59:38 UTC (rev 143327)
@@ -37,12 +37,10 @@
     InspectorTest.addResult(fileMapping.uriForURL("https://localhost"));
     InspectorTest.addResult(fileMapping.uriForURL("http://example.com"));
 
-    InspectorTest.addResult(fileMapping.urlForURI("uri:/home/example.com"));
-    InspectorTest.addResult(fileMapping.urlForURI("uri:/home/example.com/"));
-    InspectorTest.addResult(fileMapping.urlForURI("uri:/var/www/index.html"));
-    InspectorTest.addResult(fileMapping.urlForURI("uri:/var/www/foo/index.html"));
-    InspectorTest.addResult(fileMapping.urlForURI("https://localhost"));
-    InspectorTest.addResult(fileMapping.urlForURI("http://example.com"));
+    InspectorTest.addResult(fileMapping.urlForPath("/home/example.com"));
+    InspectorTest.addResult(fileMapping.urlForPath("/home/example.com/"));
+    InspectorTest.addResult(fileMapping.urlForPath("/var/www/index.html"));
+    InspectorTest.addResult(fileMapping.urlForPath("/var/www/foo/index.html"));
 
     InspectorTest.addResult("All mappings were correct.");
     InspectorTest.completeTest();

Added: trunk/LayoutTests/inspector/file-system-project-expected.txt (0 => 143327)


--- trunk/LayoutTests/inspector/file-system-project-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/file-system-project-expected.txt	2013-02-19 14:59:38 UTC (rev 143327)
@@ -0,0 +1,36 @@
+Tests file system project.
+
+
+Running: testFileSystems
+Adding first file system.
+Adding second file system.
+
+UISourceCode: file:///var/www/localhost/foo.js
+UISourceCode is editable: true
+UISourceCode is content script: false
+Mime type: text/_javascript_
+UISourceCode content: <foo content>
+
+UISourceCode: file:///var/www/bar.js
+UISourceCode is editable: true
+UISourceCode is content script: false
+Mime type: text/_javascript_
+UISourceCode content: <bar content>
+
+UISourceCode: file:///foo/bar/baz.js
+UISourceCode is editable: true
+UISourceCode is content script: false
+Mime type: text/_javascript_
+UISourceCode content: <baz content>
+
+UISourceCode uri to url mappings:
+    0@www/localhost/foo.js -> http://localhost/foo.js
+    1@bar/baz.js -> http://www.example.com/baz.js
+UISourceCode url to uri mappings:
+    http://localhost/foo.js -> 0@www/localhost/foo.js
+    http://www.example.com/baz.js -> 1@bar/baz.js
+Removing second file system.
+    number of uiSourceCodes in workspace after removing second file system: 1
+Removing first file system.
+    number of uiSourceCodes in workspace after removing first file system: 0
+

Added: trunk/LayoutTests/inspector/file-system-project.html (0 => 143327)


--- trunk/LayoutTests/inspector/file-system-project.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/file-system-project.html	2013-02-19 14:59:38 UTC (rev 143327)
@@ -0,0 +1,146 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script>
+function test()
+{
+    var MockIsolatedFileSystem = function(id, path, files)
+    {
+        this._id = id;
+        this._path = path;
+        this._files = files;
+    };
+    MockIsolatedFileSystem.prototype = {
+        id: function()
+        {
+            return this._id;
+        },
+
+        path: function()
+        {
+            return this._path;
+        },
+
+        requestFileContent: function(path, callback)
+        {
+            callback(this._files[path]);
+        },
+
+        setFileContent: function(path, newContent, callback)
+        {
+            this._files[path] = newContent;
+            callback();
+        },
+
+        requestFilesRecursive: function(path, callback)
+        {
+            callback(Object.keys(this._files));
+        },
+    }
+
+    var MockIsolatedFileSystemManager = function() {};
+    MockIsolatedFileSystemManager.prototype = {
+        addMockFileSystem: function(path, files)
+        {
+            var id = this.fileSystemMapping.addFileSystemMapping(path);
+            var fileSystem = new MockIsolatedFileSystem(id, path, files);
+            this._fileSystems = this._fileSystems || {};
+            this._fileSystems[path] = fileSystem;
+            this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemAdded, fileSystem);
+        },
+
+        removeMockFileSystem: function(path)
+        {
+            var fileSystem = this._fileSystems[path];
+            delete this._fileSystems[path];
+            this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, fileSystem);
+        },
+
+        __proto__: WebInspector.Object.prototype
+    }
+
+    function createIsolatedFileSystemManager()
+    {
+        InspectorTest.createWorkspace();
+        var manager = new MockIsolatedFileSystemManager();
+        manager.fileSystemMapping = new WebInspector.FileSystemMappingImpl();
+        manager.fileSystemMapping._fileSystemMappingSetting = new InspectorTest.MockSetting({});
+        InspectorTest.MockSetting
+        manager.fileMapping = new WebInspector.FileMapping(manager.fileSystemMapping);
+        manager.fileSystemWorkspaceProvider = new WebInspector.FileSystemWorkspaceProvider(manager, InspectorTest.testWorkspace, manager.fileMapping);
+        return manager;
+    }
+
+    function dumpUISourceCodes(uiSourceCodes, next)
+    {
+        innerDumpUISourceCodes(uiSourceCodes, 0, next);
+
+        function innerDumpUISourceCodes(uiSourceCodes, startIndex, next)
+        {
+            InspectorTest.addResult("");
+            if (startIndex === uiSourceCodes.length) {
+                next();
+                return;
+            }
+            InspectorTest.dumpUISourceCode(uiSourceCodes[startIndex], innerDumpUISourceCodes.bind(this, uiSourceCodes, startIndex + 1, next));
+        }
+    }
+
+    InspectorTest.runTestSuite([
+        function testFileSystems(next)
+        {
+            var uiSourceCodes = [];
+            var manager = createIsolatedFileSystemManager();
+            var entry1 = new WebInspector.FileMapping.Entry("http://localhost/", "/var/www/localhost/");
+            var entry2 = new WebInspector.FileMapping.Entry("http://www.example.com/", "/foo/bar/");
+            manager.fileMapping.setMappingEntries([entry1, entry2]);
+            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded, 3);
+            InspectorTest.addResult("Adding first file system.");
+            manager.addMockFileSystem("/var/www", {"/localhost/foo.js": "<foo content>", "/bar.js": "<bar content>"});
+            InspectorTest.addResult("Adding second file system.");
+            manager.addMockFileSystem("/foo/bar", {"/baz.js": "<baz content>"});
+
+            dumpUISourceCodes(uiSourceCodes, uiSourceCodesDumped);
+
+            function uiSourceCodeAdded(uiSourceCode)
+            {
+                uiSourceCodes.push(uiSourceCode)
+            }
+
+            function uiSourceCodesDumped()
+            {
+                InspectorTest.addResult("UISourceCode uri to url mappings:");
+                for (var i = 0; i < uiSourceCodes.length; ++i) {
+                    var url = ""
+                    if (!url)
+                        continue;
+                    InspectorTest.addResult("    " + uiSourceCodes[i].uri() + " -> " + uiSourceCodes[i].url);
+                }
+                InspectorTest.addResult("UISourceCode url to uri mappings:");
+                for (var i = 0; i < uiSourceCodes.length; ++i) {
+                    var url = ""
+                    if (!url)
+                        continue;
+                    var uri = manager.fileMapping.uriForURL(url);
+                    InspectorTest.addResult("    " + url + " -> " + uri);
+                }
+                var uiSourceCodesCount = InspectorTest.testWorkspace.uiSourceCodes().length;
+                InspectorTest.addResult("Removing second file system.");
+                manager.removeMockFileSystem("/var/www");
+                InspectorTest.addResult("    number of uiSourceCodes in workspace after removing second file system: " + InspectorTest.testWorkspace.uiSourceCodes().length);
+                InspectorTest.addResult("Removing first file system.");
+                manager.removeMockFileSystem("/foo/bar");
+                InspectorTest.addResult("    number of uiSourceCodes in workspace after removing first file system: " + InspectorTest.testWorkspace.uiSourceCodes().length);
+                next();
+            }
+        },
+    ]);
+};
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests file system project.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector/version-controller.html (143326 => 143327)


--- trunk/LayoutTests/inspector/version-controller.html	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/LayoutTests/inspector/version-controller.html	2013-02-19 14:59:38 UTC (rev 143327)
@@ -4,21 +4,6 @@
 <script>
 function test()
 {
-    var MockSetting = function(value)
-    {
-        this._value = value;
-    };
-    var value;
-    MockSetting.prototype = {
-        get: function() {
-            return this._value;
-        },
-
-        set: function(value) {
-            this._value = value;
-        }
-    }
-
     function createBreakpoint(uiSourceCodeId, lineNumber, condition, enabled)
     {
         return { sourceFileId: uiSourceCodeId, lineNumber: lineNumber, condition: condition, enabled: enabled };
@@ -57,7 +42,7 @@
                 var serializedBreakpoints = [];
                 for (var i = 0; i < breakpointsCount; ++i)
                     serializedBreakpoints.push(createBreakpoint("file" + i + ".js", i % 10, "", true));
-                var breakpointsSetting = new MockSetting(serializedBreakpoints);
+                var breakpointsSetting = new InspectorTest.MockSetting(serializedBreakpoints);
                 versionController._clearBreakpointsWhenTooMany(breakpointsSetting, maxBreakpointsCount);
                 InspectorTest.addResult("Number of breakpoints left in the setting after the test: " + breakpointsSetting.get().length + ".");
                 InspectorTest.addResult("");

Modified: trunk/Source/WebCore/ChangeLog (143326 => 143327)


--- trunk/Source/WebCore/ChangeLog	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/Source/WebCore/ChangeLog	2013-02-19 14:59:38 UTC (rev 143327)
@@ -1,3 +1,36 @@
+2013-02-19  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Decouple various file system project implementation parts for better testability and cover with tests.
+        https://bugs.webkit.org/show_bug.cgi?id=110204
+
+        Reviewed by Pavel Feldman.
+
+        Extracted FileSystemWorkspaceProvider from IsolatedFileSystemManager to take care of managing workspace projects and projectDelegates.
+        Replaced FileMapping.urlForURI with urlForPath method that does not need any information about workspace structure anymore.
+
+        Test: inspector/file-system-project.html
+
+        * inspector/front-end/FileMapping.js:
+        (WebInspector.FileMapping.prototype.urlForPath):
+        * inspector/front-end/FileSystemProjectDelegate.js:
+        (WebInspector.FileSystemProjectDelegate):
+        (WebInspector.FileSystemProjectDelegate.prototype.populate.filesLoaded):
+        (WebInspector.FileSystemProjectDelegate.prototype.populate):
+        (WebInspector.FileSystemWorkspaceProvider):
+        (WebInspector.FileSystemWorkspaceProvider.prototype._fileSystemAdded):
+        (WebInspector.FileSystemWorkspaceProvider.prototype._fileSystemRemoved):
+        * inspector/front-end/IsolatedFileSystem.js:
+        (WebInspector.IsolatedFileSystem):
+        (WebInspector.IsolatedFileSystem.prototype.name):
+        (WebInspector.IsolatedFileSystem.prototype.rootURL):
+        * inspector/front-end/IsolatedFileSystemManager.js:
+        (WebInspector.IsolatedFileSystemManager):
+        (WebInspector.IsolatedFileSystemManager.prototype._innerAddFileSystem):
+        (WebInspector.IsolatedFileSystemManager.prototype._fileSystemRemoved):
+        (WebInspector.IsolatedFileSystemManager.prototype._isolatedFileSystem):
+        (WebInspector.IsolatedFileSystemManager.prototype.requestDOMFileSystem):
+        * inspector/front-end/inspector.js:
+
 2013-02-19  Andrey Adaikin  <aand...@chromium.org>
 
         Web Inspector: [Canvas] do not replace replay image with spinner icon

Modified: trunk/Source/WebCore/inspector/front-end/FileMapping.js (143326 => 143327)


--- trunk/Source/WebCore/inspector/front-end/FileMapping.js	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/Source/WebCore/inspector/front-end/FileMapping.js	2013-02-19 14:59:38 UTC (rev 143327)
@@ -95,16 +95,15 @@
     },
     
     /**
-     * @param {string} uri
+     * @param {string} path
      * @return {string}
      */
-    urlForURI: function(uri)
+    urlForPath: function(path)
     {
         for (var i = 0; i < this._entries.length; ++i) {
             var entry = this._entries[i];
-            var uriPrefix = this._entryURIPrefix(entry);
-            if (uriPrefix && uri.startsWith(uriPrefix))
-                return entry.urlPrefix + uri.substring(uriPrefix.length);
+            if (path.startsWith(entry.pathPrefix))
+                return entry.urlPrefix + path.substring(entry.pathPrefix.length);
         }
         return "";
     },

Modified: trunk/Source/WebCore/inspector/front-end/FileSystemProjectDelegate.js (143326 => 143327)


--- trunk/Source/WebCore/inspector/front-end/FileSystemProjectDelegate.js	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemProjectDelegate.js	2013-02-19 14:59:38 UTC (rev 143327)
@@ -33,11 +33,12 @@
  * @implements {WebInspector.ProjectDelegate}
  * @extends {WebInspector.Object}
  * @param {WebInspector.IsolatedFileSystem} isolatedFileSystem
+ * @param {WebInspector.FileMapping} fileMapping
  */
-WebInspector.FileSystemProjectDelegate = function(isolatedFileSystem)
+WebInspector.FileSystemProjectDelegate = function(isolatedFileSystem, fileMapping)
 {
     this._fileSystem = isolatedFileSystem;
-    this._populate();
+    this._fileMapping = fileMapping;
 }
 
 WebInspector.FileSystemProjectDelegate._scriptExtensions = ["js", "java", "cc", "cpp", "h", "cs", "py", "php"].keySet();
@@ -153,19 +154,18 @@
         return WebInspector.resourceTypes.Other;
     },
 
-    _populate: function()
+    populate: function()
     {
         this._fileSystem.requestFilesRecursive("", filesLoaded.bind(this));
 
         function filesLoaded(files)
         {
             for (var i = 0; i < files.length; ++i) {
-                var path = files[i].substr(1);
-                // FIXME: FileSystemProject delegate should know nothing about UISourceCode.
-                var uri = WebInspector.UISourceCode.uri(this.id(), path);
-                var contentType = this._contentTypeForPath(files[i]);
-                var url = ""
-                var fileDescriptor = new WebInspector.FileDescriptor(path, "file://" + this._fileSystem.path() + files[i], url, contentType, true);
+                var fullPath = this._fileSystem.path() + files[i];
+                var path = files[i].substr(1); 
+                var url = ""
+                var contentType = this._contentTypeForPath(path);
+                var fileDescriptor = new WebInspector.FileDescriptor(path, "file://" + fullPath, url, contentType, true);
                 this._addFile(fileDescriptor);
             } 
         }
@@ -199,3 +199,48 @@
  * @type {?WebInspector.FileSystemProjectDelegate}
  */
 WebInspector.fileSystemProjectDelegate = null;
+
+/**
+ * @constructor
+ * @implements {WebInspector.ProjectDelegate}
+ * @param {WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager
+ * @param {WebInspector.Workspace} workspace
+ * @param {WebInspector.FileMapping} fileMapping
+ */
+WebInspector.FileSystemWorkspaceProvider = function(isolatedFileSystemManager, workspace, fileMapping)
+{
+    this._isolatedFileSystemManager = isolatedFileSystemManager;
+    this._workspace = workspace;
+    this._fileMapping = fileMapping;
+    this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemAdded, this._fileSystemAdded, this);
+    this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this);
+}
+
+WebInspector.FileSystemWorkspaceProvider.prototype = {
+    /**
+     * @param {WebInspector.event} event
+     */
+    _fileSystemAdded: function(event)
+    {
+        var fileSystem = /** @type {WebInspector.IsolatedFileSystem} */ (event.data);
+        console.assert(!this._workspace.project(fileSystem.id()));
+        var projectDelegate = new WebInspector.FileSystemProjectDelegate(fileSystem, this._fileMapping)
+        this._workspace.addProject(projectDelegate);
+        projectDelegate.populate();
+    },
+
+    /**
+     * @param {WebInspector.event} event
+     */
+    _fileSystemRemoved: function(event)
+    {
+        var fileSystem = /** @type {WebInspector.IsolatedFileSystem} */ (event.data);
+        if (fileSystem.id())
+            this._workspace.removeProject(fileSystem.id());
+    }
+}
+
+/**
+ * @type {?WebInspector.FileSystemWorkspaceProvider}
+ */
+WebInspector.fileSystemWorkspaceProvider = null;

Modified: trunk/Source/WebCore/inspector/front-end/IsolatedFileSystem.js (143326 => 143327)


--- trunk/Source/WebCore/inspector/front-end/IsolatedFileSystem.js	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/Source/WebCore/inspector/front-end/IsolatedFileSystem.js	2013-02-19 14:59:38 UTC (rev 143327)
@@ -34,11 +34,13 @@
  * @param {string} id
  * @param {string} path
  */
-WebInspector.IsolatedFileSystem = function(manager, id, path)
+WebInspector.IsolatedFileSystem = function(manager, id, path, name, rootURL)
 {
     this._manager = manager;
     this._id = id;
     this._path = path;
+    this._name = name;
+    this._rootURL = rootURL;
 }
 
 WebInspector.IsolatedFileSystem.errorMessage = function(error)
@@ -86,6 +88,22 @@
     },
 
     /**
+     * @return {string}
+     */
+    name: function()
+    {
+        return this._name;
+    },
+
+    /**
+     * @return {string}
+     */
+    rootURL: function()
+    {
+        return this._rootURL;
+    },
+
+    /**
      * @param {function(DOMFileSystem)} callback
      */
     _requestFileSystem: function(callback)

Modified: trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemManager.js (143326 => 143327)


--- trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemManager.js	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemManager.js	2013-02-19 14:59:38 UTC (rev 143327)
@@ -30,11 +30,10 @@
 
 /**
  * @constructor
- * @param {WebInspector.Workspace} workspace
+ * @extends {WebInspector.Object}
  */
-WebInspector.IsolatedFileSystemManager = function(workspace)
+WebInspector.IsolatedFileSystemManager = function()
 {
-    this._workspace = workspace;
     /** @type {!Object.<string, WebInspector.IsolatedFileSystemManager.FileSystem>} */
     this._fileSystems = {};
     /** @type {Object.<string, Array.<function(DOMFileSystem)>>} */
@@ -48,6 +47,11 @@
 /** @typedef {{fileSystemName: string, rootURL: string, fileSystemPath: string}} */
 WebInspector.IsolatedFileSystemManager.FileSystem;
 
+WebInspector.IsolatedFileSystemManager.Events = {
+    FileSystemAdded: "FileSystemAdded",
+    FileSystemRemoved: "FileSystemRemoved"
+}
+
 WebInspector.IsolatedFileSystemManager.prototype = {
     /**
      * @return {WebInspector.FileSystemMapping}
@@ -106,11 +110,10 @@
     _innerAddFileSystem: function(fileSystem)
     {
         var fileSystemPath = fileSystem.fileSystemPath;
-        this._fileSystems[fileSystemPath] = fileSystem;
         var fileSystemId = this._fileSystemMapping.addFileSystemMapping(fileSystemPath);
-        console.assert(!this._workspace.project(fileSystemId));
-        var isolatedFileSystem = new WebInspector.IsolatedFileSystem(this, fileSystemId, fileSystemPath);
-        this._workspace.addProject(new WebInspector.FileSystemProjectDelegate(isolatedFileSystem));
+        var isolatedFileSystem = new WebInspector.IsolatedFileSystem(this, fileSystemId, fileSystemPath, fileSystem.fileSystemName, fileSystem.rootURL);
+        this._fileSystems[fileSystemPath] = isolatedFileSystem;
+        this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemAdded, isolatedFileSystem);
     },
 
     /**
@@ -157,14 +160,14 @@
     _fileSystemRemoved: function(fileSystemPath)
     {
         var fileSystemId = this._fileSystemMapping.fileSystemId(fileSystemPath);
-        if (fileSystemId)
-            this._workspace.removeProject(fileSystemId);
         this._fileSystemMapping.removeFileSystemMapping(fileSystemPath);
+        var isolatedFileSystem = this._fileSystems[fileSystemPath];
         delete this._fileSystems[fileSystemPath];
         if (this._removeFileSystemCallback) {
             this._removeFileSystemCallback(fileSystemPath);
             delete this._removeFileSystemCallback;
         }
+        this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, isolatedFileSystem);
     },
 
     /**
@@ -178,7 +181,7 @@
             return null;
         if (!InspectorFrontendHost.isolatedFileSystem)
             return null;
-        return InspectorFrontendHost.isolatedFileSystem(fileSystem.fileSystemName, fileSystem.rootURL);
+        return InspectorFrontendHost.isolatedFileSystem(fileSystem.name(), fileSystem.rootURL());
     },
 
     /**
@@ -194,7 +197,9 @@
             return;
         }
         callback(this._isolatedFileSystem(fileSystemPath));
-    }
+    },
+
+    __proto__: WebInspector.Object.prototype
 }
 
 /**

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (143326 => 143327)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2013-02-19 14:43:09 UTC (rev 143326)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2013-02-19 14:59:38 UTC (rev 143327)
@@ -438,9 +438,10 @@
 
     this.workspaceController = new WebInspector.WorkspaceController(this.workspace);
 
-    this.isolatedFileSystemManager = new WebInspector.IsolatedFileSystemManager(this.workspace);
+    this.isolatedFileSystemManager = new WebInspector.IsolatedFileSystemManager();
     this.isolatedFileSystemDispatcher = new WebInspector.IsolatedFileSystemDispatcher(this.isolatedFileSystemManager);
     this.fileMapping = new WebInspector.FileMapping(this.isolatedFileSystemManager.mapping());
+    this.fileSystemWorkspaceProvider = new WebInspector.FileSystemWorkspaceProvider(this.isolatedFileSystemManager, this.workspace, this.fileMapping);
 
     this.networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(this.workspace, WebInspector.projectTypes.Network);
     new WebInspector.NetworkUISourceCodeProvider(this.networkWorkspaceProvider);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to