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

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

Issue 2753583002: Add the JobComplete callback and error/interrupt information (Closed)
Patch Set: Missed two files because of rebasing, oops. 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_data.cc
diff --git a/content/browser/background_fetch/background_fetch_job_data.cc b/content/browser/background_fetch/background_fetch_job_data.cc
index 005780c31e05c08a3b7bb04d40bc274e3025a2fe..7fcc82a9d545136c5da480a5fa48604ed7ecf7ca 100644
--- a/content/browser/background_fetch/background_fetch_job_data.cc
+++ b/content/browser/background_fetch/background_fetch_job_data.cc
@@ -15,18 +15,24 @@ BackgroundFetchJobData::BackgroundFetchJobData(
BackgroundFetchJobData::~BackgroundFetchJobData() {}
-// TODO(harkness): Provide more detail about status and where the returned data
-// is now available.
-bool BackgroundFetchJobData::BackgroundFetchRequestInfoComplete(
- const std::string& fetch_guid) {
+bool BackgroundFetchJobData::UpdateBackgroundFetchRequestState(
+ const std::string& fetch_guid,
+ DownloadItem::DownloadState state,
+ DownloadInterruptReason interrupt_reason) {
// Make sure that the request was expected to be in-progress.
auto index_iter = request_info_index_.find(fetch_guid);
DCHECK(index_iter != request_info_index_.end());
DCHECK_EQ(fetch_guid, request_infos_[index_iter->second].guid());
- // Set the request as complete and delete it from the in-progress index.
- request_infos_[index_iter->second].set_complete(true);
- request_info_index_.erase(index_iter);
+ // Set the state of the request and the interrupt reason.
+ request_infos_[index_iter->second].set_state(state);
+ request_infos_[index_iter->second].set_interrupt_reason(interrupt_reason);
+
+ // If the new state is complete or cancelled, remove the in-progress request.
+ if ((state == DownloadItem::DownloadState::COMPLETE) ||
+ (state == DownloadItem::DownloadState::CANCELLED)) {
+ request_info_index_.erase(index_iter);
Peter Beverloo 2017/03/15 16:53:38 Are we certain that this will continue to be synch
harkness 2017/03/16 11:41:09 In the future, the JobData might fire off an async
+ }
// Return a boolean indicating whether there are more requests to be
// processed.
@@ -39,7 +45,8 @@ BackgroundFetchJobData::GetNextBackgroundFetchRequestInfo() {
const BackgroundFetchRequestInfo& next_request =
request_infos_[next_request_info_];
- DCHECK(!next_request.complete());
+ DCHECK(next_request.state() ==
Peter Beverloo 2017/03/15 16:53:38 DCHECK_EQ
harkness 2017/03/16 11:41:09 Done.
+ DownloadItem::DownloadState::MAX_DOWNLOAD_STATE);
request_info_index_[next_request.guid()] = next_request_info_++;
return next_request;

Powered by Google App Engine
This is Rietveld 408576698