Chromium Code Reviews| Index: components/image_fetcher/core/image_data_fetcher.cc |
| diff --git a/components/image_fetcher/core/image_data_fetcher.cc b/components/image_fetcher/core/image_data_fetcher.cc |
| index 0ef812f6465ffe2436e7aed35d73fa781d14c0ab..e01f3fa6998c882c1a5085b4718063e652444ca2 100644 |
| --- a/components/image_fetcher/core/image_data_fetcher.cc |
| +++ b/components/image_fetcher/core/image_data_fetcher.cc |
| @@ -36,7 +36,8 @@ ImageDataFetcher::ImageDataFetcher( |
| net::URLRequestContextGetter* url_request_context_getter) |
| : url_request_context_getter_(url_request_context_getter), |
| data_use_service_name_(DataUseUserData::IMAGE_FETCHER_UNTAGGED), |
| - next_url_fetcher_id_(0) {} |
| + next_url_fetcher_id_(0), |
| + max_download_bytes_(-1) {} // No download limitation. |
| ImageDataFetcher::~ImageDataFetcher() {} |
| @@ -100,4 +101,27 @@ void ImageDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
| pending_requests_.erase(request_iter); |
| } |
| +void ImageDataFetcher::OnURLFetchDownloadProgress( |
| + const net::URLFetcher* source, |
| + int64_t current, |
| + int64_t total, |
| + int64_t current_network_bytes) { |
| + if (max_download_bytes_ < 0) { |
| + return; |
| + } |
| + if (total <= max_download_bytes_ && current <= max_download_bytes_) { |
| + return; |
| + } |
| + auto request_iter = pending_requests_.find(source); |
|
fhorschig
2017/03/27 12:57:25
I am aware that I duplicate 4 operations here from
Marc Treib
2017/03/27 13:16:42
We could have a "FinishRequest(source, result, met
fhorschig
2017/03/27 14:33:43
Hmm, for the sake of the argument, I introduced th
Marc Treib
2017/03/27 14:49:18
Sure, that's fine. Though duplicating the DCHECKs
|
| + DCHECK(request_iter != pending_requests_.end()); |
| + |
| + LOG(WARNING) << "Image data exceededs download size limit."; |
|
Marc Treib
2017/03/27 13:16:42
s/exceededs/exceeded/
Also DLOG?
fhorschig
2017/03/27 14:33:42
Done.
LOG was intentional, check below whether you
Marc Treib
2017/03/27 14:49:18
Non-"D" LOG is rarely useful IMO. Any particular u
Marc Treib
2017/03/27 16:40:12
This is still open
fhorschig
2017/03/28 08:28:53
Change uploaded.
|
| + RequestMetadata metadata; |
| + metadata.http_response_code = net::URLFetcher::RESPONSE_CODE_INVALID; |
|
Marc Treib
2017/03/27 13:16:42
Hm. I wonder if we should somehow signal to the cl
fhorschig
2017/03/27 14:33:42
An empty image in combination with the warning see
Marc Treib
2017/03/27 14:49:18
Okay, fair enough.
Marc Treib
2017/03/27 16:40:12
Did you file a bug for this?
fhorschig
2017/03/28 08:28:53
There is a bug now:
https://crbug.com/705888
I am
|
| + |
| + request_iter->second->callback.Run(std::string(), metadata); |
| + // Abort the finished request. |
|
Marc Treib
2017/03/27 13:16:42
nit: not actually finished
fhorschig
2017/03/27 14:33:42
Gone.
|
| + pending_requests_.erase(request_iter); |
| +} |
| + |
| } // namespace image_fetcher |