[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:55:15 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 9722909faebdff223334d001e972badd78920308
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 4 23:22:13 2003 +0000

    	Fixed: <rdar://problem/3286922>: Shockwave: Using HTTP to stream .mp3 or .swa files fails at ~50%
    
            Reviewed by mjs.
    
            * Plugins.subproj/WebBaseNetscapePluginStream.h: new deliveryData and reason ivars
            * Plugins.subproj/WebBaseNetscapePluginStream.m:
            (-[WebBaseNetscapePluginStream dealloc]): release deliveryData ivar
            (-[WebBaseNetscapePluginStream startStreamWithURL:expectedContentLength:lastModifiedDate:MIMEType:]): set new reason ivar
            (-[WebBaseNetscapePluginStream destroyStream]): new, calls NPP_StreamAsFile, NPP_DestroyStream and NPP_URLNotify
            (-[WebBaseNetscapePluginStream destroyStreamWithReason:]): set the reason, call destroyStream
            (-[WebBaseNetscapePluginStream receivedError:]): set deliveryData length to 0 so no more data is streamed, call destroyStreamWithReason
            (-[WebBaseNetscapePluginStream finishedLoadingWithData:]): don't call NPP_StreamAsFile because this has to be called right before NPP_DestroyStream in destroyStream
            (-[WebBaseNetscapePluginStream deliverData]): new, call NPP_WriteReady and NPP_Write and properly obey their returned values
            (-[WebBaseNetscapePluginStream receivedData:]): call deliverData
            * Plugins.subproj/WebNetscapePluginStream.m:
            (-[WebNetscapePluginStream stop]): call receivedError here
            (-[WebNetscapePluginConnectionDelegate connection:didFailWithError:]): don't call receivedError here because after the load is complete, stream is set to nil and receivedError can be called after the completed load
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4937 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 1dc01b1..5f09272 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,25 @@
 2003-09-04  Chris Blumenberg  <cblu at apple.com>
 
+	Fixed: <rdar://problem/3286922>: Shockwave: Using HTTP to stream .mp3 or .swa files fails at ~50%
+
+        Reviewed by mjs.
+
+        * Plugins.subproj/WebBaseNetscapePluginStream.h: new deliveryData and reason ivars
+        * Plugins.subproj/WebBaseNetscapePluginStream.m:
+        (-[WebBaseNetscapePluginStream dealloc]): release deliveryData ivar
+        (-[WebBaseNetscapePluginStream startStreamWithURL:expectedContentLength:lastModifiedDate:MIMEType:]): set new reason ivar
+        (-[WebBaseNetscapePluginStream destroyStream]): new, calls NPP_StreamAsFile, NPP_DestroyStream and NPP_URLNotify
+        (-[WebBaseNetscapePluginStream destroyStreamWithReason:]): set the reason, call destroyStream
+        (-[WebBaseNetscapePluginStream receivedError:]): set deliveryData length to 0 so no more data is streamed, call destroyStreamWithReason
+        (-[WebBaseNetscapePluginStream finishedLoadingWithData:]): don't call NPP_StreamAsFile because this has to be called right before NPP_DestroyStream in destroyStream
+        (-[WebBaseNetscapePluginStream deliverData]): new, call NPP_WriteReady and NPP_Write and properly obey their returned values
+        (-[WebBaseNetscapePluginStream receivedData:]): call deliverData
+        * Plugins.subproj/WebNetscapePluginStream.m:
+        (-[WebNetscapePluginStream stop]): call receivedError here
+        (-[WebNetscapePluginConnectionDelegate connection:didFailWithError:]): don't call receivedError here because after the load is complete, stream is set to nil and receivedError can be called after the completed load
+
+2003-09-04  Chris Blumenberg  <cblu at apple.com>
+
         * Plugins.subproj/WebBaseNetscapePluginView.m:
         (-[WebBaseNetscapePluginView postURL:target:len:buf:file:]): Fixed typo in newly added comment.
 
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h
index 75bbd04..31bf1d0 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.h
@@ -13,6 +13,7 @@
 
 @interface WebBaseNetscapePluginStream : NSObject
 {
+    NSMutableData *deliveryData;
     NSURL *URL;
     NPP instance;
     uint16 transferMode;
@@ -21,6 +22,7 @@
     char *path;
     void *notifyData;
     WebNetscapePluginPackage *plugin;
+    NPReason reason;
         
     NPP_NewStreamProcPtr NPP_NewStream;
     NPP_DestroyStreamProcPtr NPP_DestroyStream;
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
index b2e5bbe..7c95bf9 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
@@ -31,6 +31,7 @@
     free((void *)stream.URL);
     free(path);
     [plugin release];
+    [deliveryData release];
     
     [super dealloc];
 }
@@ -82,6 +83,7 @@
     
     transferMode = NP_NORMAL;
     offset = 0;
+    reason = -1;
 
     // FIXME: Need a way to check if stream is seekable
 
@@ -121,29 +123,17 @@
                     MIMEType:[r MIMEType]];
 }
 
-- (void)receivedData:(NSData *)data
+- (void)destroyStream
 {
-    if (![plugin isLoaded] || !stream.ndata || [data length] == 0) {
+    if (![plugin isLoaded] || !stream.ndata || [deliveryData length] > 0 || reason == -1) {
         return;
     }
     
-    if (transferMode != NP_ASFILEONLY) {
-        int32 numBytes;
-        
-        numBytes = NPP_WriteReady(instance, &stream);
-        LOG(Plugins, "NPP_WriteReady bytes=%lu", numBytes);
-        
-        numBytes = NPP_Write(instance, &stream, offset, [data length], (void *)[data bytes]);
-        LOG(Plugins, "NPP_Write bytes=%lu", numBytes);
-        
-        offset += [data length];
-    }
-}
-
-- (void)destroyStreamWithReason:(NPReason)reason
-{
-    if (![plugin isLoaded] || !stream.ndata) {
-        return;
+    if (reason == NPRES_DONE && (transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY)) {
+        ASSERT(path != NULL);
+        NSString *carbonPath = [[NSFileManager defaultManager] _web_carbonPathForPath:[NSString stringWithCString:path]];
+        NPP_StreamAsFile(instance, &stream, [carbonPath cString]);
+        LOG(Plugins, "NPP_StreamAsFile: %@", carbonPath);
     }
     
     NPError npErr;
@@ -158,9 +148,17 @@
     }
 }
 
-- (void)receivedError:(NPError)reason
+- (void)destroyStreamWithReason:(NPReason)theReason
+{
+    reason = theReason;
+    [self destroyStream];
+}
+
+- (void)receivedError:(NPError)error
 {
-    [self destroyStreamWithReason:reason];
+    // Stop any pending data from being streamed.
+    [deliveryData setLength:0];
+    [self destroyStreamWithReason:error];
 }
 
 - (void)finishedLoadingWithData:(NSData *)data
@@ -177,7 +175,7 @@
                 // This should almost never happen.
                 ERROR("can't make temporary file, almost certainly a problem with /tmp");
                 // This is not a network error, but the only error codes are "network error" and "user break".
-                [self destroyStreamWithReason:NPRES_NETWORK_ERR];
+                [self receivedError:NPRES_NETWORK_ERR];
                 free(path);
                 path = NULL;
                 return;
@@ -189,20 +187,70 @@
                 ERROR("error writing to temporary file, errno %d", errno);
                 close(fd);
                 // This is not a network error, but the only error codes are "network error" and "user break".
-                [self destroyStreamWithReason:NPRES_NETWORK_ERR];
+                [self receivedError:NPRES_NETWORK_ERR];
                 free(path);
                 path = NULL;
                 return;
             }
             close(fd);
         }
-        
-        NSString *carbonPath = [[NSFileManager defaultManager] _web_carbonPathForPath:[NSString stringWithCString:path]];
-        NPP_StreamAsFile(instance, &stream, [carbonPath cString]);
-        LOG(Plugins, "NPP_StreamAsFile: %@", carbonPath);
     }
 
     [self destroyStreamWithReason:NPRES_DONE];
 }
 
+- (void)deliverData
+{
+    if (![plugin isLoaded] || !stream.ndata || [deliveryData length] == 0) {
+        return;
+    }
+    
+    int32 totalBytes = [deliveryData length];
+    int32 totalBytesDelivered = 0;
+    
+    while (totalBytesDelivered < totalBytes) {
+        int32 deliveryBytes = NPP_WriteReady(instance, &stream);
+        LOG(Plugins, "NPP_WriteReady bytes=%d", deliveryBytes);
+        
+        if (deliveryBytes <= 0) {
+            // Plug-in can't receive anymore data right now. Send it later.
+            [self performSelector:@selector(deliverData) withObject:nil afterDelay:0];
+            break;
+        } else {
+            deliveryBytes = MIN(deliveryBytes, totalBytes - totalBytesDelivered);
+            NSData *subdata = [deliveryData subdataWithRange:NSMakeRange(totalBytesDelivered, deliveryBytes)];
+            deliveryBytes = NPP_Write(instance, &stream, offset, [subdata length], (void *)[subdata bytes]);
+            deliveryBytes = MIN((unsigned)deliveryBytes, [subdata length]);
+            LOG(Plugins, "NPP_Write bytes=%d", deliveryBytes);
+            offset += deliveryBytes;
+            totalBytesDelivered += deliveryBytes;
+        }
+    }
+    
+    if (totalBytesDelivered > 0) {
+        if (totalBytesDelivered < totalBytes) {
+            NSMutableData *newDeliveryData = [[NSMutableData alloc] initWithCapacity:totalBytes - totalBytesDelivered];
+            [newDeliveryData appendBytes:(char *)[deliveryData bytes] + totalBytesDelivered length:totalBytes - totalBytesDelivered];
+            [deliveryData release];
+            deliveryData = newDeliveryData;
+        } else {
+            [deliveryData setLength:0];
+            [self destroyStream];
+        }
+    }
+}
+
+- (void)receivedData:(NSData *)data
+{
+    ASSERT([data length] > 0);
+    
+    if (transferMode != NP_ASFILEONLY) {
+        if (!deliveryData) {
+            deliveryData = [[NSMutableData alloc] initWithCapacity:[data length]];
+        }
+        [deliveryData appendData:data];
+        [self deliverData];
+    }
+}
+
 @end
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginStream.m b/WebKit/Plugins.subproj/WebNetscapePluginStream.m
index 8eaaf67..dd19e4e 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginStream.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginStream.m
@@ -68,6 +68,11 @@
 - (void)stop
 {
     [_loader cancel];
+    // Since the plug-in is notified of the stream when the response is received,
+    // only report an error if the response has been received.
+    if ([_loader response]) {
+        [self receivedError:NPRES_USER_BREAK];
+    }
 }
 
 @end
@@ -144,15 +149,4 @@
     [self release];
 }
 
-- (void)cancel
-{
-    // Since the plug-in is notified of the stream when the response is received,
-    // only report an error if the response has been received.
-    if ([self response]) {
-        [stream receivedError:NPRES_USER_BREAK];
-    }
-
-    [super cancel];
-}
-
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list