Title: [121017] trunk/Source/WebCore
Revision
121017
Author
[email protected]
Date
2012-06-22 05:35:55 -0700 (Fri, 22 Jun 2012)

Log Message

Web Inspector: Add frontend-side Entry object to FileSystemModel
https://bugs.webkit.org/show_bug.cgi?id=89739

Patch by Taiju Tsuiki <[email protected]> on 2012-06-22
Reviewed by Vsevolod Vlasov.

* inspector/front-end/FileSystemModel.js:
(WebInspector.FileSystemModel.prototype._fileSystemRootReceived):
(WebInspector.FileSystemModel.prototype.requestDirectoryContent):
(WebInspector.FileSystemModel.prototype._directoryContentReceived):
(WebInspector.FileSystemModel.FileSystem):
(WebInspector.FileSystemModel.Entry):
(WebInspector.FileSystemModel.Entry.prototype.get fileSystemModel):
(WebInspector.FileSystemModel.Entry.prototype.get fileSystem):
(WebInspector.FileSystemModel.Entry.prototype.get url):
(WebInspector.FileSystemModel.Entry.prototype.get name):
(WebInspector.FileSystemModel.Entry.prototype.get isDirectory):
(WebInspector.FileSystemModel.Directory):
(WebInspector.FileSystemModel.Directory.prototype.requestDirectoryContent):
(WebInspector.FileSystemModel.File):
(WebInspector.FileSystemModel.File.prototype.get mimeType):
(WebInspector.FileSystemModel.File.prototype.get resourceType):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121016 => 121017)


--- trunk/Source/WebCore/ChangeLog	2012-06-22 11:32:42 UTC (rev 121016)
+++ trunk/Source/WebCore/ChangeLog	2012-06-22 12:35:55 UTC (rev 121017)
@@ -1,3 +1,27 @@
+2012-06-22  Taiju Tsuiki  <[email protected]>
+
+        Web Inspector: Add frontend-side Entry object to FileSystemModel
+        https://bugs.webkit.org/show_bug.cgi?id=89739
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/FileSystemModel.js:
+        (WebInspector.FileSystemModel.prototype._fileSystemRootReceived):
+        (WebInspector.FileSystemModel.prototype.requestDirectoryContent):
+        (WebInspector.FileSystemModel.prototype._directoryContentReceived):
+        (WebInspector.FileSystemModel.FileSystem):
+        (WebInspector.FileSystemModel.Entry):
+        (WebInspector.FileSystemModel.Entry.prototype.get fileSystemModel):
+        (WebInspector.FileSystemModel.Entry.prototype.get fileSystem):
+        (WebInspector.FileSystemModel.Entry.prototype.get url):
+        (WebInspector.FileSystemModel.Entry.prototype.get name):
+        (WebInspector.FileSystemModel.Entry.prototype.get isDirectory):
+        (WebInspector.FileSystemModel.Directory):
+        (WebInspector.FileSystemModel.Directory.prototype.requestDirectoryContent):
+        (WebInspector.FileSystemModel.File):
+        (WebInspector.FileSystemModel.File.prototype.get mimeType):
+        (WebInspector.FileSystemModel.File.prototype.get resourceType):
+
 2012-06-22  Amy Ousterhout  <[email protected]>
 
         Renamed DeviceOrientation to DeviceOrientationData

Modified: trunk/Source/WebCore/inspector/front-end/FileSystemModel.js (121016 => 121017)


--- trunk/Source/WebCore/inspector/front-end/FileSystemModel.js	2012-06-22 11:32:42 UTC (rev 121016)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemModel.js	2012-06-22 12:35:55 UTC (rev 121017)
@@ -202,6 +202,39 @@
             store[type] = fileSystem;
             this._fileSystemAdded(fileSystem);
         }
+    },
+
+    /**
+     * @param {WebInspector.FileSystemModel.Directory} directory
+     * @param {function(number, Array.<WebInspector.FileSystemModel.Entry>=)} callback
+     */
+    requestDirectoryContent: function(directory, callback)
+    {
+        this._agentWrapper.requestDirectoryContent(directory.url, this._directoryContentReceived.bind(this, directory, callback));
+    },
+
+    /**
+     * @param {WebInspector.FileSystemModel.Directory} parentDirectory
+     * @param {function(number, Array.<WebInspector.FileSystemModel.Entry>=)} callback
+     * @param {number} errorCode
+     * @param {Array.<FileSystemAgent.Entry>=} backendEntries
+     */
+    _directoryContentReceived: function(parentDirectory, callback, errorCode, backendEntries)
+    {
+        if (errorCode !== 0) {
+            callback(errorCode, null);
+            return;
+        }
+
+        var entries = [];
+        for (var i = 0; i < backendEntries.length; ++i) {
+            if (backendEntries[i].isDirectory)
+                entries.push(new WebInspector.FileSystemModel.Directory(this, parentDirectory.fileSystem, backendEntries[i]));
+            else
+                entries.push(new WebInspector.FileSystemModel.File(this, parentDirectory.fileSystem, backendEntries[i]));
+        }
+
+        callback(errorCode, entries);
     }
 }
 
@@ -223,9 +256,14 @@
 {
     this.origin = origin;
     this.type = type;
+
+    this.root = new WebInspector.FileSystemModel.Directory(fileSystemModel, this, backendRootEntry);
 }
 
 WebInspector.FileSystemModel.FileSystem.prototype = {
+    /**
+     * @type {string}
+     */
     get name()
     {
         return "filesystem:" + this.origin + "/" + this.type;
@@ -234,7 +272,124 @@
 
 /**
  * @constructor
+ * @param {WebInspector.FileSystemModel} fileSystemModel
+ * @param {WebInspector.FileSystemModel.FileSystem} fileSystem
+ * @param {FileSystemAgent.Entry} backendEntry
  */
+WebInspector.FileSystemModel.Entry = function(fileSystemModel, fileSystem, backendEntry)
+{
+    this._fileSystemModel = fileSystemModel;
+    this._fileSystem = fileSystem;
+
+    this._url = backendEntry.url;
+    this._name = backendEntry.name;
+    this._isDirectory = backendEntry.isDirectory;
+}
+
+WebInspector.FileSystemModel.Entry.prototype = {
+    /**
+     * @type {WebInspector.FileSystemModel}
+     */
+    get fileSystemModel()
+    {
+        return this._fileSystemModel;
+    },
+
+    /**
+     * @type {WebInspector.FileSystemModel.FileSystem}
+     */
+    get fileSystem()
+    {
+        return this._fileSystem;
+    },
+
+    /**
+     * @type {string}
+     */
+    get url()
+    {
+        return this._url;
+    },
+
+    /**
+     * @type {string}
+     */
+    get name()
+    {
+        return this._name;
+    },
+
+    /**
+     * @type {boolean}
+     */
+    get isDirectory()
+    {
+        return this._isDirectory;
+    }
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.FileSystemModel.Entry}
+ * @param {WebInspector.FileSystemModel} fileSystemModel
+ * @param {WebInspector.FileSystemModel.FileSystem} fileSystem
+ * @param {FileSystemAgent.Entry} backendEntry
+ */
+WebInspector.FileSystemModel.Directory = function(fileSystemModel, fileSystem, backendEntry)
+{
+    WebInspector.FileSystemModel.Entry.call(this, fileSystemModel, fileSystem, backendEntry);
+}
+
+WebInspector.FileSystemModel.Directory.prototype = {
+    /**
+     * @param {function(number, Array.<WebInspector.FileSystemModel.Directory>)} callback
+     */
+    requestDirectoryContent: function(callback)
+    {
+        this.fileSystemModel.requestDirectoryContent(this, callback);
+    }
+}
+
+WebInspector.FileSystemModel.Directory.prototype.__proto__ = WebInspector.FileSystemModel.Entry.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.FileSystemModel.Entry}
+ * @param {WebInspector.FileSystemModel} fileSystemModel
+ * @param {WebInspector.FileSystemModel.FileSystem} fileSystem
+ * @param {FileSystemAgent.Entry} backendEntry
+ */
+WebInspector.FileSystemModel.File = function(fileSystemModel, fileSystem, backendEntry)
+{
+    WebInspector.FileSystemModel.Entry.call(this, fileSystemModel, fileSystem, backendEntry);
+
+    this._mimeType = backendEntry.mimeType;
+    this._resourceType = WebInspector.resourceTypes[backendEntry.resourceType];
+}
+
+WebInspector.FileSystemModel.File.prototype = {
+    /**
+     * @type {string}
+     */
+    get mimeType()
+    {
+        return this._mimeType;
+    },
+
+    /**
+     * @type {WebInspector.ResourceType}
+     */
+    get resourceType()
+    {
+        return this._resourceType;
+    }
+}
+
+WebInspector.FileSystemModel.File.prototype.__proto__ = WebInspector.FileSystemModel.Entry.prototype;
+
+/**
+ * @constructor
+ */
 WebInspector.FileSystemRequestManager = function()
 {
     this._pendingFileSystemRootRequests = {};
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to