summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorbengr@google.com <bengr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 23:54:50 +0000
committerbengr@google.com <bengr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 23:54:50 +0000
commit7a299a9dbabb337957790c5b1d40500a23d0befe (patch)
tree8e342fc64130e1366b6f1d326092abcd87c17ec2 /net
parent0dae9eb4a377ff0c237857486a8a1aa51b9f71a5 (diff)
downloadchromium_src-7a299a9dbabb337957790c5b1d40500a23d0befe.zip
chromium_src-7a299a9dbabb337957790c5b1d40500a23d0befe.tar.gz
chromium_src-7a299a9dbabb337957790c5b1d40500a23d0befe.tar.bz2
Coalesce payload length statistics in ChromeNetworkDelegate
BUG= Review URL: https://chromiumcodereview.appspot.com/11137022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_response_headers.cc7
-rw-r--r--net/http/http_response_headers.h4
-rw-r--r--net/url_request/url_request.cc2
-rw-r--r--net/url_request/url_request.h9
-rw-r--r--net/url_request/url_request_http_job.cc6
5 files changed, 25 insertions, 3 deletions
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc
index 355f0b0..bc1340b 100644
--- a/net/http/http_response_headers.cc
+++ b/net/http/http_response_headers.cc
@@ -1140,9 +1140,14 @@ bool HttpResponseHeaders::HasStrongValidators() const {
// From RFC 2616:
// Content-Length = "Content-Length" ":" 1*DIGIT
int64 HttpResponseHeaders::GetContentLength() const {
+ return GetInt64HeaderValue("content-length");
+}
+
+int64 HttpResponseHeaders::GetInt64HeaderValue(
+ const std::string& header) const {
void* iter = NULL;
std::string content_length_val;
- if (!EnumerateHeader(&iter, "content-length", &content_length_val))
+ if (!EnumerateHeader(&iter, header, &content_length_val))
return -1;
if (content_length_val.empty())
diff --git a/net/http/http_response_headers.h b/net/http/http_response_headers.h
index d2586d2..3ed1a74 100644
--- a/net/http/http_response_headers.h
+++ b/net/http/http_response_headers.h
@@ -230,6 +230,10 @@ class NET_EXPORT HttpResponseHeaders
// no such header in the response.
int64 GetContentLength() const;
+ // Extracts the value of the specified header or returns -1 if there is no
+ // such header in the response.
+ int64 GetInt64HeaderValue(const std::string& header) const;
+
// Extracts the values in a Content-Range header and returns true if they are
// valid for a 206 response; otherwise returns false.
// The following values will be outputted:
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index cc7bfe6..71454aa 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -156,6 +156,7 @@ URLRequest::URLRequest(const GURL& url,
base::Bind(&URLRequest::BeforeRequestComplete,
base::Unretained(this)))),
has_notified_completion_(false),
+ received_response_content_length_(0),
creation_time_(base::TimeTicks::Now()) {
SIMPLE_STATS_COUNTER("URLRequestCount");
@@ -193,6 +194,7 @@ URLRequest::URLRequest(const GURL& url,
base::Bind(&URLRequest::BeforeRequestComplete,
base::Unretained(this)))),
has_notified_completion_(false),
+ received_response_content_length_(0),
creation_time_(base::TimeTicks::Now()) {
SIMPLE_STATS_COUNTER("URLRequestCount");
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 2b1dec4..dcb1523 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -651,6 +651,13 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
void set_stack_trace(const base::debug::StackTrace& stack_trace);
const base::debug::StackTrace* stack_trace() const;
+ void set_received_response_content_length(int64 received_content_length) {
+ received_response_content_length_ = received_content_length;
+ }
+ int64 received_response_content_length() {
+ return received_response_content_length_;
+ }
+
protected:
// Allow the URLRequestJob class to control the is_pending() flag.
void set_is_pending(bool value) { is_pending_ = value; }
@@ -828,6 +835,8 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
AuthCredentials auth_credentials_;
scoped_refptr<AuthChallengeInfo> auth_info_;
+ int64 received_response_content_length_;
+
base::TimeTicks creation_time_;
scoped_ptr<const base::debug::StackTrace> stack_trace_;
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 6068fa5..aab892f 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -29,6 +29,7 @@
#include "net/base/ssl_cert_request_info.h"
#include "net/base/ssl_config_service.h"
#include "net/cookies/cookie_monster.h"
+#include "net/http/http_network_session.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
@@ -1488,10 +1489,11 @@ void URLRequestHttpJob::DoneWithRequest(CompletionCause reason) {
if (done_)
return;
done_ = true;
-
RecordPerfHistograms(reason);
- if (reason == FINISHED)
+ if (reason == FINISHED) {
+ request_->set_received_response_content_length(prefilter_bytes_read());
RecordCompressionHistograms();
+ }
}
HttpResponseHeaders* URLRequestHttpJob::GetResponseHeaders() const {