summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authormsw <msw@chromium.org>2015-12-11 15:07:42 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-11 23:08:44 +0000
commit2d583b005c9a03be071ae50f6120a3e3351dfae7 (patch)
treebe5c5313baf8083db4ebf99678e9dc6939b881d3 /mojo
parenta853d663f8d11076a866399feb0f5be96cec98c7 (diff)
downloadchromium_src-2d583b005c9a03be071ae50f6120a3e3351dfae7.zip
chromium_src-2d583b005c9a03be071ae50f6120a3e3351dfae7.tar.gz
chromium_src-2d583b005c9a03be071ae50f6120a3e3351dfae7.tar.bz2
Add URLLoaderStatus bytes_read and content_length for progress.
These values may be used by future URLLoaderImpl::QueryStatus callers. ( none yet, explored in https://codereview.chromium.org/1463373003 ) BUG=NONE TEST=NONE R=ben@chromium.org Review URL: https://codereview.chromium.org/1507033007 Cr-Commit-Position: refs/heads/master@{#364827}
Diffstat (limited to 'mojo')
-rw-r--r--mojo/services/network/public/interfaces/url_loader.mojom5
-rw-r--r--mojo/services/network/url_loader_impl.cc7
-rw-r--r--mojo/services/network/url_loader_impl.h3
3 files changed, 14 insertions, 1 deletions
diff --git a/mojo/services/network/public/interfaces/url_loader.mojom b/mojo/services/network/public/interfaces/url_loader.mojom
index 8a18c26..f7e12c8 100644
--- a/mojo/services/network/public/interfaces/url_loader.mojom
+++ b/mojo/services/network/public/interfaces/url_loader.mojom
@@ -87,6 +87,11 @@ struct URLLoaderStatus {
// body stream.
bool is_loading;
+ // The length in bytes of the content as reported by the HTTP response header,
+ // and the number of bytes read by the URLLoader thus far.
+ int64 content_length;
+ int64 bytes_read;
+
// TODO(darin): Add further details about the stages of loading (e.g.,
// "resolving host") that happen prior to receiving bytes.
};
diff --git a/mojo/services/network/url_loader_impl.cc b/mojo/services/network/url_loader_impl.cc
index dfb1566..ab264cb 100644
--- a/mojo/services/network/url_loader_impl.cc
+++ b/mojo/services/network/url_loader_impl.cc
@@ -139,6 +139,7 @@ URLLoaderImpl::URLLoaderImpl(NetworkContext* context,
scoped_ptr<mojo::AppRefCount> app_refcount)
: context_(context),
response_body_buffer_size_(0),
+ response_body_bytes_read_(0),
auto_follow_redirects_(true),
connected_(true),
binding_(this, request.Pass()),
@@ -231,10 +232,15 @@ void URLLoaderImpl::FollowRedirect(
void URLLoaderImpl::QueryStatus(
const Callback<void(URLLoaderStatusPtr)>& callback) {
URLLoaderStatusPtr status(URLLoaderStatus::New());
+ status->bytes_read = response_body_bytes_read_;
if (url_request_) {
status->is_loading = url_request_->is_pending();
if (!url_request_->status().is_success())
status->error = MakeNetworkError(url_request_->status().error());
+ if (url_request_->response_info().headers) {
+ status->content_length =
+ url_request_->response_info().headers->GetContentLength();
+ }
} else {
status->is_loading = false;
}
@@ -385,6 +391,7 @@ void URLLoaderImpl::ReadMore() {
void URLLoaderImpl::DidRead(uint32_t num_bytes, bool completed_synchronously) {
DCHECK(url_request_->status().is_success());
+ response_body_bytes_read_ += num_bytes;
response_body_stream_ = pending_write_->Complete(num_bytes);
pending_write_ = nullptr;
diff --git a/mojo/services/network/url_loader_impl.h b/mojo/services/network/url_loader_impl.h
index 0b7b44d..c1931e3 100644
--- a/mojo/services/network/url_loader_impl.h
+++ b/mojo/services/network/url_loader_impl.h
@@ -63,7 +63,8 @@ class URLLoaderImpl : public URLLoader,
ScopedDataPipeProducerHandle response_body_stream_;
scoped_refptr<NetToMojoPendingBuffer> pending_write_;
common::HandleWatcher handle_watcher_;
- uint32 response_body_buffer_size_;
+ uint32_t response_body_buffer_size_;
+ uint32_t response_body_bytes_read_;
bool auto_follow_redirects_;
bool connected_;
Binding<URLLoader> binding_;