Skip to content

Commit

Permalink
Remove unused runAllOperations from DataBrokerProtectionScheduler
Browse files Browse the repository at this point in the history
…, `IPCServerInterface`, and `XPCServerInterface` interfaces. Remove related Pixel.
  • Loading branch information
aataraxiaa committed May 3, 2024
1 parent 716c5c0 commit 16acb56
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 90 deletions.
4 changes: 0 additions & 4 deletions DuckDuckGo/DBP/DataBrokerProtectionLoginItemScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ extension DataBrokerProtectionLoginItemScheduler: DataBrokerProtectionScheduler
ipcScheduler.optOutAllBrokers(showWebView: showWebView, completion: completion)
}

func runAllOperations(showWebView: Bool) {
ipcScheduler.runAllOperations(showWebView: showWebView)
}

func runQueuedOperations(showWebView: Bool,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) {
ipcScheduler.runQueuedOperations(showWebView: showWebView, completion: completion)
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/DBP/DataBrokerProtectionPixelsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public class DataBrokerProtectionPixelsHandler: EventMapping<DataBrokerProtectio
.backgroundAgentStartedStoppingDueToAnotherInstanceRunning,
.ipcServerOptOutAllBrokers,
.ipcServerRunQueuedOperations,
.ipcServerRunAllOperations,
.scanSuccess,
.scanFailed,
.scanError,
Expand Down
5 changes: 0 additions & 5 deletions DuckDuckGoDBPBackgroundAgent/IPCServiceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ extension IPCServiceManager: IPCServerInterface {
}
}

func runAllOperations(showWebView: Bool) {
pixelHandler.fire(.ipcServerRunAllOperations)
scheduler.runAllOperations(showWebView: showWebView)
}

func openBrowser(domain: String) {
Task { @MainActor in
browserWindowManager.show(domain: domain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,7 @@ extension DataBrokerProtectionIPCClient: IPCServerInterface {
})
}

public func runAllOperations(showWebView: Bool) {
self.pixelHandler.fire(.ipcServerRunAllOperations)
xpc.execute(call: { server in
server.runAllOperations(showWebView: showWebView)
}, xpcReplyErrorHandler: { _ in
// Intentional no-op as there's no completion block
// If you add a completion block, please remember to call it here too!
})
}

public func openBrowser(domain: String) {
self.pixelHandler.fire(.ipcServerRunAllOperations)
xpc.execute(call: { server in
server.openBrowser(domain: domain)
}, xpcReplyErrorHandler: { error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public final class DataBrokerProtectionIPCScheduler: DataBrokerProtectionSchedul
ipcClient.runQueuedOperations(showWebView: showWebView, completion: completion)
}

public func runAllOperations(showWebView: Bool) {
ipcClient.runAllOperations(showWebView: showWebView)
}

public func getDebugMetadata(completion: @escaping (DBPBackgroundAgentMetadata?) -> Void) {
ipcClient.getDebugMetadata(completion: completion)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public protocol IPCServerInterface: AnyObject {
completion: @escaping ((DataBrokerProtectionSchedulerErrorCollection?) -> Void))
func runQueuedOperations(showWebView: Bool,
completion: @escaping ((DataBrokerProtectionSchedulerErrorCollection?) -> Void))
func runAllOperations(showWebView: Bool)

// MARK: - Debugging Features

Expand Down Expand Up @@ -141,7 +140,6 @@ protocol XPCServerInterface {
completion: @escaping ((DataBrokerProtectionSchedulerErrorCollection?) -> Void))
func runQueuedOperations(showWebView: Bool,
completion: @escaping ((DataBrokerProtectionSchedulerErrorCollection?) -> Void))
func runAllOperations(showWebView: Bool)

// MARK: - Debugging Features

Expand Down Expand Up @@ -226,10 +224,6 @@ extension DataBrokerProtectionIPCServer: XPCServerInterface {
serverDelegate?.runQueuedOperations(showWebView: showWebView, completion: completion)
}

func runAllOperations(showWebView: Bool) {
serverDelegate?.runAllOperations(showWebView: showWebView)
}

func openBrowser(domain: String) {
serverDelegate?.openBrowser(domain: domain)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public enum DataBrokerProtectionPixels {
case ipcServerOptOutAllBrokersCompletion(error: Error?)
case ipcServerRunQueuedOperations
case ipcServerRunQueuedOperationsCompletion(error: Error?)
case ipcServerRunAllOperations

// DataBrokerProtection User Notifications
case dataBrokerProtectionNotificationSentFirstScanComplete
Expand Down Expand Up @@ -247,7 +246,6 @@ extension DataBrokerProtectionPixels: PixelKitEvent {
case .ipcServerOptOutAllBrokersCompletion: return "m_mac_dbp_ipc-server_opt-out-all-brokers_completion"
case .ipcServerRunQueuedOperations: return "m_mac_dbp_ipc-server_run-queued-operations"
case .ipcServerRunQueuedOperationsCompletion: return "m_mac_dbp_ipc-server_run-queued-operations_completion"
case .ipcServerRunAllOperations: return "m_mac_dbp_ipc-server_run-all-operations"

// User Notifications
case .dataBrokerProtectionNotificationSentFirstScanComplete:
Expand Down Expand Up @@ -418,8 +416,7 @@ extension DataBrokerProtectionPixels: PixelKitEvent {
.ipcServerOptOutAllBrokers,
.ipcServerOptOutAllBrokersCompletion,
.ipcServerRunQueuedOperations,
.ipcServerRunQueuedOperationsCompletion,
.ipcServerRunAllOperations:
.ipcServerRunQueuedOperationsCompletion:
return [Consts.bundleIDParamKey: Bundle.main.bundleIdentifier ?? "nil"]
case .scanSuccess(let dataBroker, let matchesFound, let duration, let tries, let isManualScan):
return [Consts.dataBrokerParamKey: dataBroker, Consts.matchesFoundKey: String(matchesFound), Consts.durationParamKey: String(duration), Consts.triesKey: String(tries), Consts.isManualScan: isManualScan.description]
Expand Down Expand Up @@ -507,7 +504,6 @@ public class DataBrokerProtectionPixelsHandler: EventMapping<DataBrokerProtectio
.backgroundAgentStartedStoppingDueToAnotherInstanceRunning,
.ipcServerOptOutAllBrokers,
.ipcServerRunQueuedOperations,
.ipcServerRunAllOperations,
.scanSuccess,
.scanFailed,
.scanError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ final class DataBrokerProtectionNoOpScheduler: DataBrokerProtectionScheduler {
func runQueuedOperations(showWebView: Bool,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) { }
func startManualScan(showWebView: Bool, startTime: Date, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) { }
func runAllOperations(showWebView: Bool) { }
func getDebugMetadata(completion: (DBPBackgroundAgentMetadata?) -> Void) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ final class DataBrokerProtectionProcessor {
}
}

func runAllOperations(showWebView: Bool = false,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)? = nil ) {
runOperations(operationType: .all,
priorityDate: nil,
showWebView: showWebView) { errors in
os_log("Queued operations done", log: .dataBrokerProtection)
completion?(errors)
}
}

func stopAllOperations() {
operationQueue.cancelAllOperations()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ protocol DataBrokerProtectionQueueManager {
func startManualScans(showWebView: Bool, operationDependencies: OperationDependencies, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
func runAllOptOutOperations(showWebView: Bool, operationDependencies: OperationDependencies, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
func runQueuedOperations(showWebView: Bool, operationDependencies: OperationDependencies, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
func runAllOperations(showWebView: Bool, operationDependencies: OperationDependencies, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
func stopAllOperations()
}

Expand Down Expand Up @@ -120,19 +119,6 @@ final class DefaultDataBrokerProtectionQueueManager: DataBrokerProtectionQueueMa
}
}

func runAllOperations(showWebView: Bool, operationDependencies: OperationDependencies, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?) {

guard mode.canInterrupt(forNewMode: .queued) else { return }
mode = .queued

addOperationCollections(withType: .all,
showWebView: showWebView,
operationDependencies: operationDependencies) { errors in
os_log("All operations completed", log: .dataBrokerProtection)
completion?(errors)
}
}

func stopAllOperations() {
operationQueue.cancelAllOperations()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public protocol DataBrokerProtectionScheduler {
func optOutAllBrokers(showWebView: Bool, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
func startManualScan(showWebView: Bool, startTime: Date, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
func runQueuedOperations(showWebView: Bool, completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)?)
func runAllOperations(showWebView: Bool)

/// Debug operations

Expand All @@ -94,10 +93,6 @@ extension DataBrokerProtectionScheduler {
startScheduler(showWebView: false)
}

public func runAllOperations() {
runAllOperations(showWebView: false)
}

public func startManualScan(startTime: Date) {
startManualScan(showWebView: false, startTime: startTime, completion: nil)
}
Expand Down Expand Up @@ -247,30 +242,6 @@ public final class DefaultDataBrokerProtectionScheduler: DataBrokerProtectionSch
self.queueManager.stopAllOperations()
}

public func runAllOperations(showWebView: Bool = false) {
guard self.currentOperation != .manualScan else {
os_log("Manual scan in progress, returning...", log: .dataBrokerProtection)
return
}

os_log("Running all operations...", log: .dataBrokerProtection)
self.currentOperation = .all
queueManager.runAllOperations(showWebView: showWebView,
operationDependencies: operationDependencies) { [weak self] errors in
if let errors = errors {
if let oneTimeError = errors.oneTimeError {
os_log("Error during DefaultDataBrokerProtectionScheduler.runAllOperations in dataBrokerProcessor.runAllOperations(), error: %{public}@", log: .dataBrokerProtection, oneTimeError.localizedDescription)
self?.pixelHandler.fire(.generalError(error: oneTimeError, functionOccurredIn: "DefaultDataBrokerProtectionScheduler.runAllOperations"))
}
if let operationErrors = errors.operationErrors,
operationErrors.count != 0 {
os_log("Operation error(s) during DefaultDataBrokerProtectionScheduler.runAllOperations in dataBrokerProcessor.runAllOperations(), count: %{public}d", log: .dataBrokerProtection, operationErrors.count)
}
}
self?.currentOperation = .idle
}
}

public func runQueuedOperations(showWebView: Bool = false,
completion: ((DataBrokerProtectionSchedulerErrorCollection?) -> Void)? = nil) {
guard self.currentOperation != .manualScan else {
Expand Down

0 comments on commit 16acb56

Please sign in to comment.