Changeset 150609 in webkit


Ignore:
Timestamp:
May 23, 2013 1:08:21 PM (11 years ago)
Author:
andersca@apple.com
Message:

Crash in convertMainResourceLoadToDownload when downloading file by option-return
https://bugs.webkit.org/show_bug.cgi?id=116451

Reviewed by Andreas Kling.

Source/WebCore:

Handle MainResourceLoader being null here which will happen when loading a cached main resource.

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::continueAfterContentPolicy):

Source/WebKit/mac:

If the main resource loader is null, create a new download instead since there's no existing loader to convert.

  • WebCoreSupport/WebFrameLoaderClient.mm:

(WebFrameLoaderClient::convertMainResourceLoadToDownload):

Source/WebKit2:

If the main resource loader is null, create a new download instead since there's no existing loader to convert.

  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::convertMainResourceLoadToDownload):

  • WebProcess/WebPage/WebFrame.cpp:

(WebKit::WebFrame::convertMainResourceLoadToDownload):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150606 r150609  
     12013-05-23  Anders Carlsson  <andersca@apple.com>
     2
     3        Crash in convertMainResourceLoadToDownload when downloading file by option-return
     4        https://bugs.webkit.org/show_bug.cgi?id=116451
     5
     6        Reviewed by Andreas Kling.
     7
     8        Handle MainResourceLoader being null here which will happen when loading a cached main resource.
     9
     10        * loader/DocumentLoader.cpp:
     11        (WebCore::DocumentLoader::continueAfterContentPolicy):
     12
    1132013-05-23  Benjamin Poulain  <bpoulain@apple.com>
    214
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r150150 r150609  
    669669            return;
    670670        }
    671         InspectorInstrumentation::continueWithPolicyDownload(m_frame, this, mainResourceLoader()->identifier(), m_response);
     671
     672        if (ResourceLoader* mainResourceLoader = this->mainResourceLoader())
     673            InspectorInstrumentation::continueWithPolicyDownload(m_frame, this, mainResourceLoader->identifier(), m_response);
    672674
    673675        // When starting the request, we didn't know that it would result in download and not navigation. Now we know that main document URL didn't change.
     
    682684    }
    683685    case PolicyIgnore:
    684         InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, mainResourceLoader()->identifier(), m_response);
     686        if (ResourceLoader* mainResourceLoader = this->mainResourceLoader())
     687            InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, mainResourceLoader->identifier(), m_response);
    685688        stopLoadingForPolicyChange();
    686689        return;
  • trunk/Source/WebKit/mac/ChangeLog

    r150530 r150609  
     12013-05-23  Anders Carlsson  <andersca@apple.com>
     2
     3        Crash in convertMainResourceLoadToDownload when downloading file by option-return
     4        https://bugs.webkit.org/show_bug.cgi?id=116451
     5
     6        Reviewed by Andreas Kling.
     7
     8        If the main resource loader is null, create a new download instead since there's no existing loader to convert.
     9
     10        * WebCoreSupport/WebFrameLoaderClient.mm:
     11        (WebFrameLoaderClient::convertMainResourceLoadToDownload):
     12
    1132013-05-22  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r150273 r150609  
    279279void WebFrameLoaderClient::convertMainResourceLoadToDownload(DocumentLoader* documentLoader, const ResourceRequest& request, const ResourceResponse& response)
    280280{
     281    WebView *webView = getWebView(m_webFrame.get());
     282
     283    if (!documentLoader->mainResourceLoader()) {
     284        // The resource has already been cached, start a new download.
     285        WebDownload *webDownload = [[WebDownload alloc] initWithRequest:request.nsURLRequest(UpdateHTTPBody) delegate:[webView downloadDelegate]];
     286        [webDownload autorelease];
     287        return;
     288    }
     289
    281290    ResourceHandle* handle = documentLoader->mainResourceLoader()->handle();
    282291
    283292#if USE(CFNETWORK)
    284293    ASSERT([WebDownload respondsToSelector:@selector(_downloadWithLoadingCFURLConnection:request:response:delegate:proxy:)]);
    285     WebView *webView = getWebView(m_webFrame.get());
    286294    CFURLConnectionRef connection = handle->connection();
    287295    [WebDownload _downloadWithLoadingCFURLConnection:connection
     
    295303    CFRelease(connection);
    296304#else
    297     WebView *webView = getWebView(m_webFrame.get());
    298305    [WebDownload _downloadWithLoadingConnection:handle->connection()
    299306                                                                request:request.nsURLRequest(UpdateHTTPBody)
  • trunk/Source/WebKit2/ChangeLog

    r150599 r150609  
     12013-05-23  Anders Carlsson  <andersca@apple.com>
     2
     3        Crash in convertMainResourceLoadToDownload when downloading file by option-return
     4        https://bugs.webkit.org/show_bug.cgi?id=116451
     5
     6        Reviewed by Andreas Kling.
     7
     8        If the main resource loader is null, create a new download instead since there's no existing loader to convert.
     9
     10        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     11        (WebKit::NetworkConnectionToWebProcess::convertMainResourceLoadToDownload):
     12        * WebProcess/WebPage/WebFrame.cpp:
     13        (WebKit::WebFrame::convertMainResourceLoadToDownload):
     14
    1152013-05-22  Alexey Proskuryakov  <ap@apple.com>
    216
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r150537 r150609  
    176176void NetworkConnectionToWebProcess::convertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, const ResourceRequest& request, const ResourceResponse& response)
    177177{
     178    if (!mainResourceLoadIdentifier) {
     179        NetworkProcess::shared().downloadManager().startDownload(downloadID, request);
     180        return;
     181    }
     182
    178183    NetworkResourceLoader* loader = m_networkResourceLoaders.get(mainResourceLoadIdentifier);
    179184    NetworkProcess::shared().downloadManager().convertHandleToDownload(downloadID, loader->handle(), request, response);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp

    r150282 r150609  
    257257    m_policyDownloadID = 0;
    258258
     259    ResourceLoader* mainResourceLoader = documentLoader->mainResourceLoader();
     260
    259261#if ENABLE(NETWORK_PROCESS)
    260262    if (WebProcess::shared().usesNetworkProcess()) {
    261         WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ConvertMainResourceLoadToDownload(documentLoader->mainResourceLoader()->identifier(), policyDownloadID, request, response), 0);
     263        // Use 0 to indicate that there is no main resource loader.
     264        // This can happen if the main resource is in the WebCore memory cache.
     265        uint64_t mainResourceLoadIdentifier;
     266        if (mainResourceLoader)
     267            mainResourceLoadIdentifier = mainResourceLoader->identifier();
     268        else
     269            mainResourceLoadIdentifier = 0;
     270
     271        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ConvertMainResourceLoadToDownload(mainResourceLoadIdentifier, policyDownloadID, request, response), 0);
    262272        return;
    263273    }
    264274#endif
     275
     276    if (!mainResourceLoader) {
     277        // The main resource has already been loaded. Start a new download instead.
     278        WebProcess::shared().downloadManager().startDownload(policyDownloadID, request);
     279        return;
     280    }
    265281
    266282    WebProcess::shared().downloadManager().convertHandleToDownload(policyDownloadID, documentLoader->mainResourceLoader()->handle(), request, response);
Note: See TracChangeset for help on using the changeset viewer.