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

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

Issue 2763613004: Use std::unique_ptr for access to BackgroundFetchJobInfo (Closed)
Patch Set: Missed one 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_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 cf277010a74f316a6700fdcdcea8481fd29a9aee..f47bac8d0c80d83a4419f7bb94ee82ae3137b83a 100644
--- a/content/browser/background_fetch/background_fetch_data_manager.cc
+++ b/content/browser/background_fetch/background_fetch_data_manager.cc
@@ -21,35 +21,37 @@ BackgroundFetchDataManager::~BackgroundFetchDataManager() = default;
std::unique_ptr<BackgroundFetchJobData>
BackgroundFetchDataManager::CreateRequest(
- const BackgroundFetchJobInfo& job_info,
+ std::unique_ptr<BackgroundFetchJobInfo> job_info,
BackgroundFetchRequestInfos request_infos) {
- JobIdentifier id(job_info.service_worker_registration_id(), job_info.tag());
+ 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()) {
- DVLOG(1) << "Origin " << job_info.origin()
+ DVLOG(1) << "Origin " << job_info->origin()
<< " has already created a batch request with tag "
- << job_info.tag();
+ << job_info->tag();
// 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();
- WriteJobToStorage(job_info, std::move(request_infos));
+ const std::string job_guid = job_info->guid();
+ service_worker_tag_map_[id] = job_guid;
+ WriteJobToStorage(std::move(job_info), std::move(request_infos));
// TODO(harkness): Remove data when the job is complete.
return base::MakeUnique<BackgroundFetchJobData>(
- ReadRequestsFromStorage(job_info.guid()));
+ ReadRequestsFromStorage(job_guid));
}
void BackgroundFetchDataManager::WriteJobToStorage(
- const BackgroundFetchJobInfo& job_info,
+ std::unique_ptr<BackgroundFetchJobInfo> job_info,
BackgroundFetchRequestInfos request_infos) {
// TODO(harkness): Replace these maps with actually writing to storage.
// TODO(harkness): Check for job_guid clash.
- job_map_[job_info.guid()] = job_info;
- request_map_[job_info.guid()] = std::move(request_infos);
+ const std::string job_guid = job_info->guid();
+ job_map_[job_guid] = std::move(job_info);
+ request_map_[job_guid] = std::move(request_infos);
}
// TODO(harkness): This should be changed to read (and cache) small numbers of

Powered by Google App Engine
This is Rietveld 408576698