Changeset 89089 in webkit


Ignore:
Timestamp:
Jun 16, 2011 4:53:23 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-16 Bill Budge <bbudge@chromium.org>

Reviewed by Adam Barth.

The AssociatedURLLoader returns URL access errors synchronously. Use a timer to return such errors asynchronously. Also add unit tests for successful loads, same-origin restriction by default, and successful cross-origin loads.
https://bugs.webkit.org/show_bug.cgi?id=60059

  • WebKit.gyp:
  • WebKit.gypi:
  • src/AssociatedURLLoader.cpp: (WebKit::AssociatedURLLoader::ClientAdapter::clearClient): (WebKit::AssociatedURLLoader::ClientAdapter::ClientAdapter): (WebKit::AssociatedURLLoader::ClientAdapter::didFinishLoading): (WebKit::AssociatedURLLoader::ClientAdapter::didFail): (WebKit::AssociatedURLLoader::ClientAdapter::enableErrorNotifications): (WebKit::AssociatedURLLoader::ClientAdapter::notifyError): (WebKit::AssociatedURLLoader::loadAsynchronously):
  • tests/AssociatedURLLoaderTest.cpp: Added. (WebKit::TestWebFrameClient::cancelledError): (WebKit::AssociatedURLLoaderTest::AssociatedURLLoaderTest): (WebKit::AssociatedURLLoaderTest::SetUp): (WebKit::AssociatedURLLoaderTest::TearDown): (WebKit::AssociatedURLLoaderTest::serveRequests): (WebKit::AssociatedURLLoaderTest::createAssociatedURLLoader): (WebKit::AssociatedURLLoaderTest::willSendRequest): (WebKit::AssociatedURLLoaderTest::didSendData): (WebKit::AssociatedURLLoaderTest::didReceiveResponse): (WebKit::AssociatedURLLoaderTest::didDownloadData): (WebKit::AssociatedURLLoaderTest::didReceiveData): (WebKit::AssociatedURLLoaderTest::didReceiveCachedMetadata): (WebKit::AssociatedURLLoaderTest::didFinishLoading): (WebKit::AssociatedURLLoaderTest::didFail): (WebKit::TEST_F):
Location:
trunk/Source/WebKit/chromium
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r89065 r89089  
     12011-06-16  Bill Budge  <bbudge@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        The AssociatedURLLoader returns URL access errors synchronously. Use a timer to return such errors asynchronously. Also add unit tests for successful loads, same-origin restriction by default, and successful cross-origin loads.
     6        https://bugs.webkit.org/show_bug.cgi?id=60059
     7
     8        * WebKit.gyp:
     9        * WebKit.gypi:
     10        * src/AssociatedURLLoader.cpp:
     11        (WebKit::AssociatedURLLoader::ClientAdapter::clearClient):
     12        (WebKit::AssociatedURLLoader::ClientAdapter::ClientAdapter):
     13        (WebKit::AssociatedURLLoader::ClientAdapter::didFinishLoading):
     14        (WebKit::AssociatedURLLoader::ClientAdapter::didFail):
     15        (WebKit::AssociatedURLLoader::ClientAdapter::enableErrorNotifications):
     16        (WebKit::AssociatedURLLoader::ClientAdapter::notifyError):
     17        (WebKit::AssociatedURLLoader::loadAsynchronously):
     18        * tests/AssociatedURLLoaderTest.cpp: Added.
     19        (WebKit::TestWebFrameClient::cancelledError):
     20        (WebKit::AssociatedURLLoaderTest::AssociatedURLLoaderTest):
     21        (WebKit::AssociatedURLLoaderTest::SetUp):
     22        (WebKit::AssociatedURLLoaderTest::TearDown):
     23        (WebKit::AssociatedURLLoaderTest::serveRequests):
     24        (WebKit::AssociatedURLLoaderTest::createAssociatedURLLoader):
     25        (WebKit::AssociatedURLLoaderTest::willSendRequest):
     26        (WebKit::AssociatedURLLoaderTest::didSendData):
     27        (WebKit::AssociatedURLLoaderTest::didReceiveResponse):
     28        (WebKit::AssociatedURLLoaderTest::didDownloadData):
     29        (WebKit::AssociatedURLLoaderTest::didReceiveData):
     30        (WebKit::AssociatedURLLoaderTest::didReceiveCachedMetadata):
     31        (WebKit::AssociatedURLLoaderTest::didFinishLoading):
     32        (WebKit::AssociatedURLLoaderTest::didFail):
     33        (WebKit::TEST_F):
     34
    1352011-06-16  Sailesh Agrawal  <sail@chromium.org>
    236
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r89008 r89089  
    647647                                # These tests depend on webkit_support and
    648648                                # functions defined only in !WEBKIT_IMPLEMENTATION.
     649                                'tests/AssociatedURLLoaderTest.cpp',
    649650                                'tests/WebFrameTest.cpp',
    650651                                'tests/WebPageNewSerializerTest.cpp',
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r88523 r89089  
    5454        'webkit_unittest_files': [
    5555            'tests/ArenaTestHelpers.h',
     56            'tests/AssociatedURLLoaderTest.cpp',
    5657            'tests/InnerGestureRecognizerTest.cpp',
    5758            'tests/CCThreadTaskTest.cpp',
  • trunk/Source/WebKit/chromium/src/AssociatedURLLoader.cpp

    r89036 r89089  
    3535#include "DocumentThreadableLoaderClient.h"
    3636#include "SubresourceLoader.h"
     37#include "Timer.h"
    3738#include "WebApplicationCacheHost.h"
    3839#include "WebDataSource.h"
     
    5556// It forwards its ThreadableLoaderClient notifications to a WebURLLoaderClient.
    5657class AssociatedURLLoader::ClientAdapter : public DocumentThreadableLoaderClient {
     58    WTF_MAKE_NONCOPYABLE(ClientAdapter);
    5759public:
    5860    static PassOwnPtr<ClientAdapter> create(AssociatedURLLoader*, WebURLLoaderClient*, bool /*downloadToFile*/);
     
    6971    virtual bool isDocumentThreadableLoaderClient() { return true; }
    7072
    71     // This method stops loading and releases the DocumentThreadableLoader as early as possible.
    72     void clearClient() { m_client = 0; }
     73    // Enables forwarding of error notifications to the WebURLLoaderClient. These must be
     74    // deferred until after the call to AssociatedURLLoader::loadAsynchronously() completes.
     75    void enableErrorNotifications();
     76
     77    // Stops loading and releases the DocumentThreadableLoader as early as possible.
     78    void clearClient() { m_client = 0; }
    7379
    7480private:
    7581    ClientAdapter(AssociatedURLLoader*, WebURLLoaderClient*, bool /*downloadToFile*/);
    7682
     83    void notifyError(Timer<ClientAdapter>*);
     84
    7785    AssociatedURLLoader* m_loader;
    7886    WebURLLoaderClient* m_client;
     87    WebURLError m_error;
     88
     89    Timer<ClientAdapter> m_errorTimer;
    7990    unsigned long m_downloadLength;
    8091    bool m_downloadToFile;
     92    bool m_enableErrorNotifications;
     93    bool m_didFail;
    8194};
    8295
     
    89102    : m_loader(loader)
    90103    , m_client(client)
     104    , m_errorTimer(this, &ClientAdapter::notifyError)
    91105    , m_downloadLength(0)
    92106    , m_downloadToFile(downloadToFile)
     107    , m_enableErrorNotifications(false)
     108    , m_didFail(false)
    93109{
    94110    ASSERT(m_loader);
     
    145161        int downloadLength = m_downloadLength <= INT_MAX ? m_downloadLength : INT_MAX;
    146162        m_client->didDownloadData(m_loader, downloadLength);
    147         // While the client could have cancelled, continue, since the load finished.
     163        // While the client could have canceled, continue, since the load finished.
    148164    }
    149165
     
    156172        return;
    157173
    158     WebURLError webError(error);
    159     m_client->didFail(m_loader, webError);
     174    m_didFail = true;
     175    m_error = WebURLError(error);
     176    if (m_enableErrorNotifications)
     177        notifyError(&m_errorTimer);
     178}
     179
     180void AssociatedURLLoader::ClientAdapter::enableErrorNotifications()
     181{
     182    m_enableErrorNotifications = true;
     183    // If an error has already been received, start a timer to report it to the client
     184    // after AssociatedURLLoader::loadAsynchronously has returned to the caller.
     185    if (m_didFail)
     186        m_errorTimer.startOneShot(0);
     187}
     188
     189void AssociatedURLLoader::ClientAdapter::notifyError(Timer<ClientAdapter>* timer)
     190{
     191    ASSERT_UNUSED(timer, timer == &m_errorTimer);
     192
     193    m_client->didFail(m_loader, m_error);
    160194}
    161195
     
    216250    Document* webcoreDocument = m_frameImpl->frame()->document();
    217251    m_clientAdapter = ClientAdapter::create(this, m_client, request.downloadToFile());
    218 
    219252    m_loader = DocumentThreadableLoader::create(webcoreDocument, m_clientAdapter.get(), webcoreRequest, options);
     253    m_clientAdapter->enableErrorNotifications();
    220254}
    221255
Note: See TracChangeset for help on using the changeset viewer.