Web Inspector: [Network] Refine JSDocs in NetworkRequest.js
authoreustas@chromium.org <eustas@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2013 18:47:18 +0000 (18:47 +0000)
committereustas@chromium.org <eustas@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2013 18:47:18 +0000 (18:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112412

Reviewed by Vsevolod Vlasov.

Return types for some members are confusing (Object).

* inspector/front-end/NetworkManager.js: Fixed JSDocs.
* inspector/front-end/NetworkRequest.js: Ditto. Plus minor refactorings.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@145926 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/NetworkManager.js
Source/WebCore/inspector/front-end/NetworkRequest.js

index bf20169..349547a 100644 (file)
@@ -1,3 +1,15 @@
+2013-03-15  Eugene Klyuchnikov  <eustas@chromium.org>
+
+        Web Inspector: [Network] Refine JSDocs in NetworkRequest.js
+        https://bugs.webkit.org/show_bug.cgi?id=112412
+
+        Reviewed by Vsevolod Vlasov.
+
+        Return types for some members are confusing (Object).
+
+        * inspector/front-end/NetworkManager.js: Fixed JSDocs.
+        * inspector/front-end/NetworkRequest.js: Ditto. Plus minor refactorings.
+
 2013-03-15  Andy Estes  <aestes@apple.com>
 
         REGRESSION (r127277): CSS URIs with multi-byte Unicode escape sequences fail to parse
index 47d8bcc..7fdbc95 100644 (file)
@@ -125,7 +125,7 @@ WebInspector.NetworkDispatcher = function(manager)
 WebInspector.NetworkDispatcher.prototype = {
     /**
      * @param {NetworkAgent.Headers} headersMap
-     * @return {Array.<Object>}
+     * @return {!Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     _headersMapToHeadersArray: function(headersMap)
     {
@@ -133,7 +133,7 @@ WebInspector.NetworkDispatcher.prototype = {
         for (var name in headersMap) {
             var values = headersMap[name].split("\n");
             for (var i = 0; i < values.length; ++i)
-                result.push({ name: name, value: values[i] });
+                result.push({name: name, value: values[i]});
         }
         return result;
     },
index 123e2e6..98b1cef 100644 (file)
@@ -73,6 +73,9 @@ WebInspector.NetworkRequest.InitiatorType = {
     Other: "other",
 }
 
+/** @typedef {{name: string, value: string}} */
+WebInspector.NetworkRequest.NameValue;
+
 WebInspector.NetworkRequest.prototype = {
     /**
      * @return {NetworkAgent.RequestId}
@@ -453,7 +456,7 @@ WebInspector.NetworkRequest.prototype = {
     },
 
     /**
-     * @return {Array.<Object>}
+     * @return {!Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     get requestHeaders()
     {
@@ -498,7 +501,7 @@ WebInspector.NetworkRequest.prototype = {
     },
 
     /**
-     * @return {Array.<Object>}
+     * @return {!Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     get sortedRequestHeaders()
     {
@@ -555,7 +558,7 @@ WebInspector.NetworkRequest.prototype = {
     },
 
     /**
-     * @return {Array.<Object>}
+     * @return {!Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     get responseHeaders()
     {
@@ -600,16 +603,16 @@ WebInspector.NetworkRequest.prototype = {
     },
 
     /**
-     * @return {Array.<Object>}
+     * @return {!Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     get sortedResponseHeaders()
     {
         if (this._sortedResponseHeaders !== undefined)
             return this._sortedResponseHeaders;
-        
+
         this._sortedResponseHeaders = [];
         this._sortedResponseHeaders = this.responseHeaders.slice();
-        this._sortedResponseHeaders.sort(function(a,b) { return a.name.toLowerCase().compareTo(b.name.toLowerCase()) });
+        this._sortedResponseHeaders.sort(function(a, b) { return a.name.toLowerCase().compareTo(b.name.toLowerCase()); });
         return this._sortedResponseHeaders;
     },
 
@@ -647,7 +650,7 @@ WebInspector.NetworkRequest.prototype = {
     },
 
     /**
-     * @return {?Array.<Object>}
+     * @return {?Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     get queryParameters()
     {
@@ -661,7 +664,7 @@ WebInspector.NetworkRequest.prototype = {
     },
 
     /**
-     * @return {?Array.<Object>}
+     * @return {?Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     get formParameters()
     {
@@ -687,34 +690,27 @@ WebInspector.NetworkRequest.prototype = {
 
     /**
      * @param {string} queryString
-     * @return {Array.<Object>}
+     * @return {!Array.<!WebInspector.NetworkRequest.NameValue>}
      */
     _parseParameters: function(queryString)
     {
         function parseNameValue(pair)
         {
-            var parameter = {};
             var splitPair = pair.split("=", 2);
-
-            parameter.name = splitPair[0];
-            if (splitPair.length === 1)
-                parameter.value = "";
-            else
-                parameter.value = splitPair[1];
-            return parameter;
+            return {name: splitPair[0], value: splitPair[1] || ""};
         }
         return queryString.split("&").map(parseNameValue);
     },
 
     /**
-     * @param {Object} headers
+     * @param {!Array.<!WebInspector.NetworkRequest.NameValue>} headers
      * @param {string} headerName
      * @return {string|undefined}
      */
     _headerValue: function(headers, headerName)
     {
         headerName = headerName.toLowerCase();
-        
+
         var values = [];
         for (var i = 0; i < headers.length; ++i) {
             if (headers[i].name.toLowerCase() === headerName)
@@ -879,7 +875,7 @@ WebInspector.NetworkRequest.prototype = {
     },
 
     /**
-     * @return {Object}
+     * @return {!Array.<!Object>}
      */
     frames: function()
     {
@@ -888,7 +884,7 @@ WebInspector.NetworkRequest.prototype = {
 
     /**
      * @param {number} position
-     * @return {Object}
+     * @return {Object|undefined}
      */
     frame: function(position)
     {
@@ -901,14 +897,11 @@ WebInspector.NetworkRequest.prototype = {
      */
     addFrameError: function(errorMessage, time)
     {
-        var errorObject = {};
-        errorObject.errorMessage = errorMessage;
-        errorObject.time = time;
-        this._pushFrame(errorObject);
+        this._pushFrame({errorMessage: errorMessage, time: time});
     },
 
     /**
-     * @param {Object} response
+     * @param {!NetworkAgent.WebSocketFrame} response
      * @param {number} time
      * @param {boolean} sent
      */
@@ -916,16 +909,18 @@ WebInspector.NetworkRequest.prototype = {
     {
         response.time = time;
         if (sent)
-            response.sent = true;
+            response.sent = sent;
         this._pushFrame(response);
     },
 
-    _pushFrame: function(object)
+    /**
+     * @param {!Object} frameOrError
+     */
+    _pushFrame: function(frameOrError)
     {
-        if (this._frames.length >= 100) {
+        if (this._frames.length >= 100)
             this._frames.splice(0, 10);
-        }
-        this._frames.push(object);
+        this._frames.push(frameOrError);
     },
 
     __proto__: WebInspector.Object.prototype