Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: content/browser/background_fetch/background_fetch_job_controller.cc

Issue 2776353004: Give the BackgroundFetchJobController a simple state. (Closed)
Patch Set: comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/background_fetch/background_fetch_job_controller.cc
diff --git a/content/browser/background_fetch/background_fetch_job_controller.cc b/content/browser/background_fetch/background_fetch_job_controller.cc
index 088e04232b0f7e06ac2b96db97c748ead6c4b6a2..b0bbf35aa2161d7e7cd6a5bceed63bca3ae374d3 100644
--- a/content/browser/background_fetch/background_fetch_job_controller.cc
+++ b/content/browser/background_fetch/background_fetch_job_controller.cc
@@ -57,6 +57,8 @@ void BackgroundFetchJobController::Shutdown() {
void BackgroundFetchJobController::StartProcessing() {
DCHECK(data_manager_);
+ state_ = State::FETCHING;
+
const BackgroundFetchRequestInfo& fetch_request =
data_manager_->GetNextBackgroundFetchRequestInfo(job_guid_);
ProcessRequest(fetch_request);
@@ -71,8 +73,9 @@ void BackgroundFetchJobController::UpdateUI(const std::string& title) {
void BackgroundFetchJobController::Abort() {
// TODO(harkness): Abort all in-progress downloads.
- std::move(completed_callback_)
- .Run(registration_id_, true /* aborted_by_developer */);
+ state_ = State::ABORTED;
+
+ std::move(completed_callback_).Run(this);
}
void BackgroundFetchJobController::DownloadStarted(
@@ -114,8 +117,8 @@ void BackgroundFetchJobController::OnDownloadUpdated(DownloadItem* item) {
ProcessRequest(
data_manager_->GetNextBackgroundFetchRequestInfo(job_guid_));
} else if (data_manager_->IsComplete(job_guid_)) {
- std::move(completed_callback_)
- .Run(registration_id_, false /* aborted_by_developer */);
+ state_ = State::COMPLETED;
+ std::move(completed_callback_).Run(this);
}
break;
case DownloadItem::DownloadState::INTERRUPTED:

Powered by Google App Engine
This is Rietveld 408576698