Chromium Code Reviews| Index: content/browser/background_fetch/background_fetch_data_manager.cc |
| diff --git a/content/browser/background_fetch/background_fetch_data_manager.cc b/content/browser/background_fetch/background_fetch_data_manager.cc |
| index 06a82d4d31bbe50e3dc5b571bb0faabaf35dac1e..10512c711219aee92dcc0038153bfbf4d0822a9e 100644 |
| --- a/content/browser/background_fetch/background_fetch_data_manager.cc |
| +++ b/content/browser/background_fetch/background_fetch_data_manager.cc |
| @@ -4,8 +4,10 @@ |
| #include "content/browser/background_fetch/background_fetch_data_manager.h" |
| +#include "base/memory/ptr_util.h" |
| #include "content/browser/background_fetch/background_fetch_context.h" |
| -#include "content/browser/background_fetch/fetch_request.h" |
| +#include "content/browser/background_fetch/background_fetch_job_info.h" |
| +#include "content/browser/background_fetch/background_fetch_request_info.h" |
| namespace content { |
| @@ -16,20 +18,32 @@ BackgroundFetchDataManager::BackgroundFetchDataManager( |
| // TODO(harkness) Read from persistent storage and recreate requests. |
| } |
| -BackgroundFetchDataManager::~BackgroundFetchDataManager() {} |
| +BackgroundFetchDataManager::~BackgroundFetchDataManager() = default; |
| -void BackgroundFetchDataManager::CreateRequest( |
| - const FetchRequest& fetch_request) { |
| - FetchIdentifier id(fetch_request.service_worker_registration_id(), |
| - fetch_request.tag()); |
| - if (fetch_map_.find(id) != fetch_map_.end()) { |
| - DLOG(ERROR) << "Origin " << fetch_request.origin() |
| - << " has already created a fetch request with tag " |
| - << fetch_request.tag(); |
| +BackgroundFetchJobData* BackgroundFetchDataManager::CreateRequest( |
| + const BackgroundFetchJobInfo& job_info, |
| + BackgroundFetchRequestInfos& request_infos) { |
| + JobIdentifier id(job_info.service_worker_registration_id(), job_info.tag()); |
| + // Ensure that this is not a duplicate request. |
| + if (service_worker_tag_map_.find(id) != service_worker_tag_map_.end()) { |
| + DLOG(ERROR) << "Origin " << job_info.origin() |
| + << " has already created a batch request with tag " |
| + << job_info.tag(); |
|
Peter Beverloo
2017/02/28 03:32:54
nit: We probably should move to DVLOG at some poin
harkness
2017/02/28 11:31:08
Done.
|
| // TODO(harkness) Figure out how to return errors like this. |
| - return; |
| + return nullptr; |
| } |
| - fetch_map_[id] = fetch_request; |
| + if (batch_map_.find(job_info.guid()) != batch_map_.end()) { |
| + DLOG(ERROR) << "Job with UID " << job_info.guid() << " already exists."; |
| + // TODO(harkness) Figure out how to return errors like this. |
| + return nullptr; |
| + } |
| + |
| + // Add the request to our maps and return a JobData to track the individual |
| + // files in the request. |
| + service_worker_tag_map_[id] = job_info.guid(); |
| + batch_map_[job_info.guid()] = |
|
Peter Beverloo
2017/02/28 03:32:54
note: We need to remove data from the batch_map_ a
harkness
2017/02/28 11:31:08
TODO added.
|
| + base::MakeUnique<BackgroundFetchJobData>(request_infos); |
|
Peter Beverloo
2017/02/28 03:32:54
std::move(), and pass by value to the constructor
harkness
2017/02/28 11:31:08
Done. I think I've got too many std::moves here, b
|
| + return batch_map_[job_info.guid()].get(); |
| } |
| } // namespace content |