Title: [142867] trunk
Revision
142867
Author
vse...@chromium.org
Date
2013-02-14 04:27:16 -0800 (Thu, 14 Feb 2013)

Log Message

Web Inspector: Remove uriForFile and fileForURI methods from FileSystemMapping.
https://bugs.webkit.org/show_bug.cgi?id=109704

Reviewed by Alexander Pavlov.

Source/WebCore:

Replaced this methods with one line implementation on the only call site.

* inspector/front-end/FileSystemMapping.js:
* inspector/front-end/FileSystemProjectDelegate.js:
(WebInspector.FileSystemProjectDelegate.prototype._filePathForURI):
(WebInspector.FileSystemProjectDelegate.prototype.setFileContent):
(WebInspector.FileSystemProjectDelegate.prototype._populate.filesLoaded):
(WebInspector.FileSystemProjectDelegate.prototype._populate):

LayoutTests:

* inspector/file-system-mapping-expected.txt:
* inspector/file-system-mapping.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142866 => 142867)


--- trunk/LayoutTests/ChangeLog	2013-02-14 12:09:18 UTC (rev 142866)
+++ trunk/LayoutTests/ChangeLog	2013-02-14 12:27:16 UTC (rev 142867)
@@ -1,3 +1,13 @@
+2013-02-14  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Remove uriForFile and fileForURI methods from FileSystemMapping.
+        https://bugs.webkit.org/show_bug.cgi?id=109704
+
+        Reviewed by Alexander Pavlov.
+
+        * inspector/file-system-mapping-expected.txt:
+        * inspector/file-system-mapping.html:
+
 2013-02-14  Anton Vayvod  <avay...@chromium.org>
 
         [Text Autosizing] Process narrow descendants with the same multiplier for the font size.

Modified: trunk/LayoutTests/inspector/file-system-mapping-expected.txt (142866 => 142867)


--- trunk/LayoutTests/inspector/file-system-mapping-expected.txt	2013-02-14 12:09:18 UTC (rev 142866)
+++ trunk/LayoutTests/inspector/file-system-mapping-expected.txt	2013-02-14 12:27:16 UTC (rev 142867)
@@ -1,136 +1,78 @@
 Tests FileSystemMapping
 
 Testing file system mapping.
-    file system pathes:
+    file system paths:
     uriPrefixForPathPrefix:
-    uriForFile:
-    fileForURI:
 
 Adding file system /home/username/projects/foo
 Testing file system mapping.
-    file system pathes:
+    file system paths:
      - /home/username/projects/foo(id = 0@foo)
     uriPrefixForPathPrefix:
         /home/username/projects/foo => 0@foo/
         /home/username/projects/foo => 0@foo/
-    uriForFile:
-        /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
-        /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
-    fileForURI:
-        /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
-        /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
 
 Adding file system /home/username/projects/bar
 Testing file system mapping.
-    file system pathes:
+    file system paths:
      - /home/username/projects/foo(id = 0@foo)
      - /home/username/projects/bar(id = 1@bar)
     uriPrefixForPathPrefix:
         /home/username/projects/foo => 0@foo/
+        /home/username/projects/bar => 1@bar/
         /home/username/projects/foo => 0@foo/
         /home/username/projects/bar => 1@bar/
-        /home/username/projects/bar => 1@bar/
-    uriForFile:
-        /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
-        /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
-        /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
-        /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
-    fileForURI:
-        /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
-        /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
-        /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
-        /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
 
 Adding file system /www/site1
 Testing file system mapping.
-    file system pathes:
+    file system paths:
      - /home/username/projects/foo(id = 0@foo)
      - /home/username/projects/bar(id = 1@bar)
      - /www/site1(id = 2@site1)
     uriPrefixForPathPrefix:
         /home/username/projects/foo => 0@foo/
+        /home/username/projects/bar => 1@bar/
+        /www/site1 => 2@site1/
         /home/username/projects/foo => 0@foo/
         /home/username/projects/bar => 1@bar/
-        /home/username/projects/bar => 1@bar/
         /www/site1 => 2@site1/
-    uriForFile:
-        /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
-        /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
-        /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
-        /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
-        /www/site1, /site1.txt => 2@site1/site1.txt
-    fileForURI:
-        /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
-        /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
-        /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
-        /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
-        /www/site1, 2@site1/site1.txt => /site1.txt
 
 Creating another file system mapping.
 Testing file system mapping.
-    file system pathes:
+    file system paths:
      - /home/username/projects/foo(id = 0@foo)
      - /home/username/projects/bar(id = 1@bar)
      - /www/site1(id = 2@site1)
     uriPrefixForPathPrefix:
         /home/username/projects/foo => 0@foo/
+        /home/username/projects/bar => 1@bar/
+        /www/site1 => 2@site1/
         /home/username/projects/foo => 0@foo/
         /home/username/projects/bar => 1@bar/
-        /home/username/projects/bar => 1@bar/
         /www/site1 => 2@site1/
-    uriForFile:
-        /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
-        /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
-        /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
-        /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
-        /www/site1, /site1.txt => 2@site1/site1.txt
-    fileForURI:
-        /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
-        /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
-        /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
-        /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
-        /www/site1, 2@site1/site1.txt => /site1.txt
 
 Removing file system /www/site1
 Testing file system mapping.
-    file system pathes:
+    file system paths:
      - /home/username/projects/foo(id = 0@foo)
      - /home/username/projects/bar(id = 1@bar)
     uriPrefixForPathPrefix:
         /home/username/projects/foo => 0@foo/
+        /home/username/projects/bar => 1@bar/
         /home/username/projects/foo => 0@foo/
         /home/username/projects/bar => 1@bar/
-        /home/username/projects/bar => 1@bar/
-    uriForFile:
-        /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
-        /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
-        /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
-        /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
-    fileForURI:
-        /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
-        /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
-        /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
-        /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
 
 Removing file system /home/username/projects/foo
 Testing file system mapping.
-    file system pathes:
+    file system paths:
      - /home/username/projects/bar(id = 1@bar)
     uriPrefixForPathPrefix:
         /home/username/projects/bar => 1@bar/
         /home/username/projects/bar => 1@bar/
-    uriForFile:
-        /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
-        /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
-    fileForURI:
-        /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
-        /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
 
 Removing file system /home/username/projects/bar
 Testing file system mapping.
-    file system pathes:
+    file system paths:
     uriPrefixForPathPrefix:
-    uriForFile:
-    fileForURI:
 
 

Modified: trunk/LayoutTests/inspector/file-system-mapping.html (142866 => 142867)


--- trunk/LayoutTests/inspector/file-system-mapping.html	2013-02-14 12:09:18 UTC (rev 142866)
+++ trunk/LayoutTests/inspector/file-system-mapping.html	2013-02-14 12:27:16 UTC (rev 142867)
@@ -4,16 +4,11 @@
 <script>
 function test()
 {
-    var pathes = {
+    var paths = {
         FOO: "/home/username/projects/foo",
         BAR: "/home/username/projects/bar",
         SITE1: "/www/site1"
     };
-    var files = [{fileSystemPath: pathes.FOO, filePath: "/foo.txt"},
-                 {fileSystemPath: pathes.FOO, filePath: "/src/foo.cpp"},
-                 {fileSystemPath: pathes.BAR, filePath: "/bar.txt"},
-                 {fileSystemPath: pathes.BAR, filePath: "/src/bar.cpp"},
-                 {fileSystemPath: pathes.SITE1, filePath: "/site1.txt"}];
 
     function addFileSystem(fileSystemMapping, path)
     {
@@ -31,36 +26,22 @@
     {
         var fileSystemPaths = fileSystemMapping.fileSystemPaths();
         InspectorTest.addResult("Testing file system mapping.");
-        InspectorTest.addResult("    file system pathes:");
+        InspectorTest.addResult("    file system paths:");
         for (var i = 0; i < fileSystemPaths.length; ++i) {
             var id = fileSystemMapping.fileSystemId(fileSystemPaths[i]);
             InspectorTest.addResult("     - " + fileSystemPaths[i] + "(id = " + id + ")");
         }
         InspectorTest.addResult("    uriPrefixForPathPrefix:");
-        for (var i = 0; i < files.length; ++i) {
-            var pathPrefix = files[i].fileSystemPath;
-            var uriPrefix = fileSystemMapping.uriPrefixForPathPrefix(pathPrefix + "/");
-            if (!uriPrefix)
-                continue;
-            InspectorTest.addResult("        " + pathPrefix + " => " + uriPrefix);
+        // Call uriPrefixForPathPrefix twice for each path prefix to check caching.
+        for (var i = 0; i < 2; ++i) {
+            for (pathId in paths) {
+                var pathPrefix = paths[pathId];
+                var uriPrefix = fileSystemMapping.uriPrefixForPathPrefix(pathPrefix + "/");
+                if (!uriPrefix)
+                    continue;
+                InspectorTest.addResult("        " + pathPrefix + " => " + uriPrefix);
+            }
         }
-
-        var uris = [];
-        InspectorTest.addResult("    uriForFile:");
-        for (var i = 0; i < files.length; ++i) {
-            var uri = fileSystemMapping.uriForFile(files[i].fileSystemPath, files[i].filePath);
-            uris.push(uri);
-            if (!uri)
-                continue;
-            InspectorTest.addResult("        " + files[i].fileSystemPath + ", " + files[i].filePath + " => " + uri);
-        }
-        InspectorTest.addResult("    fileForURI:");
-        for (var i = 0; i < files.length; ++i) {
-            if (!uris[i])
-                continue;
-            var filePath = fileSystemMapping.fileForURI(files[i].fileSystemPath, uris[i]);
-            InspectorTest.addResult("        " + files[i].fileSystemPath + ", " + uris[i] + " => " + filePath);
-        }
         InspectorTest.addResult("");
     }
 
@@ -72,11 +53,11 @@
     
     // Now fill it with file systems and test.
     checkAndDumpFileSystemMapping(fileSystemMapping);
-    addFileSystem(fileSystemMapping, pathes.FOO)
+    addFileSystem(fileSystemMapping, paths.FOO)
     checkAndDumpFileSystemMapping(fileSystemMapping);
-    addFileSystem(fileSystemMapping, pathes.BAR)
+    addFileSystem(fileSystemMapping, paths.BAR)
     checkAndDumpFileSystemMapping(fileSystemMapping);
-    addFileSystem(fileSystemMapping, pathes.SITE1)
+    addFileSystem(fileSystemMapping, paths.SITE1)
     checkAndDumpFileSystemMapping(fileSystemMapping);
 
     // Then create another file mapping to make sure it is correctly restored from the settings.
@@ -85,11 +66,11 @@
     checkAndDumpFileSystemMapping(fileSystemMapping);
 
     // Now remove file systems and test.
-    removeFileSystem(fileSystemMapping, pathes.SITE1)
+    removeFileSystem(fileSystemMapping, paths.SITE1)
     checkAndDumpFileSystemMapping(fileSystemMapping);
-    removeFileSystem(fileSystemMapping, pathes.FOO)
+    removeFileSystem(fileSystemMapping, paths.FOO)
     checkAndDumpFileSystemMapping(fileSystemMapping);
-    removeFileSystem(fileSystemMapping, pathes.BAR)
+    removeFileSystem(fileSystemMapping, paths.BAR)
     checkAndDumpFileSystemMapping(fileSystemMapping);
 
     InspectorTest.completeTest();

Modified: trunk/Source/WebCore/ChangeLog (142866 => 142867)


--- trunk/Source/WebCore/ChangeLog	2013-02-14 12:09:18 UTC (rev 142866)
+++ trunk/Source/WebCore/ChangeLog	2013-02-14 12:27:16 UTC (rev 142867)
@@ -1,3 +1,19 @@
+2013-02-14  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Remove uriForFile and fileForURI methods from FileSystemMapping.
+        https://bugs.webkit.org/show_bug.cgi?id=109704
+
+        Reviewed by Alexander Pavlov.
+
+        Replaced this methods with one line implementation on the only call site.
+
+        * inspector/front-end/FileSystemMapping.js:
+        * inspector/front-end/FileSystemProjectDelegate.js:
+        (WebInspector.FileSystemProjectDelegate.prototype._filePathForURI):
+        (WebInspector.FileSystemProjectDelegate.prototype.setFileContent):
+        (WebInspector.FileSystemProjectDelegate.prototype._populate.filesLoaded):
+        (WebInspector.FileSystemProjectDelegate.prototype._populate):
+
 2013-02-14  Anton Vayvod  <avay...@chromium.org>
 
         [Text Autosizing] Process narrow descendants with the same multiplier for the font size.

Modified: trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js (142866 => 142867)


--- trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js	2013-02-14 12:09:18 UTC (rev 142866)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js	2013-02-14 12:27:16 UTC (rev 142867)
@@ -40,20 +40,6 @@
     fileSystemPaths: function() { },
 
     /**
-     * @param {string} fileSystemPath
-     * @param {string} uri
-     * @return {?string}
-     */
-    fileForURI: function(fileSystemPath, uri) { },
-
-    /**
-     * @param {string} fileSystemPath
-     * @param {string} filePath
-     * @return {?string}
-     */
-    uriForFile: function(fileSystemPath, filePath) { },
-
-    /**
      * @param {string} pathPrefix
      * @return {?string}
      */
@@ -161,35 +147,6 @@
     },
 
     /**
-     * @param {string} fileSystemPath
-     * @param {string} uri
-     * @return {?string}
-     */
-    fileForURI: function(fileSystemPath, uri)
-    {
-        var indexOfSlash = uri.indexOf("/");
-        var uriId = uri.substr(0, indexOfSlash);
-        var id = this._fileSystemIds[fileSystemPath]
-        if (!uriId || uriId !== id)
-            return null;
-        var filePath = uri.substr(indexOfSlash);
-        return filePath;
-    },
-
-    /**
-     * @param {string} fileSystemPath
-     * @param {string} filePath
-     * @return {?string}
-     */
-    uriForFile: function(fileSystemPath, filePath)
-    {
-        var id = this._fileSystemIds[fileSystemPath];
-        if (!id)
-            return null;
-        return id + filePath;
-    },
-    
-    /**
      * @param {string} pathPrefix
      * @return {?string}
      */

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


--- trunk/Source/WebCore/inspector/front-end/FileSystemProjectDelegate.js	2013-02-14 12:09:18 UTC (rev 142866)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemProjectDelegate.js	2013-02-14 12:27:16 UTC (rev 142867)
@@ -74,16 +74,20 @@
 
     /**
      * @param {string} uri
+     * @return {string}
+     */
+    _filePathForURI: function(uri)
+    {
+        return uri.substr(uri.indexOf("/") + 1);
+    },
+
+    /**
+     * @param {string} uri
      * @param {function(?string,boolean,string)} callback
      */
     requestFileContent: function(uri, callback)
     {
-        var filePath = this._isolatedFileSystemModel.mapping().fileForURI(this._fileSystemPath, uri);
-        if (!filePath) {
-            console.error("No matching file for uri: " + uri);
-            callback(null, false, WebInspector.resourceTypes.Other.canonicalMimeType());
-            return;
-        }
+        var filePath = this._filePathForURI(uri);
         WebInspector.FileSystemUtils.requestFileContent(this._isolatedFileSystemModel, this._fileSystemPath, filePath, innerCallback.bind(this));
         
         /**
@@ -103,12 +107,7 @@
      */
     setFileContent: function(uri, newContent, callback)
     {
-        var filePath = this._isolatedFileSystemModel.mapping().fileForURI(this._fileSystemPath, uri);
-        if (!filePath) {
-            console.error("No matching file for uri: " + uri);
-            callback("");
-            return;
-        }
+        var filePath = this._filePathForURI(uri);
         WebInspector.FileSystemUtils.setFileContent(this._isolatedFileSystemModel, this._fileSystemPath, filePath, newContent, callback.bind(this, ""));
     },
 
@@ -166,7 +165,7 @@
         function filesLoaded(files)
         {
             for (var i = 0; i < files.length; ++i) {
-                var uri = this._isolatedFileSystemModel.mapping().uriForFile(this._fileSystemPath, files[i]);
+                var uri = this.id() + files[i];
                 var contentType = this._contentTypeForPath(files[i]);
                 var url = ""
                 var fileDescriptor = new WebInspector.FileDescriptor(uri, "file://" + this._fileSystemPath + files[i], url, contentType, true);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to