Skip to content

Commit

Permalink
Post-rebase updates/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aataraxiaa committed May 10, 2024
1 parent 76dabb9 commit 6c4a23b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 179 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ extension OperationQueue: DataBrokerProtectionOperationQueue {}

enum DataBrokerProtectionQueueMode {
case idle
case immediate(completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
case scheduled(completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
case immediate(completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?)
case scheduled(completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?)

func canBeInterruptedBy(newMode: DataBrokerProtectionQueueMode) -> Bool {
switch (self, newMode) {
Expand All @@ -54,10 +54,10 @@ protocol DataBrokerProtectionQueueManager {

func startImmediateOperationsIfPermitted(showWebView: Bool,
operationDependencies: DataBrokerOperationDependencies,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?)
func startScheduledOperationsIfPermitted(showWebView: Bool,
operationDependencies: DataBrokerOperationDependencies,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?)

func stopAllOperations()
}
Expand Down Expand Up @@ -85,7 +85,7 @@ final class DefaultDataBrokerProtectionQueueManager: DataBrokerProtectionQueueMa

func startImmediateOperationsIfPermitted(showWebView: Bool,
operationDependencies: DataBrokerOperationDependencies,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) {
completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?) {

let newMode = DataBrokerProtectionQueueMode.immediate(completion: completion)
startOperationsIfPermitted(forNewMode: newMode,
Expand All @@ -99,7 +99,7 @@ final class DefaultDataBrokerProtectionQueueManager: DataBrokerProtectionQueueMa

func startScheduledOperationsIfPermitted(showWebView: Bool,
operationDependencies: DataBrokerOperationDependencies,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) {
completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?) {
let newMode = DataBrokerProtectionQueueMode.scheduled(completion: completion)
startOperationsIfPermitted(forNewMode: newMode,
type: .all,
Expand All @@ -119,7 +119,7 @@ private extension DefaultDataBrokerProtectionQueueManager {
type: OperationType,
showWebView: Bool,
operationDependencies: DataBrokerOperationDependencies,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) {
completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?) {

guard mode.canBeInterruptedBy(newMode: newMode) else {
completion?(nil)
Expand Down Expand Up @@ -149,7 +149,7 @@ private extension DefaultDataBrokerProtectionQueueManager {
priorityDate: Date? = nil,
showWebView: Bool,
operationDependencies: DataBrokerOperationDependencies,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) {
completion: ((DataBrokerProtectionAgentErrorCollection?) -> Void)?) {

// Update broker files if applicable
brokerUpdater?.checkForUpdatesInBrokerJSONFiles()
Expand All @@ -173,7 +173,7 @@ private extension DefaultDataBrokerProtectionQueueManager {
}
} catch {
os_log("DataBrokerProtectionProcessor error: addOperations, error: %{public}@", log: .error, error.localizedDescription)
completion?(DataBrokerProtectionSchedulerErrorCollection(oneTimeError: error))
completion?(DataBrokerProtectionAgentErrorCollection(oneTimeError: error))
return
}

Expand All @@ -183,8 +183,8 @@ private extension DefaultDataBrokerProtectionQueueManager {
}
}

func errorCollection() -> DataBrokerProtectionSchedulerErrorCollection? {
return operationErrors.count != 0 ? DataBrokerProtectionSchedulerErrorCollection(operationErrors: operationErrors) : nil
func errorCollection() -> DataBrokerProtectionAgentErrorCollection? {
return operationErrors.count != 0 ? DataBrokerProtectionAgentErrorCollection(operationErrors: operationErrors) : nil
}

func firePixels(operationDependencies: DataBrokerOperationDependencies) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class DataBrokerProtectionQueueManagerTests: XCTestCase {
let mockOperationsWithError = [3, 4].map { MockDataBrokerOperation(id: $0, operationType: .scan, errorDelegate: sut, shouldError: true, shouldSleep: false) }
mockOperationsCreator.operationCollections = mockOperations + mockOperationsWithError
let expectation = expectation(description: "Expected errors to be returned in completion")
var errorCollection: DataBrokerProtectionSchedulerErrorCollection!
var errorCollection: DataBrokerProtectionAgentErrorCollection!
let expectedConcurrentOperations = DataBrokerProtectionProcessorConfiguration().concurrentOperationsFor(.scan)

// When
Expand All @@ -89,7 +89,7 @@ final class DataBrokerProtectionQueueManagerTests: XCTestCase {
let mockOperationsWithError = [3, 4].map { MockDataBrokerOperation(id: $0, operationType: .scan, errorDelegate: sut, shouldError: true, shouldSleep: false) }
mockOperationsCreator.operationCollections = mockOperations + mockOperationsWithError
let expectation = expectation(description: "Expected errors to be returned in completion")
var errorCollection: DataBrokerProtectionSchedulerErrorCollection!
var errorCollection: DataBrokerProtectionAgentErrorCollection!
let expectedConcurrentOperations = DataBrokerProtectionProcessorConfiguration().concurrentOperationsFor(.all)

// When
Expand All @@ -114,7 +114,7 @@ final class DataBrokerProtectionQueueManagerTests: XCTestCase {
var mockOperations = (1...5).map { MockDataBrokerOperation(id: $0, operationType: .scan, errorDelegate: sut) }
let mockOperationsWithError = (6...10).map { MockDataBrokerOperation(id: $0, operationType: .scan, errorDelegate: sut, shouldError: true) }
mockOperationsCreator.operationCollections = mockOperations + mockOperationsWithError
var errorCollection: DataBrokerProtectionSchedulerErrorCollection!
var errorCollection: DataBrokerProtectionAgentErrorCollection!

// When
sut.startImmediateOperationsIfPermitted(showWebView: false, operationDependencies: mockDependencies) { errors in
Expand Down Expand Up @@ -147,7 +147,7 @@ final class DataBrokerProtectionQueueManagerTests: XCTestCase {
var mockOperations = (1...5).map { MockDataBrokerOperation(id: $0, operationType: .scan, errorDelegate: sut) }
var mockOperationsWithError = (6...10).map { MockDataBrokerOperation(id: $0, operationType: .scan, errorDelegate: sut, shouldError: true) }
mockOperationsCreator.operationCollections = mockOperations + mockOperationsWithError
var errorCollection: DataBrokerProtectionSchedulerErrorCollection!
var errorCollection: DataBrokerProtectionAgentErrorCollection!

// When
sut.startImmediateOperationsIfPermitted(showWebView: false, operationDependencies: mockDependencies) { _ in }
Expand Down Expand Up @@ -183,7 +183,7 @@ final class DataBrokerProtectionQueueManagerTests: XCTestCase {
mismatchCalculator: mockMismatchCalculator,
brokerUpdater: mockUpdater)
let expectation = expectation(description: "Expected completion to be called")
var errorCollection: DataBrokerProtectionSchedulerErrorCollection!
var errorCollection: DataBrokerProtectionAgentErrorCollection!

// When
sut.startImmediateOperationsIfPermitted(showWebView: false,
Expand All @@ -207,7 +207,7 @@ final class DataBrokerProtectionQueueManagerTests: XCTestCase {
let mockOperationsWithError = (6...10).map { MockDataBrokerOperation(id: $0, operationType: .scan, errorDelegate: sut, shouldError: true) }
mockOperationsCreator.operationCollections = mockOperations + mockOperationsWithError
let expectation = expectation(description: "Expected completion to be called")
var errorCollection: DataBrokerProtectionSchedulerErrorCollection!
var errorCollection: DataBrokerProtectionAgentErrorCollection!

// When
sut.startImmediateOperationsIfPermitted(showWebView: false,
Expand Down

0 comments on commit 6c4a23b

Please sign in to comment.