Skip to content

Commit

Permalink
Give Background Fetch's totalDownloadSize plumbing some more bits
Browse files Browse the repository at this point in the history
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 <avi@chromium.org>
Reviewed-by: Mugdha Lakhani <nator@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612684}
  • Loading branch information
beverloo authored and Commit Bot committed Nov 30, 2018
1 parent e079bf4 commit 9448fce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> active_guids;
active_guids.reserve(active_fetch_requests.size());
for (const auto& request_info : active_fetch_requests)
Expand All @@ -112,7 +109,7 @@ void BackgroundFetchJobController::InitializeRequestStatus(
auto fetch_description = std::make_unique<BackgroundFetchDescription>(
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),
Expand Down Expand Up @@ -198,7 +195,7 @@ std::unique_ptr<BackgroundFetchRegistration>
BackgroundFetchJobController::NewRegistration() const {
return std::make_unique<BackgroundFetchRegistration>(
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_);
}
Expand Down
15 changes: 0 additions & 15 deletions content/browser/background_fetch/background_fetch_job_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,6 @@ class CONTENT_EXPORT BackgroundFetchJobController
// created with member fields.
std::unique_ptr<BackgroundFetchRegistration> 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_;
}
Expand Down Expand Up @@ -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_;

Expand Down
4 changes: 2 additions & 2 deletions content/public/browser/background_fetch_description.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> outstanding_guids,
bool start_paused)
: job_unique_id(job_unique_id),
Expand Down
10 changes: 6 additions & 4 deletions content/public/browser/background_fetch_description.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#ifndef CONTENT_PUBLIC_BROWSER_BACKGROUND_FETCH_DESCRIPTION_H_
#define CONTENT_PUBLIC_BROWSER_BACKGROUND_FETCH_DESCRIPTION_H_

#include <stdint.h>
#include <vector>

#include "content/common/content_export.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "url/origin.h"
Expand All @@ -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<std::string> outstanding_guids,
bool start_paused);
~BackgroundFetchDescription();
Expand All @@ -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<std::string> outstanding_guids;
bool start_paused;

Expand Down

0 comments on commit 9448fce

Please sign in to comment.