forked from mozilla-mobile/android-components
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes mozilla-mobile#4282: Migrate feature-downloads to use browser-…
…state.
- Loading branch information
Showing
19 changed files
with
390 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...feature/downloads/src/main/java/mozilla/components/feature/downloads/DownloadsUseCases.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package mozilla.components.feature.downloads | ||
|
||
import mozilla.components.browser.session.Download | ||
import mozilla.components.browser.session.Session | ||
import mozilla.components.browser.session.SessionManager | ||
|
||
/** | ||
* Contains use cases related to the downloads feature. | ||
* | ||
* @param sessionManager the application's [SessionManager]. | ||
*/ | ||
class DownloadsUseCases( | ||
sessionManager: SessionManager | ||
) { | ||
class ConsumeDownloadUseCase( | ||
private val sessionManager: SessionManager | ||
) { | ||
/** | ||
* Consumes the [Download] with the given [downloadId] from the [Session] with the given | ||
* [tabId]. | ||
*/ | ||
operator fun invoke(tabId: String, downloadId: String) { | ||
sessionManager.findSessionById(tabId)?.let { session -> | ||
session.download.consume { | ||
it.id == downloadId | ||
} | ||
} | ||
} | ||
} | ||
|
||
val consumeDownload = ConsumeDownloadUseCase(sessionManager) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.