-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db3a9fc
commit 95880e4
Showing
7 changed files
with
318 additions
and
36 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/native_cupertino_bindings.m
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#import <Foundation/NSLock.h> | ||
#import <Foundation/NSURL.h> | ||
#import <Foundation/NSURLSession.h> | ||
#include <stdint.h> | ||
|
||
#if !__has_feature(objc_arc) | ||
#error "This file must be compiled with ARC enabled" | ||
#endif | ||
|
||
typedef void (^_DidFinish)(void *, NSURLSession *session, | ||
NSURLSessionDownloadTask *downloadTask, | ||
NSURL *location); | ||
typedef void (^_DidFinishWithLock)(NSCondition *lock, NSURLSession *session, | ||
NSURLSessionDownloadTask *downloadTask, | ||
NSURL *location); | ||
/// Create a block useable as a | ||
/// `URLSession:downloadTask:didFinishDownloadingToURL:` that can be used to | ||
/// make an async Dart callback behave synchronously. | ||
_DidFinish adaptFinishWithLock(_DidFinishWithLock block); |
13 changes: 13 additions & 0 deletions
13
pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import "utils.h" | ||
|
||
_DidFinish adaptFinishWithLock(_DidFinishWithLock block) { | ||
return ^void(void *, NSURLSession *session, | ||
NSURLSessionDownloadTask *downloadTask, NSURL *location) { | ||
NSCondition *lock = [[NSCondition alloc] init]; | ||
|
||
[lock lock]; | ||
block(lock, session, downloadTask, location); | ||
[lock lock]; | ||
[lock unlock]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.