From 9448fce7150939f78f300f0596bec23e81aa998e Mon Sep 17 00:00:00 2001 From: Peter Beverloo Date: Fri, 30 Nov 2018 17:36:19 +0000 Subject: [PATCH] Give Background Fetch's `totalDownloadSize` plumbing some more bits The spec defines it to be an unsigned long long (uint64_t in Chromium), so let's make sure all the plumbing agrees with that. Change-Id: I9c22d4a197d726c276b3e69818276a4d149c68c8 Reviewed-on: https://chromium-review.googlesource.com/c/1356709 Reviewed-by: Avi Drissman Reviewed-by: Mugdha Lakhani Commit-Queue: Mugdha Lakhani Cr-Commit-Position: refs/heads/master@{#612684} --- .../background_fetch_job_controller.cc | 7 ++----- .../background_fetch_job_controller.h | 15 --------------- .../browser/background_fetch_description.cc | 4 ++-- .../public/browser/background_fetch_description.h | 10 ++++++---- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/content/browser/background_fetch/background_fetch_job_controller.cc b/content/browser/background_fetch/background_fetch_job_controller.cc index c10270162a0e3..483965d3a894d 100644 --- a/content/browser/background_fetch/background_fetch_job_controller.cc +++ b/content/browser/background_fetch/background_fetch_job_controller.cc @@ -101,9 +101,6 @@ void BackgroundFetchJobController::InitializeRequestStatus( completed_downloads_ = completed_downloads; total_downloads_ = total_downloads; - // TODO(nator): Update this when we support uploads. - total_downloads_size_ = options_.download_total; - std::vector active_guids; active_guids.reserve(active_fetch_requests.size()); for (const auto& request_info : active_fetch_requests) @@ -112,7 +109,7 @@ void BackgroundFetchJobController::InitializeRequestStatus( auto fetch_description = std::make_unique( registration_id().unique_id(), options_.title, registration_id().origin(), icon_, completed_downloads, total_downloads, - complete_requests_downloaded_bytes_cache_, total_downloads_size_, + complete_requests_downloaded_bytes_cache_, options_.download_total, std::move(active_guids), start_paused); delegate_proxy_->CreateDownloadJob(GetWeakPtr(), std::move(fetch_description), @@ -198,7 +195,7 @@ std::unique_ptr BackgroundFetchJobController::NewRegistration() const { return std::make_unique( registration_id().developer_id(), registration_id().unique_id(), - 0 /* upload_total */, 0 /* uploaded */, total_downloads_size_, + 0 /* upload_total */, 0 /* uploaded */, options_.download_total, complete_requests_downloaded_bytes_cache_, blink::mojom::BackgroundFetchResult::UNSET, failure_reason_); } diff --git a/content/browser/background_fetch/background_fetch_job_controller.h b/content/browser/background_fetch/background_fetch_job_controller.h index e48e6f2488581..0fad34b5f6c2a 100644 --- a/content/browser/background_fetch/background_fetch_job_controller.h +++ b/content/browser/background_fetch/background_fetch_job_controller.h @@ -79,18 +79,6 @@ class CONTENT_EXPORT BackgroundFetchJobController // created with member fields. std::unique_ptr NewRegistration() const; - // Returns the options with which this job is fetching data. - const BackgroundFetchOptions& options() const { return options_; } - - // Returns total downloaded bytes. - int downloaded() const { return complete_requests_downloaded_bytes_cache_; } - - // Returns total size of downloads, as indicated by the developer. - int download_total() const { return total_downloads_size_; } - - // Returns the number of requests that comprise the whole job. - int total_downloads() const { return total_downloads_; } - const BackgroundFetchRegistrationId& registration_id() const { return registration_id_; } @@ -171,9 +159,6 @@ class CONTENT_EXPORT BackgroundFetchJobController // delivering progress events without having to read from the database. uint64_t complete_requests_downloaded_bytes_cache_; - // Total downloads size, as indicated by the developer. - int total_downloads_size_ = 0; - // Callback run each time download progress updates. ProgressCallback progress_callback_; diff --git a/content/public/browser/background_fetch_description.cc b/content/public/browser/background_fetch_description.cc index cc3b5af2f24d4..178015204c6bd 100644 --- a/content/public/browser/background_fetch_description.cc +++ b/content/public/browser/background_fetch_description.cc @@ -13,8 +13,8 @@ BackgroundFetchDescription::BackgroundFetchDescription( SkBitmap icon, int completed_parts, int total_parts, - int completed_parts_size, - int total_parts_size, + uint64_t completed_parts_size, + uint64_t total_parts_size, std::vector outstanding_guids, bool start_paused) : job_unique_id(job_unique_id), diff --git a/content/public/browser/background_fetch_description.h b/content/public/browser/background_fetch_description.h index be9984d3cb14e..5d5d9efe93d3e 100644 --- a/content/public/browser/background_fetch_description.h +++ b/content/public/browser/background_fetch_description.h @@ -5,7 +5,9 @@ #ifndef CONTENT_PUBLIC_BROWSER_BACKGROUND_FETCH_DESCRIPTION_H_ #define CONTENT_PUBLIC_BROWSER_BACKGROUND_FETCH_DESCRIPTION_H_ +#include #include + #include "content/common/content_export.h" #include "third_party/skia/include/core/SkBitmap.h" #include "url/origin.h" @@ -21,8 +23,8 @@ struct CONTENT_EXPORT BackgroundFetchDescription { SkBitmap icon, int completed_parts, int total_parts, - int completed_parts_size, - int total_parts_size, + uint64_t completed_parts_size, + uint64_t total_parts_size, std::vector outstanding_guids, bool start_paused); ~BackgroundFetchDescription(); @@ -33,8 +35,8 @@ struct CONTENT_EXPORT BackgroundFetchDescription { SkBitmap icon; int completed_parts; int total_parts; - int completed_parts_size; - int total_parts_size; + uint64_t completed_parts_size; + uint64_t total_parts_size; std::vector outstanding_guids; bool start_paused;