Skip to content

Commit

Permalink
Merge pull request #1252 from mozilla/ios/async-upload-processing
Browse files Browse the repository at this point in the history
Bug 1668820 - Always launch the ping uploader on a background thread
  • Loading branch information
badboy authored Oct 9, 2020
2 parents eda285f + 94169de commit e83abba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
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

0 comments on commit e83abba

Please sign in to comment.