Commit 71e5ff8f authored by eustas@chromium.org's avatar eustas@chromium.org

Implement GetTransferSize for url request.

Currently transfer size is calculated on base of netlog events. That's a misuse of netlog system.

With this patch transfer size could be directly requested from UrlRequest.

In some cases there are multiple network requests for one UrlRequest. In that case we sum "received" bytes for all network requests.

BUG=111052

Review URL: https://codereview.chromium.org/46223003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244477 0039d316-1c4b-4281-b951-d872f2087c98
parent 7f25145c
...@@ -352,6 +352,13 @@ bool URLRequest::GetFullRequestHeaders(HttpRequestHeaders* headers) const { ...@@ -352,6 +352,13 @@ bool URLRequest::GetFullRequestHeaders(HttpRequestHeaders* headers) const {
return job_->GetFullRequestHeaders(headers); return job_->GetFullRequestHeaders(headers);
} }
int64 URLRequest::GetTotalReceivedBytes() const {
if (!job_.get())
return 0;
return job_->GetTotalReceivedBytes();
}
LoadStateWithParam URLRequest::GetLoadState() const { LoadStateWithParam URLRequest::GetLoadState() const {
// The !blocked_by_.empty() check allows |this| to report it's blocked on a // The !blocked_by_.empty() check allows |this| to report it's blocked on a
// delegate before it has been started. // delegate before it has been started.
......
...@@ -440,6 +440,10 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), ...@@ -440,6 +440,10 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
// 2. The OnResponseStarted callback is currently running or has run. // 2. The OnResponseStarted callback is currently running or has run.
bool GetFullRequestHeaders(HttpRequestHeaders* headers) const; bool GetFullRequestHeaders(HttpRequestHeaders* headers) const;
// Gets the total amount of data received from network after SSL decoding and
// proxy handling.
int64 GetTotalReceivedBytes() const;
// Returns the current load state for the request. The returned value's // Returns the current load state for the request. The returned value's
// |param| field is an optional parameter describing details related to the // |param| field is an optional parameter describing details related to the
// load state. Not all load states have a parameter. // load state. Not all load states have a parameter.
......
...@@ -1242,6 +1242,13 @@ bool URLRequestHttpJob::GetFullRequestHeaders( ...@@ -1242,6 +1242,13 @@ bool URLRequestHttpJob::GetFullRequestHeaders(
return transaction_->GetFullRequestHeaders(headers); return transaction_->GetFullRequestHeaders(headers);
} }
int64 URLRequestHttpJob::GetTotalReceivedBytes() const {
if (!transaction_)
return 0;
return transaction_->GetTotalReceivedBytes();
}
void URLRequestHttpJob::DoneReading() { void URLRequestHttpJob::DoneReading() {
if (transaction_.get()) if (transaction_.get())
transaction_->DoneReading(); transaction_->DoneReading();
......
...@@ -119,6 +119,7 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob { ...@@ -119,6 +119,7 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob {
virtual void StopCaching() OVERRIDE; virtual void StopCaching() OVERRIDE;
virtual bool GetFullRequestHeaders( virtual bool GetFullRequestHeaders(
HttpRequestHeaders* headers) const OVERRIDE; HttpRequestHeaders* headers) const OVERRIDE;
virtual int64 GetTotalReceivedBytes() const OVERRIDE;
virtual void DoneReading() OVERRIDE; virtual void DoneReading() OVERRIDE;
virtual HostPortPair GetSocketAddress() const OVERRIDE; virtual HostPortPair GetSocketAddress() const OVERRIDE;
virtual void NotifyURLRequestDestroyed() OVERRIDE; virtual void NotifyURLRequestDestroyed() OVERRIDE;
......
...@@ -110,6 +110,10 @@ bool URLRequestJob::GetFullRequestHeaders(HttpRequestHeaders* headers) const { ...@@ -110,6 +110,10 @@ bool URLRequestJob::GetFullRequestHeaders(HttpRequestHeaders* headers) const {
return false; return false;
} }
int64 URLRequestJob::GetTotalReceivedBytes() const {
return 0;
}
LoadState URLRequestJob::GetLoadState() const { LoadState URLRequestJob::GetLoadState() const {
return LOAD_STATE_IDLE; return LOAD_STATE_IDLE;
} }
......
...@@ -107,6 +107,9 @@ class NET_EXPORT URLRequestJob ...@@ -107,6 +107,9 @@ class NET_EXPORT URLRequestJob
virtual bool GetFullRequestHeaders(HttpRequestHeaders* headers) const; virtual bool GetFullRequestHeaders(HttpRequestHeaders* headers) const;
// Get the number of bytes received from network.
virtual int64 GetTotalReceivedBytes() const;
// Called to fetch the current load state for the job. // Called to fetch the current load state for the job.
virtual LoadState GetLoadState() const; virtual LoadState GetLoadState() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment