Diff
Modified: trunk/Source/WebKit2/ChangeLog (149210 => 149211)
--- trunk/Source/WebKit2/ChangeLog 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-26 21:39:27 UTC (rev 149211)
@@ -1,3 +1,45 @@
+2013-04-26 Anders Carlsson <ander...@apple.com>
+
+ Downloads need to be converted from the NSURLConnection, not canceled and restarted, when using the NetworkProcess
+ https://bugs.webkit.org/show_bug.cgi?id=115277
+ <rdar://problem/12890184>
+
+ Reviewed by Sam Weinig.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::convertMainResourceLoadToDownload):
+ Ask the download manager to convert the main resource load to a download.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+ Add new message.
+
+ * NetworkProcess/NetworkResourceLoader.h:
+ (WebKit::NetworkResourceLoader::handle):
+ Add getter.
+
+ * Shared/Downloads/mac/DownloadMac.mm:
+ (dispatchOnMainThread):
+ Helper function that ensures that a given block is called on the main thread.
+
+ (-[WKDownloadAsDelegate downloadDidBegin:]):
+ (-[WKDownloadAsDelegate download:didReceiveAuthenticationChallenge:]):
+ (-[WKDownloadAsDelegate download:didReceiveResponse:]):
+ (-[WKDownloadAsDelegate download:didReceiveDataOfLength:]):
+ (-[WKDownloadAsDelegate download:shouldDecodeSourceDataOfMIMEType:]):
+ (-[WKDownloadAsDelegate download:decideDestinationWithSuggestedFilename:]):
+ (-[WKDownloadAsDelegate download:didCreateDestination:]):
+ (-[WKDownloadAsDelegate downloadDidFinish:]):
+ (-[WKDownloadAsDelegate download:didFailWithError:]):
+ Use dispatchOnMainThread.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::receivedPolicyDecision):
+ Remove code that cancels the current load and starts a new download.
+
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::convertMainResourceLoadToDownload):
+ Send the ConvertMainResourceLoadToDownload message to the network process.
+
2013-04-25 Roger Fong <roger_f...@apple.com>
Disable sub-pixel layout on mac.
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (149210 => 149211)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2013-04-26 21:39:27 UTC (rev 149211)
@@ -163,6 +163,15 @@
NetworkProcess::shared().downloadManager().startDownload(downloadID, request);
}
+void NetworkConnectionToWebProcess::convertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, const ResourceRequest& request, const ResourceResponse& response)
+{
+ NetworkResourceLoader* loader = m_networkResourceLoaders.get(mainResourceLoadIdentifier).get();
+ NetworkProcess::shared().downloadManager().convertHandleToDownload(downloadID, loader->handle(), request, response);
+
+ // Unblock the URL connection operation queue.
+ loader->handle()->continueDidReceiveResponse();
+}
+
void NetworkConnectionToWebProcess::cookiesForDOM(bool privateBrowsingEnabled, const KURL& firstParty, const KURL& url, String& result)
{
result = WebCore::cookiesForDOM(storageSession(privateBrowsingEnabled), firstParty, url);
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (149210 => 149211)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h 2013-04-26 21:39:27 UTC (rev 149211)
@@ -77,6 +77,8 @@
void servePendingRequests(uint32_t resourceLoadPriority);
void setSerialLoadingEnabled(bool);
void startDownload(bool privateBrowsingEnabled, uint64_t downloadID, const WebCore::ResourceRequest&);
+ void convertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
+
void cookiesForDOM(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, String& result);
void setCookiesFromDOM(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
void cookiesEnabled(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, bool& result);
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in (149210 => 149211)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2013-04-26 21:39:27 UTC (rev 149211)
@@ -33,6 +33,7 @@
SetSerialLoadingEnabled(bool enabled) -> ()
StartDownload(bool privateBrowsingEnabled, uint64_t downloadID, WebCore::ResourceRequest request)
+ ConvertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, WebCore::ResourceRequest request, WebCore::ResourceResponse response)
CookiesForDOM(bool privateBrowsingEnabled, WebCore::KURL firstParty, WebCore::KURL url) -> (WTF::String result)
SetCookiesFromDOM(bool privateBrowsingEnabled, WebCore::KURL firstParty, WebCore::KURL url, WTF::String cookieString)
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h (149210 => 149211)
--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2013-04-26 21:39:27 UTC (rev 149211)
@@ -60,7 +60,9 @@
// Used by MessageSender.
CoreIPC::Connection* connection() const;
uint64_t destinationID() const;
-
+
+ WebCore::ResourceHandle* handle() const { return m_handle.get(); }
+
virtual void start() OVERRIDE;
virtual void connectionToWebProcessDidClose() OVERRIDE;
Modified: trunk/Source/WebKit2/Shared/Downloads/mac/DownloadMac.mm (149210 => 149211)
--- trunk/Source/WebKit2/Shared/Downloads/mac/DownloadMac.mm 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/Shared/Downloads/mac/DownloadMac.mm 2013-04-26 21:39:27 UTC (rev 149211)
@@ -30,6 +30,7 @@
#import <WebCore/AuthenticationMac.h>
#import <WebCore/NotImplemented.h>
#import <WebCore/ResourceHandle.h>
+#import <WebCore/ResourceHandleClient.h>
#import <WebCore/ResourceResponse.h>
#import "DataReference.h"
#import "WebPage.h"
@@ -126,6 +127,17 @@
@implementation WKDownloadAsDelegate
+// FIXME: It would be nice if these callbacks wouldn't have to be invoked on the main thread.
+static void dispatchOnMainThread(void (^block)())
+{
+ if (isMainThread()) {
+ block();
+ return;
+ }
+
+ dispatch_sync(dispatch_get_main_queue(), block);
+}
+
- (id)initWithDownload:(WebKit::Download*)download
{
self = [super init];
@@ -143,8 +155,10 @@
- (void)downloadDidBegin:(NSURLDownload *)download
{
- if (_download)
- _download->didStart();
+ dispatchOnMainThread(^{
+ if (_download)
+ _download->didStart();
+ });
}
- (NSURLRequest *)download:(NSURLDownload *)download willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
@@ -161,8 +175,10 @@
- (void)download:(NSURLDownload *)download didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
- if (_download)
- _download->didReceiveAuthenticationChallenge(core(challenge));
+ dispatchOnMainThread(^{
+ if (_download)
+ _download->didReceiveAuthenticationChallenge(core(challenge));
+ });
}
- (void)download:(NSURLDownload *)download didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
@@ -178,8 +194,10 @@
- (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response
{
- if (_download)
- _download->didReceiveResponse(response);
+ dispatchOnMainThread(^{
+ if (_download)
+ _download->didReceiveResponse(response);
+ });
}
- (void)download:(NSURLDownload *)download willResumeWithResponse:(NSURLResponse *)response fromByte:(long long)startingByte
@@ -190,50 +208,65 @@
- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(NSUInteger)length
{
- if (_download)
- _download->didReceiveData(length);
+ dispatchOnMainThread(^{
+ if (_download)
+ _download->didReceiveData(length);
+ });
}
- (BOOL)download:(NSURLDownload *)download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
{
- if (_download)
- return _download->shouldDecodeSourceDataOfMIMEType(encodingType);
+ __block BOOL returnValue;
+ dispatchOnMainThread(^{
+ if (_download)
+ returnValue = _download->shouldDecodeSourceDataOfMIMEType(encodingType);
+ else
+ returnValue = YES;
+ });
- return YES;
+ return returnValue;;
}
- (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename
{
- String destination;
- bool allowOverwrite;
- if (_download)
- destination = _download->decideDestinationWithSuggestedFilename(filename, allowOverwrite);
+ dispatchOnMainThread(^{
+ String destination;
+ bool allowOverwrite;
+ if (_download)
+ destination = _download->decideDestinationWithSuggestedFilename(filename, allowOverwrite);
- if (!destination.isNull())
- [download setDestination:destination allowOverwrite:allowOverwrite];
+ if (!destination.isNull())
+ [download setDestination:destination allowOverwrite:allowOverwrite];
+ });
}
- (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path
{
- if (_download)
- _download->didCreateDestination(path);
+ dispatchOnMainThread(^{
+ if (_download)
+ _download->didCreateDestination(path);
+ });
}
- (void)downloadDidFinish:(NSURLDownload *)download
{
- if (_download)
- _download->didFinish();
+ dispatchOnMainThread(^{
+ if (_download)
+ _download->didFinish();
+ });
}
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
{
- if (!_download)
- return;
+ dispatchOnMainThread(^{
+ if (!_download)
+ return;
- RetainPtr<NSData> resumeData = [download resumeData];
- CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>([resumeData.get() bytes]), [resumeData.get() length]);
+ RetainPtr<NSData> resumeData = [download resumeData];
+ CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>([resumeData.get() bytes]), [resumeData.get() length]);
- _download->didFail(error, dataReference);
+ _download->didFail(error, dataReference);
+ });
}
@end
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (149210 => 149211)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-04-26 21:39:27 UTC (rev 149211)
@@ -1446,16 +1446,6 @@
if (!isValid())
return;
-#if ENABLE(NETWORK_PROCESS)
- // FIXME (NetworkProcess): Instead of canceling the load and then starting a separate download, we should
- // just convert the connection to a download connection. See <rdar://problem/12890184>.
- if (m_inDecidePolicyForResponseSync && action == PolicyDownload && m_process->context()->usesNetworkProcess()) {
- action = ""
-
- m_process->context()->download(this, *m_decidePolicyForResponseRequest);
- }
-#endif
-
if (action == PolicyIgnore)
clearPendingAPIRequestURL();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (149210 => 149211)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2013-04-26 21:25:16 UTC (rev 149210)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2013-04-26 21:39:27 UTC (rev 149211)
@@ -258,7 +258,7 @@
#if ENABLE(NETWORK_PROCESS)
if (WebProcess::shared().usesNetworkProcess()) {
- // FIXME: Handle this case.
+ WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ConvertMainResourceLoadToDownload(documentLoader->mainResourceLoader()->identifier(), policyDownloadID, request, response), 0);
return;
}
#endif