cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject git commit: [CB-5175] CDVFileTransfer asynchronous download (Fixes #24)
Date Thu, 27 Mar 2014 17:23:08 GMT
Repository: cordova-plugin-file-transfer
Updated Branches:
  refs/heads/dev 449df5584 -> 223d08626


[CB-5175] CDVFileTransfer asynchronous download (Fixes #24)

Since download can take time, for it to be non-blocking, moved the call to a separate thread.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/223d0862
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/223d0862
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/223d0862

Branch: refs/heads/dev
Commit: 223d08626df36c0f386af3fe609d0a36c450d6d9
Parents: 449df55
Author: torrmal <jorge.torres.maldonado@gmail.com>
Authored: Wed Mar 26 11:58:26 2014 -0400
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Thu Mar 27 13:21:26 2014 -0400

----------------------------------------------------------------------
 src/ios/CDVFileTransfer.m | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/223d0862/src/ios/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m
index 3753993..d87bb94 100644
--- a/src/ios/CDVFileTransfer.m
+++ b/src/ios/CDVFileTransfer.m
@@ -430,8 +430,12 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
     @synchronized (activeTransfers) {
         activeTransfers[delegate.objectId] = delegate;
     }
-
-    [delegate.connection start];
+    // Downloads can take time
+    // sending this to a new thread calling the download_async method
+    dispatch_async(
+                   dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL),
+                   ^(void) { [delegate.connection start];}
+                   );
 }
 
 - (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target


Mime
View raw message