Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: net/url_request/url_fetcher_core.cc

Issue 1279543002: Support needed to measure user and service traffic in Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewHistogram
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_fetcher_core.cc
diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc
index de55ef779af1948b9a5ff8794075b9e7d76d48b9..0aa56eeb62411a2a1d2664f9f63028258beb186c 100644
--- a/net/url_request/url_fetcher_core.cc
+++ b/net/url_request/url_fetcher_core.cc
@@ -102,7 +102,9 @@ URLFetcherCore::URLFetcherCore(URLFetcher* fetcher,
max_retries_on_network_changes_(0),
current_upload_bytes_(-1),
current_response_bytes_(0),
- total_response_bytes_(-1) {
+ total_response_bytes_(-1),
bengr 2015/08/07 18:00:02 Why are these initialized to -1 and not 0?
amohammadkhan 2015/08/11 22:04:36 To be distinguishable if they are not touched at a
+ total_downloaded_bytes_(-1),
+ total_sent_bytes_(-1) {
CHECK(original_url_.is_valid());
}
@@ -347,6 +349,14 @@ int URLFetcherCore::GetResponseCode() const {
return response_code_;
}
+int64 URLFetcherCore::GetBytesSentSize() const {
bengr 2015/08/07 18:00:01 GetTotalBytesSent()
amohammadkhan 2015/08/11 22:04:36 Done.
+ return total_sent_bytes_;
+}
+
+int64 URLFetcherCore::GetBytesReceivedSize() const {
bengr 2015/08/07 18:00:02 GetTotalReceivedBytes()
amohammadkhan 2015/08/11 22:04:36 Done.
+ return total_downloaded_bytes_;
bengr 2015/08/07 18:00:02 total_received_bytes_. In general, please be consi
amohammadkhan 2015/08/11 22:04:36 At first I had use total_received_bytes. But when
+}
+
const ResponseCookies& URLFetcherCore::GetCookies() const {
return cookies_;
}
@@ -807,6 +817,22 @@ void URLFetcherCore::CancelRequestAndInformDelegate(int result) {
}
void URLFetcherCore::ReleaseRequest() {
+ if (request_) {
+ total_received_bytes_ = request_->GetTotalReceivedBytes();
+ int request_body_bytes = 0;
+ int request_header_bytes = 0;
+ int total_request_bytes = 0;
+ if (request_->has_upload()) {
bengr 2015/08/07 18:00:02 Remove curly braces.
amohammadkhan 2015/08/11 22:04:36 Done.
+ request_body_bytes = request_->get_upload()->size();
+ }
+ net::HttpRequestHeaders request_headers;
+ if (request_->GetFullRequestHeaders(&request_headers)) {
bengr 2015/08/07 18:00:02 Remove curly braces.
amohammadkhan 2015/08/11 22:04:36 Done.
+ request_header_bytes = request_headers.ToString().length();
+ }
+ total_request_bytes = request_body_bytes + request_header_bytes;
+ total_sent_bytes_ = total_request_bytes;
+ }
+
request_context_getter_->RemoveObserver(this);
upload_progress_checker_timer_.reset();
request_.reset();

Powered by Google App Engine
This is Rietveld 408576698