Skip to content

Commit 427647b

Browse files
authored
[Auth] Make AuthBackend and related types Sendable (#14125)
1 parent ec3386a commit 427647b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import Foundation
2222
#endif
2323

2424
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
25-
protocol AuthBackendProtocol {
25+
protocol AuthBackendProtocol: Sendable {
2626
func call<T: AuthRPCRequest>(with request: T) async throws -> T.Response
2727
}
2828

2929
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
30-
class AuthBackend: AuthBackendProtocol {
30+
final class AuthBackend: AuthBackendProtocol {
3131
static func authUserAgent() -> String {
3232
return "FirebaseAuth.iOS/\(FirebaseVersion()) \(GTMFetcherStandardUserAgentString(nil))"
3333
}

FirebaseAuth/Sources/Swift/Backend/AuthBackendRPCIssuer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import FirebaseCore
1616
import FirebaseCoreExtension
1717
import Foundation
1818
#if COCOAPODS
19-
import GTMSessionFetcher
19+
@preconcurrency import GTMSessionFetcher
2020
#else
21-
import GTMSessionFetcherCore
21+
@preconcurrency import GTMSessionFetcherCore
2222
#endif
2323

2424
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
25-
protocol AuthBackendRPCIssuerProtocol {
25+
protocol AuthBackendRPCIssuerProtocol: Sendable {
2626
/// Asynchronously send a HTTP request.
2727
/// - Parameter request: The request to be made.
2828
/// - Parameter body: Request body.
@@ -35,7 +35,7 @@ protocol AuthBackendRPCIssuerProtocol {
3535
}
3636

3737
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
38-
class AuthBackendRPCIssuer: AuthBackendRPCIssuerProtocol {
38+
final class AuthBackendRPCIssuer: AuthBackendRPCIssuerProtocol {
3939
let fetcherService: GTMSessionFetcherService
4040

4141
init() {

FirebaseAuth/Tests/Unit/Fakes/FakeBackendRPCIssuer.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ import XCTest
1717

1818
@testable import FirebaseAuth
1919

20-
// TODO: Investigate making this class support generics for the `request`.
21-
/** @class FakeBackendRPCIssuer
22-
@brief An implementation of @c AuthBackendRPCIssuer which is used to test backend request,
23-
response, and glue logic.
24-
*/
20+
// TODO(ncooke3): Investigate making this class support generics for the `request`.
21+
// TODO(ncooke3): Refactor to make checked Sendable.
22+
/// An implementation of `AuthBackendRPCIssuerProtocol` which is used to test
23+
/// backend request, response, and glue logic.
2524
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
26-
class FakeBackendRPCIssuer: AuthBackendRPCIssuer {
25+
final class FakeBackendRPCIssuer: AuthBackendRPCIssuerProtocol, @unchecked Sendable {
2726
/** @property requestURL
2827
@brief The URL which was requested.
2928
*/
@@ -77,8 +76,8 @@ class FakeBackendRPCIssuer: AuthBackendRPCIssuer {
7776
var secureTokenErrorString: String?
7877
var recaptchaSiteKey = "unset recaptcha siteKey"
7978

80-
override func asyncCallToURL<T>(with request: T, body: Data?,
81-
contentType: String) async -> (Data?, Error?)
79+
func asyncCallToURL<T>(with request: T, body: Data?,
80+
contentType: String) async -> (Data?, Error?)
8281
where T: FirebaseAuth.AuthRPCRequest {
8382
return await withCheckedContinuation { continuation in
8483
self.asyncCallToURL(with: request, body: body, contentType: contentType) { data, error in
@@ -172,7 +171,7 @@ class FakeBackendRPCIssuer: AuthBackendRPCIssuer {
172171
}
173172

174173
func respond(serverErrorMessage errorMessage: String, error: NSError) throws {
175-
let _ = try respond(withJSON: ["error": ["message": errorMessage]], error: error)
174+
_ = try respond(withJSON: ["error": ["message": errorMessage]], error: error)
176175
}
177176

178177
@discardableResult func respond(underlyingErrorMessage errorMessage: String,

0 commit comments

Comments
 (0)