Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1668820 - Always launch the ping uploader on a background thread #1252

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions glean-core/ios/Glean/Glean.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!)
}
}
}
Expand Down Expand Up @@ -456,7 +454,7 @@ public class Glean {

if submittedPing != 0 {
if let config = self.configuration {
HttpPingUploader(configuration: config).process()
HttpPingUploader.launch(configuration: config)
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions glean-core/ios/Glean/Net/HttpPingUploader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down