Changeset 145753 in webkit


Ignore:
Timestamp:
Mar 13, 2013, 2:36:29 PM (12 years ago)
Author:
beidson@apple.com
Message:

Small ResourceLoader cleanups.
https://bugs.webkit.org/show_bug.cgi?id=112279

Reviewed by Geoff Garen.

Source/WebCore:

No new tests (Refactor with no behavior change).

1 - Add "OVERRIDE" to virtual methods in subclasses of ResourceLoader to catch future mistakes.
2 - Replace the "bool allAtOnce" flag with a descriptive enum to make reading code easier.

  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::substituteResourceDeliveryTimerFired):

  • loader/NetscapePlugInStreamLoader.cpp:

(WebCore::NetscapePlugInStreamLoader::didReceiveData):

  • loader/NetscapePlugInStreamLoader.h:
  • loader/ResourceLoader.cpp:

(WebCore::ResourceLoader::addData):
(WebCore::ResourceLoader::didReceiveData):

  • loader/ResourceLoader.h:
  • loader/ResourceLoaderTypes.h: Added.
  • loader/SubresourceLoader.cpp:

(WebCore::SubresourceLoader::didReceiveData):

  • loader/SubresourceLoader.h:

Source/WebKit2:

Replace the "bool allAtOnce" flag with a descriptive enum to make reading code easier.

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::didReceiveData):

  • WebProcess/Network/WebResourceLoader.cpp:

(WebKit::WebResourceLoader::didReceiveData):
(WebKit::WebResourceLoader::didReceiveResource):

  • WebProcess/Network/WebResourceLoader.h:
  • WebProcess/Network/WebResourceLoader.messages.in: Get rid of the "allAtOnce" flag since it was always false.
Location:
trunk/Source
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r145752 r145753  
     12013-03-13  Brady Eidson  <beidson@apple.com>
     2
     3        Small ResourceLoader cleanups.
     4        https://bugs.webkit.org/show_bug.cgi?id=112279
     5
     6        Reviewed by Geoff Garen.
     7
     8        No new tests (Refactor with no behavior change).
     9
     10        1 - Add "OVERRIDE" to virtual methods in subclasses of ResourceLoader to catch future mistakes.
     11        2 - Replace the "bool allAtOnce" flag with a descriptive enum to make reading code easier.
     12
     13        * GNUmakefile.list.am:
     14        * Target.pri:
     15        * WebCore.gypi:
     16        * WebCore.vcproj/WebCore.vcproj:
     17        * WebCore.xcodeproj/project.pbxproj:
     18
     19        * loader/DocumentLoader.cpp:
     20        (WebCore::DocumentLoader::substituteResourceDeliveryTimerFired):
     21
     22        * loader/NetscapePlugInStreamLoader.cpp:
     23        (WebCore::NetscapePlugInStreamLoader::didReceiveData):
     24        * loader/NetscapePlugInStreamLoader.h:
     25
     26        * loader/ResourceLoader.cpp:
     27        (WebCore::ResourceLoader::addData):
     28        (WebCore::ResourceLoader::didReceiveData):
     29        * loader/ResourceLoader.h:
     30        * loader/ResourceLoaderTypes.h: Added.
     31
     32        * loader/SubresourceLoader.cpp:
     33        (WebCore::SubresourceLoader::didReceiveData):
     34        * loader/SubresourceLoader.h:
     35
    1362013-03-13  Nate Chapin  <japhet@chromium.org>
    237
  • trunk/Source/WebCore/GNUmakefile.list.am

    r145552 r145753  
    40864086        Source/WebCore/loader/ResourceLoader.h \
    40874087        Source/WebCore/loader/ResourceLoaderOptions.h \
     4088        Source/WebCore/loader/ResourceLoaderTypes.h \
    40884089        Source/WebCore/loader/ResourceLoadNotifier.cpp \
    40894090        Source/WebCore/loader/ResourceLoadNotifier.h \
  • trunk/Source/WebCore/Target.pri

    r145510 r145753  
    20882088    loader/ResourceBuffer.h \
    20892089    loader/ResourceLoader.h \
     2090    loader/ResourceLoaderTypes.h \
    20902091    loader/SubresourceLoader.h \
    20912092    loader/SubstituteData.h \
  • trunk/Source/WebCore/WebCore.gypi

    r145603 r145753  
    20942094            'loader/ResourceLoader.cpp',
    20952095            'loader/ResourceLoaderOptions.h',
     2096            'loader/ResourceLoaderTypes.h',
    20962097            'loader/SinkDocument.cpp',
    20972098            'loader/SinkDocument.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r145637 r145753  
    2808428084                        </File>
    2808528085                        <File
     28086                                RelativePath="..\loader\ResourceLoaderTypes.h"
     28087                                >
     28088                        </File>
     28089                        <File
    2808628090                                RelativePath="..\loader\ResourceLoadNotifier.cpp"
    2808728091                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r145592 r145753  
    16471647                51ABAE1F103C1913008C5260 /* SocketStreamHandleCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ABAE1D103C1913008C5260 /* SocketStreamHandleCFNet.cpp */; };
    16481648                51ABF64D16392E2800132A7A /* LoaderStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ABF64C16392E2800132A7A /* LoaderStrategy.cpp */; };
     1649                51AF503616F100F60095B2E8 /* ResourceLoaderTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
    16491650                51B2417B0D931F3F00E83F5C /* LegacyWebArchiveMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */; };
    16501651                51BE37E00DAEE00E001085FC /* StorageArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE37DE0DAEE00E001085FC /* StorageArea.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    91209121                51ABAE1D103C1913008C5260 /* SocketStreamHandleCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleCFNet.cpp; sourceTree = "<group>"; };
    91219122                51ABF64C16392E2800132A7A /* LoaderStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoaderStrategy.cpp; sourceTree = "<group>"; };
     9123                51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderTypes.h; sourceTree = "<group>"; };
    91229124                51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = "<group>"; };
    91239125                51BE37DE0DAEE00E001085FC /* StorageArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageArea.h; sourceTree = "<group>"; };
     
    2152321525                                93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */,
    2152421526                                656D37270ADBA5DE00A4554D /* ResourceLoader.h */,
     21527                                51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */,
    2152521528                                D0A3A7301405A39800FB8ED3 /* ResourceLoaderOptions.h */,
    2152621529                                973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */,
     
    2429924302                                854163980AC718680001E01B /* DOMSVGTransformInternal.h in Headers */,
    2430024303                                8541636B0AC7180B0001E01B /* DOMSVGTransformList.h in Headers */,
     24304                                51AF503616F100F60095B2E8 /* ResourceLoaderTypes.h in Headers */,
    2430124305                                854163970AC718680001E01B /* DOMSVGTransformListInternal.h in Headers */,
    2430224306                                859D62BA0AD888EF00012995 /* DOMSVGTRefElement.h in Headers */,
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r145752 r145753  
    782782                return;
    783783
    784             loader->didReceiveData(data->data(), data->size(), data->size(), true);
     784            loader->didReceiveData(data->data(), data->size(), data->size(), DataPayloadWholeResource);
    785785
    786786            // Calling ResourceLoader::didReceiveData can end up cancelling the load,
  • trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp

    r99104 r145753  
    9494}
    9595
    96 void NetscapePlugInStreamLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
     96void NetscapePlugInStreamLoader::didReceiveData(const char* data, int length, long long encodedDataLength, DataPayloadType dataPayloadType)
    9797{
    9898    RefPtr<NetscapePlugInStreamLoader> protect(this);
     
    100100    m_client->didReceiveData(this, data, length);
    101101   
    102     ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);
     102    ResourceLoader::didReceiveData(data, length, encodedDataLength, dataPayloadType);
    103103}
    104104
  • trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.h

    r131492 r145753  
    5757
    5858private:
    59     virtual void didReceiveResponse(const ResourceResponse&);
    60     virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce);
    61     virtual void didFinishLoading(double finishTime);
    62     virtual void didFail(const ResourceError&);
     59    virtual void didReceiveResponse(const ResourceResponse&) OVERRIDE;
     60    virtual void didReceiveData(const char*, int, long long encodedDataLength, DataPayloadType) OVERRIDE;
     61    virtual void didFinishLoading(double finishTime) OVERRIDE;
     62    virtual void didFail(const ResourceError&) OVERRIDE;
    6363
    64     virtual void releaseResources();
     64    virtual void releaseResources() OVERRIDE;
    6565
    6666    NetscapePlugInStreamLoader(Frame*, NetscapePlugInStreamLoaderClient*);
    6767
    68     virtual void willCancel(const ResourceError&);
    69     virtual void didCancel(const ResourceError&);
     68    virtual void willCancel(const ResourceError&) OVERRIDE;
     69    virtual void didCancel(const ResourceError&) OVERRIDE;
    7070
    7171    NetscapePlugInStreamLoaderClient* m_client;
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r144770 r145753  
    201201   
    202202
    203 void ResourceLoader::addData(const char* data, int length, bool allAtOnce)
     203void ResourceLoader::addData(const char* data, int length, DataPayloadType dataPayloadType)
    204204{
    205205    if (m_options.dataBufferingPolicy == DoNotBufferData)
    206206        return;
    207207
    208     if (allAtOnce) {
     208    if (dataPayloadType == DataPayloadWholeResource) {
    209209        m_resourceData = ResourceBuffer::create(data, length);
    210210        return;
     
    288288}
    289289
    290 void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
     290void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, DataPayloadType dataPayloadType)
    291291{
    292292    // The following assertions are not quite valid here, since a subclass
     
    300300    RefPtr<ResourceLoader> protector(this);
    301301
    302     addData(data, length, allAtOnce);
     302    addData(data, length, dataPayloadType);
    303303    // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
    304304    // However, with today's computers and networking speeds, this won't happen in practice.
     
    466466{
    467467    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), identifier(), encodedDataLength);
    468     didReceiveData(data, length, encodedDataLength, false);
     468    didReceiveData(data, length, encodedDataLength, DataPayloadBytes);
    469469    InspectorInstrumentation::didReceiveResourceData(cookie);
    470470}
  • trunk/Source/WebCore/loader/ResourceLoader.h

    r144770 r145753  
    3232#include "ResourceHandleClient.h"
    3333#include "ResourceLoaderOptions.h"
     34#include "ResourceLoaderTypes.h"
    3435#include "ResourceRequest.h"
    3536#include "ResourceResponse.h"
     
    7374    const ResourceResponse& response() const;
    7475
    75     virtual void addData(const char*, int, bool allAtOnce);
     76    virtual void addData(const char*, int, DataPayloadType);
    7677    virtual PassRefPtr<ResourceBuffer> resourceData();
    7778    void clearResourceData();
     
    8182    virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
    8283    virtual void didReceiveResponse(const ResourceResponse&);
    83     virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce);
     84    virtual void didReceiveData(const char*, int, long long encodedDataLength, DataPayloadType);
    8485    virtual void didReceiveCachedMetadata(const char*, int) { }
    8586    void willStopBufferingData(const char*, int);
  • trunk/Source/WebCore/loader/SubresourceLoader.cpp

    r145735 r145753  
    214214}
    215215
    216 void SubresourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
     216void SubresourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, DataPayloadType dataPayloadType)
    217217{
    218218    if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors())
     
    224224    // anything including removing the last reference to this object; one example of this is 3266216.
    225225    RefPtr<SubresourceLoader> protect(this);
    226     addData(data, length, allAtOnce);
     226    addData(data, length, dataPayloadType);
    227227    if (!m_loadingMultipartContent)
    228228        sendDataToResource(data, length);
  • trunk/Source/WebCore/loader/SubresourceLoader.h

    r133233 r145753  
    5656    virtual ~SubresourceLoader();
    5757
    58     virtual bool init(const ResourceRequest&);
     58    virtual bool init(const ResourceRequest&) OVERRIDE;
    5959
    60     virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
    61     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
    62     virtual void didReceiveResponse(const ResourceResponse&);
    63     virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce);
    64     virtual void didReceiveCachedMetadata(const char*, int);
    65     virtual void didFinishLoading(double finishTime);
    66     virtual void didFail(const ResourceError&);
    67     virtual void willCancel(const ResourceError&);
    68     virtual void didCancel(const ResourceError&) { }
     60    virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse) OVERRIDE;
     61    virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
     62    virtual void didReceiveResponse(const ResourceResponse&) OVERRIDE;
     63    virtual void didReceiveData(const char*, int, long long encodedDataLength, DataPayloadType) OVERRIDE;
     64    virtual void didReceiveCachedMetadata(const char*, int) OVERRIDE;
     65    virtual void didFinishLoading(double finishTime) OVERRIDE;
     66    virtual void didFail(const ResourceError&) OVERRIDE;
     67    virtual void willCancel(const ResourceError&) OVERRIDE;
     68    virtual void didCancel(const ResourceError&) OVERRIDE { }
    6969
    7070#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
    71     virtual bool supportsDataArray() { return true; }
    72     virtual void didReceiveDataArray(CFArrayRef);
     71    virtual bool supportsDataArray() OVERRIDE { return true; }
     72    virtual void didReceiveDataArray(CFArrayRef) OVERRIDE;
    7373#endif
    7474#if PLATFORM(CHROMIUM)
    75     virtual void didDownloadData(int);
     75    virtual void didDownloadData(int) OVERRIDE;
    7676#endif
    77     virtual void releaseResources();
     77    virtual void releaseResources() OVERRIDE;
    7878
    7979    bool checkForHTTPStatusCodeError();
  • trunk/Source/WebKit2/ChangeLog

    r145745 r145753  
     12013-03-13  Brady Eidson  <beidson@apple.com>
     2
     3        Small ResourceLoader cleanups.
     4        https://bugs.webkit.org/show_bug.cgi?id=112279
     5
     6        Reviewed by Geoff Garen.
     7
     8        Replace the "bool allAtOnce" flag with a descriptive enum to make reading code easier.
     9
     10        * NetworkProcess/NetworkResourceLoader.cpp:
     11        (WebKit::NetworkResourceLoader::didReceiveData):
     12
     13        * WebProcess/Network/WebResourceLoader.cpp:
     14        (WebKit::WebResourceLoader::didReceiveData):
     15        (WebKit::WebResourceLoader::didReceiveResource):
     16        * WebProcess/Network/WebResourceLoader.h:
     17        * WebProcess/Network/WebResourceLoader.messages.in: Get rid of the "allAtOnce" flag since it was always false.
     18
    1192013-03-13  Abhishek Arya  <inferno@chromium.org>
    220
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp

    r145485 r145753  
    206206   
    207207    CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(data), length);
    208     sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedDataLength, false));
     208    sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedDataLength));
    209209}
    210210
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp

    r141824 r145753  
    8888}
    8989
    90 void WebResourceLoader::didReceiveData(const CoreIPC::DataReference& data, int64_t encodedDataLength, bool allAtOnce)
     90void WebResourceLoader::didReceiveData(const CoreIPC::DataReference& data, int64_t encodedDataLength)
    9191{
    9292    LOG(Network, "(WebProcess) WebResourceLoader::didReceiveData of size %i for '%s'", (int)data.size(), m_coreLoader->url().string().utf8().data());
    93     m_coreLoader->didReceiveData(reinterpret_cast<const char*>(data.data()), data.size(), encodedDataLength, allAtOnce);
     93    m_coreLoader->didReceiveData(reinterpret_cast<const char*>(data.data()), data.size(), encodedDataLength, DataPayloadBytes);
    9494}
    9595
     
    118118        // That will allow us to pass it along to CachedResources and allow them to hang on to the shared memory behind the scenes.
    119119        // FIXME (NetworkProcess): Pass along the correct value for encodedDataLength.
    120         m_coreLoader->didReceiveData(reinterpret_cast<const char*>(resource->data()), resource->size(), -1 /* encodedDataLength */ , true);
     120        m_coreLoader->didReceiveData(reinterpret_cast<const char*>(resource->data()), resource->size(), -1 /* encodedDataLength */ , DataPayloadWholeResource);
    121121    }
    122122
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h

    r141824 r145753  
    7676    void willSendRequest(const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::ResourceRequest& newRequest);
    7777    void didReceiveResponseWithCertificateInfo(const WebCore::ResourceResponse&, const PlatformCertificateInfo&);
    78     void didReceiveData(const CoreIPC::DataReference&, int64_t encodedDataLength, bool allAtOnce);
     78    void didReceiveData(const CoreIPC::DataReference&, int64_t encodedDataLength);
    7979    void didFinishResourceLoad(double finishTime);
    8080    void didFailResourceLoad(const WebCore::ResourceError&);
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in

    r140921 r145753  
    2828    WillSendRequest(WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse) -> (WebCore::ResourceRequest newRequest)
    2929    DidReceiveResponseWithCertificateInfo(WebCore::ResourceResponse response, WebKit::PlatformCertificateInfo certificateInfo)
    30     DidReceiveData(CoreIPC::DataReference data, int64_t encodedDataLength, bool allAtOnce)
     30    DidReceiveData(CoreIPC::DataReference data, int64_t encodedDataLength)
    3131    DidFinishResourceLoad(double finishTime)
    3232    DidFailResourceLoad(WebCore::ResourceError error)
Note: See TracChangeset for help on using the changeset viewer.