[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:07:28 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit f7b34a461191ea081a62781438d061bac13dc18c
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Nov 23 21:17:43 2002 +0000

    	Fixed: 3109835 - Download errors aren't communicated to client
    
    	Cleaned-up WebMainResourceClient and WebBaseResourceHandleDelegate a little.
    
            * Misc.subproj/WebIconDatabase.m:
            (-[WebIconDatabase defaultIconWithSize:]): tweak
            (-[WebIconDatabase releaseIconForSiteURL:]): don't retain site URL here
            (-[WebIconDatabase _setIcon:forIconURL:]): tweak
            (-[WebIconDatabase _setIconURL:forSiteURL:]): tweak
            (-[WebIconDatabase _releaseIconForIconURLString:]): retain site URL here
            (-[WebIconDatabase _releaseFutureIconForSiteURL:]): tweak
            (-[WebIconDatabase _sendNotificationForSiteURL:]): tweak
            * WebView.subproj/WebBaseResourceHandleDelegate.h:
            * WebView.subproj/WebBaseResourceHandleDelegate.m:
            (-[WebBaseResourceHandleDelegate cancelWithError:]): made public
            (-[WebBaseResourceHandleDelegate cancel]): cancel downloads too, call cancelWithError
            (-[WebBaseResourceHandleDelegate cancelQuietly]): call cancelWithError
            (-[WebBaseResourceHandleDelegate cancelledError]): tweak
            (-[WebBaseResourceHandleDelegate notifyDelegatesOfInterruptionByPolicyChange]): tweak
            * WebView.subproj/WebMainResourceClient.m:
            (-[WebMainResourceClient receivedError:]): stop downloadHandler if downloading, else notify controller
            (-[WebMainResourceClient cancel]): call receivedError
            (-[WebMainResourceClient checkContentPolicyForResponse:andCallSelector:]): tweak
            (-[WebMainResourceClient handle:didReceiveData:]): stop load for download errors, report error
            (-[WebMainResourceClient handleDidFinishLoading:]): call didFailLoadingWithError is download error
            (-[WebMainResourceClient handle:didFailLoadingWithError:]): call receivedError
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2844 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 60c2f41..7b7a40d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,32 @@
+2002-11-23  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed: 3109835 - Download errors aren't communicated to client
+
+	Cleaned-up WebMainResourceClient and WebBaseResourceHandleDelegate a little.
+
+        * Misc.subproj/WebIconDatabase.m:
+        (-[WebIconDatabase defaultIconWithSize:]): tweak
+        (-[WebIconDatabase releaseIconForSiteURL:]): don't retain site URL here 
+        (-[WebIconDatabase _setIcon:forIconURL:]): tweak
+        (-[WebIconDatabase _setIconURL:forSiteURL:]): tweak
+        (-[WebIconDatabase _releaseIconForIconURLString:]): retain site URL here 
+        (-[WebIconDatabase _releaseFutureIconForSiteURL:]): tweak
+        (-[WebIconDatabase _sendNotificationForSiteURL:]): tweak
+        * WebView.subproj/WebBaseResourceHandleDelegate.h:
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate cancelWithError:]): made public
+        (-[WebBaseResourceHandleDelegate cancel]): cancel downloads too, call cancelWithError
+        (-[WebBaseResourceHandleDelegate cancelQuietly]): call cancelWithError
+        (-[WebBaseResourceHandleDelegate cancelledError]): tweak
+        (-[WebBaseResourceHandleDelegate notifyDelegatesOfInterruptionByPolicyChange]): tweak
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient receivedError:]): stop downloadHandler if downloading, else notify controller
+        (-[WebMainResourceClient cancel]): call receivedError
+        (-[WebMainResourceClient checkContentPolicyForResponse:andCallSelector:]): tweak
+        (-[WebMainResourceClient handle:didReceiveData:]): stop load for download errors, report error
+        (-[WebMainResourceClient handleDidFinishLoading:]): call didFailLoadingWithError is download error
+        (-[WebMainResourceClient handle:didFailLoadingWithError:]): call receivedError
+
 2002-11-22  Darin Adler  <darin at apple.com>
 
         * Misc.subproj/WebCoreStatistics.h:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 60c2f41..7b7a40d 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,32 @@
+2002-11-23  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed: 3109835 - Download errors aren't communicated to client
+
+	Cleaned-up WebMainResourceClient and WebBaseResourceHandleDelegate a little.
+
+        * Misc.subproj/WebIconDatabase.m:
+        (-[WebIconDatabase defaultIconWithSize:]): tweak
+        (-[WebIconDatabase releaseIconForSiteURL:]): don't retain site URL here 
+        (-[WebIconDatabase _setIcon:forIconURL:]): tweak
+        (-[WebIconDatabase _setIconURL:forSiteURL:]): tweak
+        (-[WebIconDatabase _releaseIconForIconURLString:]): retain site URL here 
+        (-[WebIconDatabase _releaseFutureIconForSiteURL:]): tweak
+        (-[WebIconDatabase _sendNotificationForSiteURL:]): tweak
+        * WebView.subproj/WebBaseResourceHandleDelegate.h:
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate cancelWithError:]): made public
+        (-[WebBaseResourceHandleDelegate cancel]): cancel downloads too, call cancelWithError
+        (-[WebBaseResourceHandleDelegate cancelQuietly]): call cancelWithError
+        (-[WebBaseResourceHandleDelegate cancelledError]): tweak
+        (-[WebBaseResourceHandleDelegate notifyDelegatesOfInterruptionByPolicyChange]): tweak
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient receivedError:]): stop downloadHandler if downloading, else notify controller
+        (-[WebMainResourceClient cancel]): call receivedError
+        (-[WebMainResourceClient checkContentPolicyForResponse:andCallSelector:]): tweak
+        (-[WebMainResourceClient handle:didReceiveData:]): stop load for download errors, report error
+        (-[WebMainResourceClient handleDidFinishLoading:]): call didFailLoadingWithError is download error
+        (-[WebMainResourceClient handle:didFailLoadingWithError:]): call receivedError
+
 2002-11-22  Darin Adler  <darin at apple.com>
 
         * Misc.subproj/WebCoreStatistics.h:
diff --git a/WebKit/Misc.subproj/WebIconDatabase.m b/WebKit/Misc.subproj/WebIconDatabase.m
index b02e3e4..083427e 100644
--- a/WebKit/Misc.subproj/WebIconDatabase.m
+++ b/WebKit/Misc.subproj/WebIconDatabase.m
@@ -139,7 +139,8 @@ NSSize WebIconLargeSize = {128, 128};
         NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"url_icon" ofType:@"tiff"];
         if (path) {
             NSImage *icon = [[NSImage alloc] initByReferencingFile:path];
-            _private->defaultIcons = [[NSMutableDictionary dictionaryWithObject:icon forKey:[NSValue valueWithSize:[icon size]]] retain];
+            _private->defaultIcons = [[NSMutableDictionary dictionaryWithObject:icon
+                                            forKey:[NSValue valueWithSize:[icon size]]] retain];
             [icon release];
         }
     }
@@ -165,15 +166,12 @@ NSSize WebIconLargeSize = {128, 128};
     ASSERT(siteURL);
     
     NSString *iconURLString = [_private->siteURLToIconURL objectForKey:[siteURL absoluteString]];
-    [iconURLString retain];
     
     if(iconURLString){
         [self _releaseIconForIconURLString:iconURLString];
     }else{
         [self _releaseFutureIconForSiteURL:siteURL];        
     }
-
-    [iconURLString release];
 }
 
 - (void)delayDatabaseCleanup
@@ -398,7 +396,6 @@ NSSize WebIconLargeSize = {128, 128};
     }
 
     NSString *iconURLString = [iconURL absoluteString];
-    [_private->iconURLToIcons removeObjectForKey:iconURLString];
     [_private->iconURLToIcons setObject:icons forKey:iconURLString];
 
     [self _retainIconForIconURLString:iconURLString];
@@ -418,7 +415,7 @@ NSSize WebIconLargeSize = {128, 128};
     NSString *iconURLString = [iconURL absoluteString];
 
     if([[_private->siteURLToIconURL objectForKey:siteURLString] isEqualToString:iconURLString]){
-        // Don't do any work if the iconURL is already bound to site URL
+        // Don't do any work if the iconURL is already bound to the site URL
         return;
     }
     
@@ -496,9 +493,11 @@ NSSize WebIconLargeSize = {128, 128};
         [_private->iconURLToRetainCount removeObjectForKey:iconURLString];
 
         // Remove the icon's associated site URLs
+        [iconURLString retain];
         NSSet *siteURLStrings = [_private->iconURLToSiteURLs objectForKey:iconURLString];
         [_private->siteURLToIconURL removeObjectsForKeys:[siteURLStrings allObjects]];
         [_private->iconURLToSiteURLs removeObjectForKey:iconURLString];
+        [iconURLString release];
     }
 }
 
@@ -531,6 +530,7 @@ NSSize WebIconLargeSize = {128, 128};
     if(!retainCount){
         [NSException raise:NSGenericException
                     format:@"Releasing a future icon that was not previously retained."];
+        return;
     }
 
     int newRetainCount = [retainCount intValue] - 1;
@@ -575,7 +575,8 @@ NSSize WebIconLargeSize = {128, 128};
 {
     ASSERT(siteURL);
     
-    NSDictionary *userInfo = [NSDictionary dictionaryWithObject:siteURL forKey:WebIconNotificationUserInfoSiteURLKey];
+    NSDictionary *userInfo = [NSDictionary dictionaryWithObject:siteURL
+                                                         forKey:WebIconNotificationUserInfoSiteURLKey];
     [[NSNotificationCenter defaultCenter] postNotificationName:WebIconDatabaseDidAddIconNotification
                                                         object:self
                                                       userInfo:userInfo];
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
index 967b8d7..c27885c 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
@@ -44,6 +44,7 @@
 
 - (void)cancel;
 - (void)cancelQuietly;
+- (void)cancelWithError:(WebError *)error;
 
 - (void)setDefersCallbacks:(BOOL)defers;
 
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
index a993862..9cf034a 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
@@ -210,7 +210,7 @@
     [self _releaseResources];
 }
 
-- (void)_cancelWithError:(WebError *)error
+- (void)cancelWithError:(WebError *)error
 {
     ASSERT(!reachedTerminalState);
 
@@ -219,7 +219,11 @@
     [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:controller];
 
     if (error) {
-        [resourceLoadDelegate resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+        if ([self isDownload]) {
+            [downloadDelegate resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+        } else {
+            [resourceLoadDelegate resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+        }
     }
 
     [self _releaseResources];
@@ -227,24 +231,30 @@
 
 - (void)cancel
 {
-    [self _cancelWithError:[self isDownload] ? nil : [self cancelledError]];
+    [self cancelWithError:[self cancelledError]];
 }
 
 - (void)cancelQuietly
 {
-    [self _cancelWithError:nil];
+    [self cancelWithError:nil];
 }
 
 - (WebError *)cancelledError
 {
-    return [WebError errorWithCode:WebErrorCodeCancelled 
-        inDomain:WebErrorDomainWebFoundation failingURL:[[request URL] absoluteString]];
+    return [WebError errorWithCode:WebErrorCodeCancelled
+                          inDomain:WebErrorDomainWebFoundation
+                        failingURL:[[request URL] absoluteString]];
 }
 
 - (void)notifyDelegatesOfInterruptionByPolicyChange
 {
-    WebError *error = [WebError errorWithCode:WebErrorResourceLoadInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
-    [[self resourceLoadDelegate] resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+    WebError *error = [WebError errorWithCode:WebErrorResourceLoadInterruptedByPolicyChange
+                                     inDomain:WebErrorDomainWebKit
+                                   failingURL:nil];
+    
+    [[self resourceLoadDelegate] resource:identifier
+                  didFailLoadingWithError:error
+                           fromDataSource:dataSource];
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebLoader.h b/WebKit/WebView.subproj/WebLoader.h
index 967b8d7..c27885c 100644
--- a/WebKit/WebView.subproj/WebLoader.h
+++ b/WebKit/WebView.subproj/WebLoader.h
@@ -44,6 +44,7 @@
 
 - (void)cancel;
 - (void)cancelQuietly;
+- (void)cancelWithError:(WebError *)error;
 
 - (void)setDefersCallbacks:(BOOL)defers;
 
diff --git a/WebKit/WebView.subproj/WebLoader.m b/WebKit/WebView.subproj/WebLoader.m
index a993862..9cf034a 100644
--- a/WebKit/WebView.subproj/WebLoader.m
+++ b/WebKit/WebView.subproj/WebLoader.m
@@ -210,7 +210,7 @@
     [self _releaseResources];
 }
 
-- (void)_cancelWithError:(WebError *)error
+- (void)cancelWithError:(WebError *)error
 {
     ASSERT(!reachedTerminalState);
 
@@ -219,7 +219,11 @@
     [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:controller];
 
     if (error) {
-        [resourceLoadDelegate resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+        if ([self isDownload]) {
+            [downloadDelegate resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+        } else {
+            [resourceLoadDelegate resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+        }
     }
 
     [self _releaseResources];
@@ -227,24 +231,30 @@
 
 - (void)cancel
 {
-    [self _cancelWithError:[self isDownload] ? nil : [self cancelledError]];
+    [self cancelWithError:[self cancelledError]];
 }
 
 - (void)cancelQuietly
 {
-    [self _cancelWithError:nil];
+    [self cancelWithError:nil];
 }
 
 - (WebError *)cancelledError
 {
-    return [WebError errorWithCode:WebErrorCodeCancelled 
-        inDomain:WebErrorDomainWebFoundation failingURL:[[request URL] absoluteString]];
+    return [WebError errorWithCode:WebErrorCodeCancelled
+                          inDomain:WebErrorDomainWebFoundation
+                        failingURL:[[request URL] absoluteString]];
 }
 
 - (void)notifyDelegatesOfInterruptionByPolicyChange
 {
-    WebError *error = [WebError errorWithCode:WebErrorResourceLoadInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
-    [[self resourceLoadDelegate] resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
+    WebError *error = [WebError errorWithCode:WebErrorResourceLoadInterruptedByPolicyChange
+                                     inDomain:WebErrorDomainWebKit
+                                   failingURL:nil];
+    
+    [[self resourceLoadDelegate] resource:identifier
+                  didFailLoadingWithError:error
+                           fromDataSource:dataSource];
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index d13383c..8bcae94 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -65,9 +65,14 @@
 }
 
 - (void)receivedError:(WebError *)error
-{    
-    if (![dataSource isDownloading]) {
-        [[dataSource controller] _mainReceivedError:error fromDataSource:dataSource];
+{
+    if (downloadHandler) {
+        [downloadHandler cancel];
+        [downloadHandler release];
+        downloadHandler = nil;
+    } else {
+        [[dataSource controller] _mainReceivedError:error
+                                     fromDataSource:dataSource];
     }
 }
 
@@ -77,14 +82,8 @@
     
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
-    
-    [self receivedError:[self cancelledError]];
 
-    if (downloadHandler) {
-        [downloadHandler cancel];
-        [downloadHandler release];
-        downloadHandler = nil;
-    }
+    [self receivedError:[self cancelledError]];
         
     [super cancel];
 
@@ -233,8 +232,8 @@
 {
     WebPolicyAction contentPolicy = 
 	[[[dataSource controller] policyDelegate] contentPolicyForMIMEType:[r contentType]
-						  andRequest:[dataSource request]
-						  inFrame:[dataSource webFrame]];
+                                                                andRequest:[dataSource request]
+                                                                   inFrame:[dataSource webFrame]];
     [self performSelector:selector withObject:(id)contentPolicy withObject:r];
 }
 
@@ -266,14 +265,11 @@
     ASSERT([data length] != 0);
 
     LOG(Loading, "URL = %@, data = %p, length %d", [dataSource URL], data, [data length]);
+
+    WebError *downloadError= nil;
     
     if (downloadHandler) {
-        WebError *downloadError = [downloadHandler receivedData:data];
-        if (downloadError) {
-            [self receivedError:downloadError];
-            [self cancel];
-            return;
-        }
+        downloadError = [downloadHandler receivedData:data];
     } else {
         [resourceData appendData:data];
         [dataSource _receivedData:data];
@@ -283,8 +279,12 @@
     }
     
     [super handle:h didReceiveData:data];
-    
     _bytesReceived += [data length];
+    
+    if(downloadError){
+        // Cancel download after calling didReceiveData to preserve ordering of calls.
+        [self cancelWithError:downloadError];
+    }
 
     LOG(Download, "%d of %d", _bytesReceived, _contentLength);
 }
@@ -293,53 +293,44 @@
 {
     LOG(Loading, "URL = %@", [dataSource URL]);
         
-    // Calling receivedError will likely result in a call to release, so we must retain.
+    // Calls in this method will most likely result in a call to release, so we must retain.
     [self retain];
 
-    if (![dataSource isDownloading]) {
-	// Don't retain data for downloaded files
-    	[dataSource _setResourceData:resourceData];
-
-        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
-    }
+    WebError *downloadError = nil;
     
     if (downloadHandler) {
-        WebError *downloadError = [downloadHandler finishedLoading];
-        if (downloadError)
-            [self receivedError:downloadError];
-
+        downloadError = [downloadHandler finishedLoading];
         [dataSource _setPrimaryLoadComplete:YES];
         [downloadHandler release];
         downloadHandler = nil;
-    }
-    else {
+    } else {
+        [dataSource _setResourceData:resourceData];
+        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
         [dataSource _finishedLoading];
         [[dataSource controller] _mainReceivedBytesSoFar:[resourceData length]
                                           fromDataSource:dataSource
                                                 complete:YES];
     }
-    
-    [super handleDidFinishLoading:h];
+
+    if(downloadError){
+        [super handle:h didFailLoadingWithError:downloadError];
+    } else {
+        [super handleDidFinishLoading:h];
+    }
 
     [self release];
 }
 
-- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)result
+- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)error
 {
-    LOG(Loading, "URL = %@, result = %@", [result failingURL], [result errorDescription]);
+    LOG(Loading, "URL = %@, error = %@", [error failingURL], [error errorDescription]);
 
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:result];
-
-    if (downloadHandler) {
-        [downloadHandler cancel];
-        [downloadHandler release];
-        downloadHandler = nil;
-    }
+    [self receivedError:error];
     
-    [super handle:h didFailLoadingWithError:result];
+    [super handle:h didFailLoadingWithError:error];
 
     [self release];
 }
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index d13383c..8bcae94 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -65,9 +65,14 @@
 }
 
 - (void)receivedError:(WebError *)error
-{    
-    if (![dataSource isDownloading]) {
-        [[dataSource controller] _mainReceivedError:error fromDataSource:dataSource];
+{
+    if (downloadHandler) {
+        [downloadHandler cancel];
+        [downloadHandler release];
+        downloadHandler = nil;
+    } else {
+        [[dataSource controller] _mainReceivedError:error
+                                     fromDataSource:dataSource];
     }
 }
 
@@ -77,14 +82,8 @@
     
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
-    
-    [self receivedError:[self cancelledError]];
 
-    if (downloadHandler) {
-        [downloadHandler cancel];
-        [downloadHandler release];
-        downloadHandler = nil;
-    }
+    [self receivedError:[self cancelledError]];
         
     [super cancel];
 
@@ -233,8 +232,8 @@
 {
     WebPolicyAction contentPolicy = 
 	[[[dataSource controller] policyDelegate] contentPolicyForMIMEType:[r contentType]
-						  andRequest:[dataSource request]
-						  inFrame:[dataSource webFrame]];
+                                                                andRequest:[dataSource request]
+                                                                   inFrame:[dataSource webFrame]];
     [self performSelector:selector withObject:(id)contentPolicy withObject:r];
 }
 
@@ -266,14 +265,11 @@
     ASSERT([data length] != 0);
 
     LOG(Loading, "URL = %@, data = %p, length %d", [dataSource URL], data, [data length]);
+
+    WebError *downloadError= nil;
     
     if (downloadHandler) {
-        WebError *downloadError = [downloadHandler receivedData:data];
-        if (downloadError) {
-            [self receivedError:downloadError];
-            [self cancel];
-            return;
-        }
+        downloadError = [downloadHandler receivedData:data];
     } else {
         [resourceData appendData:data];
         [dataSource _receivedData:data];
@@ -283,8 +279,12 @@
     }
     
     [super handle:h didReceiveData:data];
-    
     _bytesReceived += [data length];
+    
+    if(downloadError){
+        // Cancel download after calling didReceiveData to preserve ordering of calls.
+        [self cancelWithError:downloadError];
+    }
 
     LOG(Download, "%d of %d", _bytesReceived, _contentLength);
 }
@@ -293,53 +293,44 @@
 {
     LOG(Loading, "URL = %@", [dataSource URL]);
         
-    // Calling receivedError will likely result in a call to release, so we must retain.
+    // Calls in this method will most likely result in a call to release, so we must retain.
     [self retain];
 
-    if (![dataSource isDownloading]) {
-	// Don't retain data for downloaded files
-    	[dataSource _setResourceData:resourceData];
-
-        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
-    }
+    WebError *downloadError = nil;
     
     if (downloadHandler) {
-        WebError *downloadError = [downloadHandler finishedLoading];
-        if (downloadError)
-            [self receivedError:downloadError];
-
+        downloadError = [downloadHandler finishedLoading];
         [dataSource _setPrimaryLoadComplete:YES];
         [downloadHandler release];
         downloadHandler = nil;
-    }
-    else {
+    } else {
+        [dataSource _setResourceData:resourceData];
+        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
         [dataSource _finishedLoading];
         [[dataSource controller] _mainReceivedBytesSoFar:[resourceData length]
                                           fromDataSource:dataSource
                                                 complete:YES];
     }
-    
-    [super handleDidFinishLoading:h];
+
+    if(downloadError){
+        [super handle:h didFailLoadingWithError:downloadError];
+    } else {
+        [super handleDidFinishLoading:h];
+    }
 
     [self release];
 }
 
-- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)result
+- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)error
 {
-    LOG(Loading, "URL = %@, result = %@", [result failingURL], [result errorDescription]);
+    LOG(Loading, "URL = %@, error = %@", [error failingURL], [error errorDescription]);
 
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:result];
-
-    if (downloadHandler) {
-        [downloadHandler cancel];
-        [downloadHandler release];
-        downloadHandler = nil;
-    }
+    [self receivedError:error];
     
-    [super handle:h didFailLoadingWithError:result];
+    [super handle:h didFailLoadingWithError:error];
 
     [self release];
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list