Commit 08a92657 authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

[Background Fetch] Pass most recent title to Job Controller on creation

Bug: 853058
Change-Id: I4c816e84ca40c34d723043532c028a13f09e168e
Reviewed-on: https://chromium-review.googlesource.com/1133176
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574930}
parent bb90ca9f
......@@ -73,8 +73,8 @@ void BackgroundFetchContext::DidGetInitializationData(
for (auto& data : initialization_data) {
CreateController(data.registration_id, data.options, data.icon,
data.num_completed_requests, data.num_requests,
data.active_fetch_guids,
data.ui_title, data.num_completed_requests,
data.num_requests, data.active_fetch_guids,
std::make_unique<BackgroundFetchRegistration>(
std::move(data.registration)));
}
......@@ -179,7 +179,7 @@ void BackgroundFetchContext::DidCreateRegistration(
DCHECK(registration);
// Create the BackgroundFetchJobController to do the actual fetching.
CreateController(registration_id, options, icon,
CreateController(registration_id, options, icon, options.title,
0u /* num_completed_requests */, num_requests,
{} /* outstanding_guids */, std::move(registration));
}
......@@ -275,6 +275,7 @@ void BackgroundFetchContext::CreateController(
const BackgroundFetchRegistrationId& registration_id,
const BackgroundFetchOptions& options,
const SkBitmap& icon,
const std::string& ui_title,
size_t num_completed_requests,
size_t num_requests,
const std::vector<std::string>& outstanding_guids,
......@@ -292,7 +293,7 @@ void BackgroundFetchContext::CreateController(
base::Bind(&background_fetch::RecordSchedulerFinishedError)));
controller->InitializeRequestStatus(num_completed_requests, num_requests,
outstanding_guids);
outstanding_guids, ui_title);
scheduler_->AddJobController(controller.get());
job_controllers_.emplace(registration_id.unique_id(), std::move(controller));
......
......@@ -142,6 +142,7 @@ class CONTENT_EXPORT BackgroundFetchContext
const BackgroundFetchRegistrationId& registration_id,
const BackgroundFetchOptions& options,
const SkBitmap& icon,
const std::string& ui_title,
size_t num_completed_requests,
size_t num_requests,
const std::vector<std::string>& outstanding_guids,
......
......@@ -35,7 +35,8 @@ BackgroundFetchJobController::BackgroundFetchJobController(
void BackgroundFetchJobController::InitializeRequestStatus(
int completed_downloads,
int total_downloads,
const std::vector<std::string>& outstanding_guids) {
const std::vector<std::string>& outstanding_guids,
const std::string& ui_title) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Don't allow double initialization.
......@@ -49,7 +50,7 @@ void BackgroundFetchJobController::InitializeRequestStatus(
int total_downloads_size = options_.download_total;
auto fetch_description = std::make_unique<BackgroundFetchDescription>(
registration_id().unique_id(), options_.title, registration_id().origin(),
registration_id().unique_id(), ui_title, registration_id().origin(),
icon_, completed_downloads, total_downloads,
complete_requests_downloaded_bytes_cache_, total_downloads_size,
outstanding_guids);
......
......@@ -58,11 +58,13 @@ class CONTENT_EXPORT BackgroundFetchJobController final
~BackgroundFetchJobController() override;
// Initializes the job controller with the status of the active and completed
// downloads. Only called when this has been loaded from the database.
// downloads, as well as the title to use.
// Only called when this has been loaded from the database.
void InitializeRequestStatus(
int completed_downloads,
int total_downloads,
const std::vector<std::string>& outstanding_guids);
const std::vector<std::string>& outstanding_guids,
const std::string& ui_title);
// Gets the number of bytes downloaded for jobs that are currently running.
uint64_t GetInProgressDownloadedBytes();
......
......@@ -162,8 +162,8 @@ class BackgroundFetchJobControllerTest : public BackgroundFetchTestBase {
base::Unretained(this)),
base::BindOnce(&BackgroundFetchJobControllerTest::OnJobFinished));
controller->InitializeRequestStatus(0, total_downloads,
std::vector<std::string>());
controller->InitializeRequestStatus(
0, total_downloads, {} /* outstanding_guids */, "" /* ui_title */);
return controller;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment