Chromium Code Reviews| 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..a0ae98ba055ebeb11931262e91d74f390aba3e8c 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)) { |
|
Peter Beverloo
2017/03/16 12:37:10
Could we have a switch() w/o a default: state to p
harkness
2017/03/17 11:14:11
Done.
|
| + request_info_index_.erase(index_iter); |
| + } |
| // 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_EQ(next_request.state(), |
| + DownloadItem::DownloadState::MAX_DOWNLOAD_STATE); |
| request_info_index_[next_request.guid()] = next_request_info_++; |
| return next_request; |