Skip to content

Commit

Permalink
Removed old proxies + fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArielDemarco committed Feb 7, 2025
1 parent 54095bf commit 6e65af5
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 344 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ protocol URLSessionSwizzler: Swizzlable {
init(handler: URLSessionTaskHandler, baseClass: AnyClass)
}

class EmbraceDummyURLSessionDelegate: NSObject, URLSessionDelegate {}

/// Service that generates OpenTelemetry spans for network requests that use `URLSession`.
@objc(EMBURLSessionCaptureService)
public final class URLSessionCaptureService: CaptureService, URLSessionTaskHandlerDataSource {
Expand Down Expand Up @@ -112,6 +114,11 @@ struct URLSessionInitWithDelegateSwizzler: URLSessionSwizzler {
return originalImplementation(urlSession, Self.selector, configuration, delegate, queue)
}

// Add protection against re-proxying our own proxy
guard !(proxiedDelegate is EMBURLSessionDelegateProxy) else {
return originalImplementation(urlSession, Self.selector, configuration, delegate, queue)
}

let newDelegate = EMBURLSessionDelegateProxy(delegate: proxiedDelegate, handler: handler)
let session = originalImplementation(urlSession, Self.selector, configuration, newDelegate, queue)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ NS_ASSUME_NONNULL_BEGIN
@interface EMBURLSessionDelegateProxy : NSProxy<NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSURLSessionStreamDelegate>

@property (nonatomic, strong, nullable) id originalDelegate;

/// This helps to determine if, during the creation of the `URLSessionDelegateProxy`,
/// another player or SDK has already swizzled or proxied NSURLSession/URLSession.
@property (nonatomic, weak, nullable) id<NSURLSessionDelegate> swizzledDelegate;

@property (nonatomic, strong, nullable) id<URLSessionTaskHandler> handler;

- (instancetype)initWithDelegate:(id<NSURLSessionDelegate> _Nullable)delegate handler:(id<URLSessionTaskHandler>)handler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface EMBWKNavigationDelegateProxy: NSProxy <WKNavigationDelegate>

@property (nonatomic, weak, nullable) id<WKNavigationDelegate> originalDelegate;

/// callback triggered the webview loads an url or errors
@property (copy, nullable) void (^callback)(NSURL * _Nullable, NSInteger);

- (instancetype)initWithOriginalDelegate:(id<WKNavigationDelegate> _Nullable)originalDelegate
Expand Down
Loading

0 comments on commit 6e65af5

Please sign in to comment.