Changeset 76690 in webkit


Ignore:
Timestamp:
Jan 26, 2011 8:06:28 AM (13 years ago)
Author:
caseq@chromium.org
Message:

2011-01-26 Andrey Kosyakov <caseq@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: summary bar is not resized properly with the rest of network panel

  • inspector/InspectorResourceAgent.cpp: (WebCore::InspectorResourceAgent::didReceiveResponse):
  • inspector/front-end/Resource.js: (WebInspector.Resource): (WebInspector.Resource.prototype.get transferSize): (WebInspector.Resource.prototype.set responseHeaders): (WebInspector.Resource.prototype._headersSize): (WebInspector.Resource.prototype._mimeTypeIsConsistentWithType):
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76689 r76690  
     12011-01-26  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: summary bar is not resized properly with the rest of network panel
     6        - Set the size for 304/not modified resources from cached resource.
     7        - Add response headers size to resource transfer size.
     8        https://bugs.webkit.org/show_bug.cgi?id=52886
     9
     10        * inspector/InspectorResourceAgent.cpp:
     11        (WebCore::InspectorResourceAgent::didReceiveResponse):
     12        * inspector/front-end/Resource.js:
     13        (WebInspector.Resource):
     14        (WebInspector.Resource.prototype.get transferSize):
     15        (WebInspector.Resource.prototype.set responseHeaders):
     16        (WebInspector.Resource.prototype._headersSize):
     17        (WebInspector.Resource.prototype._mimeTypeIsConsistentWithType):
     18
    1192011-01-26  Carol Szabo  <carol.szabo@nokia.com>
    220
  • trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp

    r76472 r76690  
    317317    RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response);
    318318    String type = "Other";
     319    long cachedResourceSize = 0;
     320
    319321    if (loader) {
     322        CachedResource* cachedResource = InspectorResourceAgent::cachedResource(loader->frame(), response.url());
     323        if (cachedResource) {
     324            type = cachedResourceTypeString(*cachedResource);
     325            cachedResourceSize = cachedResource->encodedSize();
     326            // Use mime type from cached resource in case the one in response is empty.
     327            if (response.mimeType().isEmpty())
     328                resourceResponse->setString("mimeType", cachedResource->response().mimeType());
     329        }
    320330        if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->iconURL()))
    321331            type = "Image";
    322         else {
    323             CachedResource* cachedResource = InspectorResourceAgent::cachedResource(loader->frame(), response.url());
    324             if (cachedResource)
    325                 type = cachedResourceTypeString(*cachedResource);
    326 
    327             if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == "Other")
    328                 type = "Document";
    329 
    330             // Use mime type from cached resource in case the one in response is empty.
    331             if (response.mimeType().isEmpty() && cachedResource)
    332                 resourceResponse->setString("mimeType", cachedResource->response().mimeType());
    333         }
     332        else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == "Other")
     333            type = "Document";
    334334    }
    335335    m_frontend->didReceiveResponse(identifier, currentTime(), type, resourceResponse);
     336    // If we revalidated the resource and got Not modified, send content length following didReceiveResponse
     337    // as there will be no calls to didReceiveContentLength from the network stack.
     338    if (cachedResourceSize && response.httpStatusCode() == 304)
     339        didReceiveContentLength(identifier, cachedResourceSize);
    336340}
    337341
  • trunk/Source/WebCore/inspector/front-end/Resource.js

    r76519 r76690  
    3535    this._category = WebInspector.resourceCategories.other;
    3636    this._pendingContentCallbacks = [];
     37    this._responseHeadersSize = 0;
    3738}
    3839
     
    238239    get transferSize()
    239240    {
    240         // FIXME: this is wrong for chunked-encoding resources.
    241         return this.cached ? 0 : Number(this.responseHeaders["Content-Length"] || this.resourceSize || 0);
     241        if (this.cached)
     242            return 0;
     243        if (this.statusCode === 304) // Not modified
     244            return this._responseHeadersSize;
     245        // FIXME: We prefer using Content-Length over resourceSize as
     246        // resourceSize may differ from actual transfer size if platform's
     247        // network stack performed decoding (e.g. gzip decompression).
     248        // The Content-Length, though, is expected to come from raw
     249        // response headers and will reflect actual transfer length.
     250        // This won't work for chunked content encoding, so fall back to
     251        // resourceSize when we don't have Content-Length. This still won't
     252        // work for chunks with non-trivial encodings. We need a way to
     253        // get actaul transfer size from the network stack.
     254        var bodySize = Number(this.responseHeaders["Content-Length"] || this.resourceSize);
     255        return this._responseHeadersSize + bodySize;
    242256    },
    243257
     
    304318    },
    305319
    306 
    307320    get timing()
    308321    {
     
    432445    {
    433446        this._responseHeaders = x;
     447        // FIXME: we should take actual headers size from network stack, when possible.
     448        this._responseHeadersSize = this._headersSize(x);
    434449        delete this._sortedResponseHeaders;
    435450        delete this._responseCookies;
     
    513528    },
    514529
     530    _headersSize: function(headers)
     531    {
     532        var size = 0;
     533        for (var header in headers)
     534            size += header.length + headers[header].length + 3; // _typical_ overhead per herader is ": ".length + "\n".length.
     535        return size;
     536    },
     537
    515538    get errors()
    516539    {
     
    551574
    552575        if (typeof this.type === "undefined"
    553          || this.type === WebInspector.Resource.Type.Other
    554          || this.type === WebInspector.Resource.Type.XHR
    555          || this.type === WebInspector.Resource.Type.WebSocket)
     576            || this.type === WebInspector.Resource.Type.Other
     577            || this.type === WebInspector.Resource.Type.XHR
     578            || this.type === WebInspector.Resource.Type.WebSocket)
    556579            return true;
    557580
Note: See TracChangeset for help on using the changeset viewer.