Skip to content

Commit

Permalink
Remove bespoke code that handled blocking callbacks (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan authored Jan 21, 2025
1 parent 7271367 commit 27184eb
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 5,184 deletions.
4 changes: 4 additions & 0 deletions pkgs/cupertino_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.3-wip

* Remove some unnecessary native code.

## 2.0.2

* Upgrade to `package:objective_c` 4.1.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion pkgs/cupertino_http/ffigen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ headers:
- '/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSOperation.h'
- '/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSError.h'
- '/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSDictionary.h'
- 'darwin/cupertino_http/Sources/cupertino_http/utils.h'
preamble: |
// ignore_for_file: always_specify_types
// ignore_for_file: camel_case_types
Expand Down
30 changes: 8 additions & 22 deletions pkgs/cupertino_http/lib/src/cupertino_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -919,29 +919,15 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
}

if (onFinishedDownloading != null) {
final asyncFinishDownloading =
// ignore: lines_longer_than_80_chars
ncb.ObjCBlock_ffiVoid_NSCondition_NSURLSession_NSURLSessionDownloadTask_NSURL
.listener((nsCondition, nsSession, nsTask, nsUrl) {
try {
onFinishedDownloading(
URLSession._(nsSession,
isBackground: isBackground, hasDelegate: true),
URLSessionDownloadTask._(nsTask),
nsurlToUri(nsUrl));
} finally {
nsCondition.unlock();
}
ncb.NSURLSessionDownloadDelegate
.URLSession_downloadTask_didFinishDownloadingToURL_
.implementAsBlocking(protoBuilder, (nsSession, nsTask, nsUrl) {
onFinishedDownloading(
URLSession._(nsSession,
isBackground: isBackground, hasDelegate: true),
URLSessionDownloadTask._(nsTask),
nsurlToUri(nsUrl));
});

final downloadDelegate = objc.getProtocol('NSURLSessionDownloadDelegate');
final didFinishDownloadingToURL = objc
.registerName('URLSession:downloadTask:didFinishDownloadingToURL:');
final signature = objc.getProtocolMethodSignature(
downloadDelegate, didFinishDownloadingToURL,
isRequired: true, isInstanceMethod: true)!;
protoBuilder.implementMethod(didFinishDownloadingToURL, signature,
linkedLibs.adaptFinishWithLock(asyncFinishDownloading));
}

if (onWebSocketTaskOpened != null) {
Expand Down
Loading

0 comments on commit 27184eb

Please sign in to comment.