| 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 8726d1b36ce787f40572892613c76dd63eb925fd..51712c74b24189258ffdc5cf3f6b8f09ef0d6593 100644
|
| --- a/content/browser/background_fetch/background_fetch_job_controller.cc
|
| +++ b/content/browser/background_fetch/background_fetch_job_controller.cc
|
| @@ -5,10 +5,11 @@
|
| #include "content/browser/background_fetch/background_fetch_job_controller.h"
|
|
|
| #include <string>
|
| -#include <vector>
|
|
|
| #include "base/bind.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "content/browser/background_fetch/background_fetch_job_data.h"
|
| +#include "content/browser/background_fetch/background_fetch_request_info.h"
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/download_manager.h"
|
| @@ -17,37 +18,38 @@
|
| namespace content {
|
|
|
| BackgroundFetchJobController::BackgroundFetchJobController(
|
| + const std::string& job_guid,
|
| BrowserContext* browser_context,
|
| - StoragePartition* storage_partition)
|
| + StoragePartition* storage_partition,
|
| + std::unique_ptr<BackgroundFetchJobData> job_data)
|
| : browser_context_(browser_context),
|
| - storage_partition_(storage_partition) {}
|
| + storage_partition_(storage_partition),
|
| + job_data_(std::move(job_data)) {}
|
|
|
| BackgroundFetchJobController::~BackgroundFetchJobController() = default;
|
|
|
| -void BackgroundFetchJobController::ProcessJob(
|
| - const std::string& job_guid,
|
| - BackgroundFetchJobData* job_data) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| - DCHECK(job_data);
|
| +void BackgroundFetchJobController::Shutdown() {
|
| + // TODO(harkness): Remove any observers.
|
| + // TODO(harkness): Write final status to the DataManager. After this call, the
|
| + // |job_data_| is no longer valid.
|
| + job_data_.reset(nullptr);
|
| +}
|
| +
|
| +void BackgroundFetchJobController::StartProcessing() {
|
| + DCHECK(job_data_);
|
| +
|
| const BackgroundFetchRequestInfo& fetch_request =
|
| - job_data->GetNextBackgroundFetchRequestInfo();
|
| - ProcessRequest(job_guid, fetch_request);
|
| + job_data_->GetNextBackgroundFetchRequestInfo();
|
| + ProcessRequest(fetch_request);
|
|
|
| // Currently this only supports jobs of size 1.
|
| // TODO(crbug.com/692544)
|
| - DCHECK(!job_data->HasRequestsRemaining());
|
| -
|
| - // TODO(harkness): Save the BackgroundFetchJobData so that when the download
|
| - // completes we can notify the DataManager.
|
| + DCHECK(!job_data_->HasRequestsRemaining());
|
| }
|
|
|
| void BackgroundFetchJobController::ProcessRequest(
|
| - const std::string& job_guid,
|
| const BackgroundFetchRequestInfo& fetch_request) {
|
| - // First add the new request to the internal map tracking in-progress
|
| - // requests.
|
| - fetch_map_[job_guid] = fetch_request;
|
| -
|
| + // TODO(harkness): Start the observer watching for this download.
|
| // TODO(harkness): Check if the download is already in progress or completed.
|
|
|
| // Send the fetch request to the DownloadManager.
|
|
|