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 3a5661ce7a580307292f4da64045e66309b57498..3556abd40d66063075824fd0b5a8b6970501a5a0 100644 |
| --- a/content/browser/background_fetch/background_fetch_data_manager.cc |
| +++ b/content/browser/background_fetch/background_fetch_data_manager.cc |
| @@ -24,29 +24,33 @@ BackgroundFetchDataManager::BackgroundFetchDataManager( |
| BackgroundFetchDataManager::~BackgroundFetchDataManager() = default; |
| -void BackgroundFetchDataManager::CreateRequest( |
| - std::unique_ptr<BackgroundFetchJobInfo> job_info, |
| - BackgroundFetchRequestInfos request_infos) { |
| - BackgroundFetchRegistrationId registration_id( |
| - job_info->service_worker_registration_id(), job_info->origin(), |
| - job_info->tag()); |
| - |
| - // Ensure that this is not a duplicate request. |
| - if (known_registrations_.find(registration_id) != |
| - known_registrations_.end()) { |
| - DVLOG(1) << "Origin " << job_info->origin() |
| - << " has already created a batch request with tag " |
| - << job_info->tag(); |
| - // TODO(harkness) Figure out how to return errors like this. |
| +void BackgroundFetchDataManager::CreateRegistration( |
| + const BackgroundFetchRegistrationId& registration_id, |
| + const std::vector<ServiceWorkerFetchRequest>& requests, |
| + const BackgroundFetchOptions& options, |
| + CreateRegistrationCallback callback) { |
| + if (registrations_.find(registration_id) != registrations_.end()) { |
| + std::move(callback).Run(blink::mojom::BackgroundFetchError::DUPLICATED_TAG); |
| return; |
| } |
| - // Add the JobInfo to the in-memory map, and write the individual requests out |
| - // to storage. |
| - job_info->set_num_requests(request_infos.size()); |
| - const std::string job_guid = job_info->guid(); |
| - known_registrations_.insert(std::move(registration_id)); |
| - WriteJobToStorage(std::move(job_info), std::move(request_infos)); |
| + registrations_.insert(registration_id); |
| + |
|
harkness
2017/03/27 15:35:12
Can you put a TODO here for one of us to put the r
Peter Beverloo
2017/03/27 15:42:55
Done.
|
| + std::move(callback).Run(blink::mojom::BackgroundFetchError::NONE); |
| +} |
| + |
| +void BackgroundFetchDataManager::DeleteRegistration( |
| + const BackgroundFetchRegistrationId& registration_id, |
| + DeleteRegistrationCallback callback) { |
| + auto iter = registrations_.find(registration_id); |
| + if (iter == registrations_.end()) { |
| + std::move(callback).Run(blink::mojom::BackgroundFetchError::INVALID_TAG); |
| + return; |
| + } |
| + |
| + registrations_.erase(iter); |
| + |
| + std::move(callback).Run(blink::mojom::BackgroundFetchError::NONE); |
| } |
| void BackgroundFetchDataManager::WriteJobToStorage( |