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

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

Issue 2824223002: Fire the `backgroundfetchabort` event for aborted fetches (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/background_fetch/background_fetch_context.cc
diff --git a/content/browser/background_fetch/background_fetch_context.cc b/content/browser/background_fetch/background_fetch_context.cc
index f27666efc7abae886b1838eaba08b7b4ed69fa96..0cd4861f823db9eb34539c4d544d8642f202e460 100644
--- a/content/browser/background_fetch/background_fetch_context.cc
+++ b/content/browser/background_fetch/background_fetch_context.cc
@@ -171,23 +171,27 @@ void BackgroundFetchContext::DidCompleteJob(
controller->registration_id();
DCHECK_GT(active_fetches_.count(registration_id), 0u);
-
- // TODO(peter): Fire `backgroundfetchabort` if the |controller|'s state is
- // ABORTED, which does not require a sequence of the settled fetches.
-
- // The `backgroundfetched` and/or `backgroundfetchfail` event will only be
- // invoked for Background Fetch jobs which have been completed.
- if (controller->state() != BackgroundFetchJobController::State::COMPLETED) {
- DeleteRegistration(registration_id,
- std::vector<std::unique_ptr<BlobHandle>>());
- return;
+ switch (controller->state()) {
+ case BackgroundFetchJobController::State::ABORTED:
+ event_dispatcher_->DispatchBackgroundFetchAbortEvent(
+ registration_id,
+ base::Bind(&BackgroundFetchContext::DeleteRegistration, this,
+ registration_id,
+ std::vector<std::unique_ptr<BlobHandle>>()));
+ return;
+ case BackgroundFetchJobController::State::COMPLETED:
+ data_manager_->GetSettledFetchesForRegistration(
+ registration_id,
+ base::BindOnce(&BackgroundFetchContext::DidGetSettledFetches, this,
+ registration_id));
+ return;
+ case BackgroundFetchJobController::State::INITIALIZED:
+ case BackgroundFetchJobController::State::FETCHING:
+ // These cases should not happen. Fall through to the NOTREACHED() below.
+ break;
}
- // Get the sequence of settled fetches from the data manager.
- data_manager_->GetSettledFetchesForRegistration(
- registration_id,
- base::BindOnce(&BackgroundFetchContext::DidGetSettledFetches, this,
- registration_id));
+ NOTREACHED();
}
void BackgroundFetchContext::DidGetSettledFetches(
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698