Stop using GetDownloadProgress() in the PDF viewer
Drops various GetDownloadProgress() APIs from the PDF viewer because: 1. We never call pp::URLRequestInfo::SetRecordDownloadProgress(), so calls to pp::URLLoader::GetDownloadProgress() always return false. 2. We only use GetDownloadProgress() in DocumentLoaderImpl, to try to get the total content length if we fail to get it from the Content-Length header. But the total content length reported by GetDownloadProgress() also comes from Content-Length, so this is not useful. 3. GetDownloadProgress() won't be useful post-Pepper, as blink::WebAssociatedURLLoader does not have a similar API. Instead, the client is expected to track this internally. Bug: 1099022 Change-Id: I6f2f183e84b2d9e4c0dee2c116ac08bce3dc4ed0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429545 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: K. Moon <kmoon@chromium.org> Cr-Commit-Position: refs/heads/master@{#810442}
This commit is contained in:
@ -107,15 +107,6 @@ bool DocumentLoaderImpl::Init(std::unique_ptr<URLLoaderWrapper> loader,
|
||||
if (!loader_->IsContentEncoded())
|
||||
chunk_stream_.set_eof_pos(std::max(0, loader_->GetContentLength()));
|
||||
|
||||
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)) {
|
||||
chunk_stream_.set_eof_pos(
|
||||
std::max(0, static_cast<int>(total_bytes_to_be_received)));
|
||||
}
|
||||
|
||||
SetPartialLoadingEnabled(
|
||||
partial_loading_enabled_ &&
|
||||
!base::StartsWith(url, "file://", base::CompareCase::INSENSITIVE_ASCII) &&
|
||||
|
@ -188,11 +188,6 @@ 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 {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
LoaderData* data_;
|
||||
};
|
||||
|
@ -157,13 +157,6 @@ void BlinkUrlLoader::Open(const UrlRequest& request, ResultCallback callback) {
|
||||
blink_loader_->LoadAsynchronously(blink_request, this);
|
||||
}
|
||||
|
||||
bool BlinkUrlLoader::GetDownloadProgress(
|
||||
int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Modeled on `ppapi::proxy::URLLoaderResource::ReadResponseBody()`.
|
||||
void BlinkUrlLoader::ReadResponseBody(base::span<char> buffer,
|
||||
ResultCallback callback) {
|
||||
@ -378,13 +371,6 @@ void PepperUrlLoader::Open(const UrlRequest& request, ResultCallback callback) {
|
||||
pp_callback.Run(result);
|
||||
}
|
||||
|
||||
bool PepperUrlLoader::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 PepperUrlLoader::ReadResponseBody(base::span<char> buffer,
|
||||
ResultCallback callback) {
|
||||
pp::CompletionCallback pp_callback =
|
||||
|
@ -103,9 +103,6 @@ class UrlLoader {
|
||||
|
||||
// Mimic `pp::URLLoader`:
|
||||
virtual void Open(const UrlRequest& request, ResultCallback callback) = 0;
|
||||
virtual bool GetDownloadProgress(
|
||||
int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const = 0;
|
||||
virtual void ReadResponseBody(base::span<char> buffer,
|
||||
ResultCallback callback) = 0;
|
||||
virtual void Close() = 0;
|
||||
@ -167,8 +164,6 @@ class BlinkUrlLoader final : public UrlLoader,
|
||||
// UrlLoader:
|
||||
void GrantUniversalAccess() override;
|
||||
void Open(const UrlRequest& request, ResultCallback callback) override;
|
||||
bool GetDownloadProgress(int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const override;
|
||||
void ReadResponseBody(base::span<char> buffer,
|
||||
ResultCallback callback) override;
|
||||
void Close() override;
|
||||
@ -243,8 +238,6 @@ class PepperUrlLoader final : public UrlLoader {
|
||||
// UrlLoader:
|
||||
void GrantUniversalAccess() override;
|
||||
void Open(const UrlRequest& request, ResultCallback callback) override;
|
||||
bool GetDownloadProgress(int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const override;
|
||||
void ReadResponseBody(base::span<char> buffer,
|
||||
ResultCallback callback) override;
|
||||
void Close() override;
|
||||
|
@ -58,14 +58,6 @@ class URLLoaderWrapper {
|
||||
virtual void ReadResponseBody(char* buffer,
|
||||
int buffer_size,
|
||||
ResultCallback callback) = 0;
|
||||
|
||||
// Returns the current download progress.
|
||||
// Progress only refers to the response body and does not include the headers.
|
||||
// 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;
|
||||
};
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -144,13 +144,6 @@ bool URLLoaderWrapperImpl::GetByteRangeStart(int* start) const {
|
||||
return byte_range_.IsValid();
|
||||
}
|
||||
|
||||
bool URLLoaderWrapperImpl::GetDownloadProgress(
|
||||
int64_t& bytes_received,
|
||||
int64_t& total_bytes_to_be_received) const {
|
||||
return url_loader_->GetDownloadProgress(bytes_received,
|
||||
total_bytes_to_be_received);
|
||||
}
|
||||
|
||||
void URLLoaderWrapperImpl::Close() {
|
||||
url_loader_->Close();
|
||||
read_starter_.Stop();
|
||||
|
@ -36,8 +36,6 @@ 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;
|
||||
void Close() override;
|
||||
void OpenRange(const std::string& url,
|
||||
const std::string& referrer_url,
|
||||
|
Reference in New Issue
Block a user