Make UrlLoader::GetDownloadProgress() null-safe
Changes chrome_pdf::UrlLoader::GetDownloadProgress() to take mutable reference parameters, rather than pointers to int64_t. Bug: 1099022 Change-Id: Ia6ab2fe8a2bdfa1909b06534647a226982c246ba Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2381251 Commit-Queue: K. Moon <kmoon@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#802559}
This commit is contained in:
@ -110,8 +110,8 @@ bool DocumentLoaderImpl::Init(std::unique_ptr<URLLoaderWrapper> loader,
|
||||
int64_t bytes_received = 0;
|
||||
int64_t total_bytes_to_be_received = 0;
|
||||
if (GetDocumentSize() == 0 &&
|
||||
loader_->GetDownloadProgress(&bytes_received,
|
||||
&total_bytes_to_be_received)) {
|
||||
loader_->GetDownloadProgress(bytes_received,
|
||||
total_bytes_to_be_received)) {
|
||||
chunk_stream_.set_eof_pos(
|
||||
std::max(0, static_cast<int>(total_bytes_to_be_received)));
|
||||
}
|
||||
|
@ -188,8 +188,8 @@ class TestURLLoader : public URLLoaderWrapper {
|
||||
data_->SetReadCallback(std::move(callback), buffer, buffer_size);
|
||||
}
|
||||
|
||||
bool GetDownloadProgress(int64_t* bytes_received,
|
||||
int64_t* total_bytes_to_be_received) const override {
|
||||
bool GetDownloadProgress(int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -78,10 +78,10 @@ void UrlLoader::Open(const UrlRequest& request, ResultCallback callback) {
|
||||
pp_callback.Run(result);
|
||||
}
|
||||
|
||||
bool UrlLoader::GetDownloadProgress(int64_t* bytes_received,
|
||||
int64_t* total_bytes_to_be_received) const {
|
||||
return pepper_loader_.GetDownloadProgress(bytes_received,
|
||||
total_bytes_to_be_received);
|
||||
bool UrlLoader::GetDownloadProgress(int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const {
|
||||
return pepper_loader_.GetDownloadProgress(&bytes_received,
|
||||
&total_bytes_to_be_received);
|
||||
}
|
||||
|
||||
void UrlLoader::ReadResponseBody(base::span<char> buffer,
|
||||
|
@ -81,8 +81,8 @@ class UrlLoader : public base::RefCounted<UrlLoader> {
|
||||
|
||||
// Mimic `pp::URLLoader`:
|
||||
void Open(const UrlRequest& request, ResultCallback callback);
|
||||
bool GetDownloadProgress(int64_t* bytes_received,
|
||||
int64_t* total_bytes_to_be_received) const;
|
||||
bool GetDownloadProgress(int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const;
|
||||
const UrlResponse& response() const { return response_; }
|
||||
void ReadResponseBody(base::span<char> buffer, ResultCallback callback);
|
||||
void Close();
|
||||
|
@ -64,8 +64,8 @@ class URLLoaderWrapper {
|
||||
// If false, progress is unknown, bytes_received/total_bytes_to_be_received
|
||||
// will be undefined.
|
||||
virtual bool GetDownloadProgress(
|
||||
int64_t* bytes_received,
|
||||
int64_t* total_bytes_to_be_received) const = 0;
|
||||
int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const = 0;
|
||||
};
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -143,8 +143,8 @@ bool URLLoaderWrapperImpl::GetByteRangeStart(int* start) const {
|
||||
}
|
||||
|
||||
bool URLLoaderWrapperImpl::GetDownloadProgress(
|
||||
int64_t* bytes_received,
|
||||
int64_t* total_bytes_to_be_received) const {
|
||||
int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const {
|
||||
return url_loader_->GetDownloadProgress(bytes_received,
|
||||
total_bytes_to_be_received);
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ class URLLoaderWrapperImpl : public URLLoaderWrapper {
|
||||
int GetStatusCode() const override;
|
||||
bool IsMultipart() const override;
|
||||
bool GetByteRangeStart(int* start) const override;
|
||||
bool GetDownloadProgress(int64_t* bytes_received,
|
||||
int64_t* total_bytes_to_be_received) const override;
|
||||
bool GetDownloadProgress(int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const override;
|
||||
void Close() override;
|
||||
void OpenRange(const std::string& url,
|
||||
const std::string& referrer_url,
|
||||
|
Reference in New Issue
Block a user