diff --git a/glean-core/ios/Glean/Glean.swift b/glean-core/ios/Glean/Glean.swift index e826d94886..e2a957f0b5 100644 --- a/glean-core/ios/Glean/Glean.swift +++ b/glean-core/ios/Glean/Glean.swift @@ -158,7 +158,7 @@ public class Glean { // 1. Pings were submitted through Glean and it is ready to upload those pings; // 2. Upload is disabled, to upload a possible deletion-request ping. if pingSubmitted || !uploadEnabled { - HttpPingUploader(configuration: configuration).process() + HttpPingUploader.launch(configuration: configuration) } // Check for overdue metrics pings @@ -270,9 +270,7 @@ public class Glean { if originalEnabled && !enabled { // If uploading is disabled, we need to send the deletion-request ping - Dispatchers.shared.launchConcurrent { - HttpPingUploader(configuration: self.configuration!).process() - } + HttpPingUploader.launch(configuration: self.configuration!) } } } @@ -456,7 +454,7 @@ public class Glean { if submittedPing != 0 { if let config = self.configuration { - HttpPingUploader(configuration: config).process() + HttpPingUploader.launch(configuration: config) } } } diff --git a/glean-core/ios/Glean/Net/HttpPingUploader.swift b/glean-core/ios/Glean/Net/HttpPingUploader.swift index 8213472c50..9d8a8e7580 100644 --- a/glean-core/ios/Glean/Net/HttpPingUploader.swift +++ b/glean-core/ios/Glean/Net/HttpPingUploader.swift @@ -33,6 +33,15 @@ public class HttpPingUploader { self.config = configuration } + /// Launch a new ping uploader on the background thread. + /// + /// This function doesn't block. + static func launch(configuration: Configuration) { + Dispatchers.shared.launchConcurrent { + HttpPingUploader(configuration: configuration).process() + } + } + /// Synchronously upload a ping to Mozilla servers. /// /// - parameters: