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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_fetcher_core.h" 5 #include "net/url_request/url_fetcher_core.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 was_cancelled_(false), 95 was_cancelled_(false),
96 stop_on_redirect_(false), 96 stop_on_redirect_(false),
97 stopped_on_redirect_(false), 97 stopped_on_redirect_(false),
98 automatically_retry_on_5xx_(true), 98 automatically_retry_on_5xx_(true),
99 num_retries_on_5xx_(0), 99 num_retries_on_5xx_(0),
100 max_retries_on_5xx_(0), 100 max_retries_on_5xx_(0),
101 num_retries_on_network_changes_(0), 101 num_retries_on_network_changes_(0),
102 max_retries_on_network_changes_(0), 102 max_retries_on_network_changes_(0),
103 current_upload_bytes_(-1), 103 current_upload_bytes_(-1),
104 current_response_bytes_(0), 104 current_response_bytes_(0),
105 total_response_bytes_(-1) { 105 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
106 total_downloaded_bytes_(-1),
107 total_sent_bytes_(-1) {
106 CHECK(original_url_.is_valid()); 108 CHECK(original_url_.is_valid());
107 } 109 }
108 110
109 void URLFetcherCore::Start() { 111 void URLFetcherCore::Start() {
110 DCHECK(delegate_task_runner_.get()); 112 DCHECK(delegate_task_runner_.get());
111 DCHECK(request_context_getter_.get()) << "We need an URLRequestContext!"; 113 DCHECK(request_context_getter_.get()) << "We need an URLRequestContext!";
112 if (network_task_runner_.get()) { 114 if (network_task_runner_.get()) {
113 DCHECK_EQ(network_task_runner_, 115 DCHECK_EQ(network_task_runner_,
114 request_context_getter_->GetNetworkTaskRunner()); 116 request_context_getter_->GetNetworkTaskRunner());
115 } else { 117 } else {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 342 }
341 343
342 const URLRequestStatus& URLFetcherCore::GetStatus() const { 344 const URLRequestStatus& URLFetcherCore::GetStatus() const {
343 return status_; 345 return status_;
344 } 346 }
345 347
346 int URLFetcherCore::GetResponseCode() const { 348 int URLFetcherCore::GetResponseCode() const {
347 return response_code_; 349 return response_code_;
348 } 350 }
349 351
352 int64 URLFetcherCore::GetBytesSentSize() const {
bengr 2015/08/07 18:00:01 GetTotalBytesSent()
amohammadkhan 2015/08/11 22:04:36 Done.
353 return total_sent_bytes_;
354 }
355
356 int64 URLFetcherCore::GetBytesReceivedSize() const {
bengr 2015/08/07 18:00:02 GetTotalReceivedBytes()
amohammadkhan 2015/08/11 22:04:36 Done.
357 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
358 }
359
350 const ResponseCookies& URLFetcherCore::GetCookies() const { 360 const ResponseCookies& URLFetcherCore::GetCookies() const {
351 return cookies_; 361 return cookies_;
352 } 362 }
353 363
354 void URLFetcherCore::ReceivedContentWasMalformed() { 364 void URLFetcherCore::ReceivedContentWasMalformed() {
355 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 365 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
356 if (network_task_runner_.get()) { 366 if (network_task_runner_.get()) {
357 network_task_runner_->PostTask( 367 network_task_runner_->PostTask(
358 FROM_HERE, base::Bind(&URLFetcherCore::NotifyMalformedContent, this)); 368 FROM_HERE, base::Bind(&URLFetcherCore::NotifyMalformedContent, this));
359 } 369 }
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 } 810 }
801 811
802 void URLFetcherCore::CancelRequestAndInformDelegate(int result) { 812 void URLFetcherCore::CancelRequestAndInformDelegate(int result) {
803 CancelURLRequest(result); 813 CancelURLRequest(result);
804 delegate_task_runner_->PostTask( 814 delegate_task_runner_->PostTask(
805 FROM_HERE, 815 FROM_HERE,
806 base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, this)); 816 base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, this));
807 } 817 }
808 818
809 void URLFetcherCore::ReleaseRequest() { 819 void URLFetcherCore::ReleaseRequest() {
820 if (request_) {
821 total_received_bytes_ = request_->GetTotalReceivedBytes();
822 int request_body_bytes = 0;
823 int request_header_bytes = 0;
824 int total_request_bytes = 0;
825 if (request_->has_upload()) {
bengr 2015/08/07 18:00:02 Remove curly braces.
amohammadkhan 2015/08/11 22:04:36 Done.
826 request_body_bytes = request_->get_upload()->size();
827 }
828 net::HttpRequestHeaders request_headers;
829 if (request_->GetFullRequestHeaders(&request_headers)) {
bengr 2015/08/07 18:00:02 Remove curly braces.
amohammadkhan 2015/08/11 22:04:36 Done.
830 request_header_bytes = request_headers.ToString().length();
831 }
832 total_request_bytes = request_body_bytes + request_header_bytes;
833 total_sent_bytes_ = total_request_bytes;
834 }
835
810 request_context_getter_->RemoveObserver(this); 836 request_context_getter_->RemoveObserver(this);
811 upload_progress_checker_timer_.reset(); 837 upload_progress_checker_timer_.reset();
812 request_.reset(); 838 request_.reset();
813 g_registry.Get().RemoveURLFetcherCore(this); 839 g_registry.Get().RemoveURLFetcherCore(this);
814 } 840 }
815 841
816 base::TimeTicks URLFetcherCore::GetBackoffReleaseTime() { 842 base::TimeTicks URLFetcherCore::GetBackoffReleaseTime() {
817 DCHECK(network_task_runner_->BelongsToCurrentThread()); 843 DCHECK(network_task_runner_->BelongsToCurrentThread());
818 844
819 if (!original_url_throttler_entry_.get()) 845 if (!original_url_throttler_entry_.get())
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 } 976 }
951 977
952 void URLFetcherCore::AssertHasNoUploadData() const { 978 void URLFetcherCore::AssertHasNoUploadData() const {
953 DCHECK(!upload_content_set_); 979 DCHECK(!upload_content_set_);
954 DCHECK(upload_content_.empty()); 980 DCHECK(upload_content_.empty());
955 DCHECK(upload_file_path_.empty()); 981 DCHECK(upload_file_path_.empty());
956 DCHECK(upload_stream_factory_.is_null()); 982 DCHECK(upload_stream_factory_.is_null());
957 } 983 }
958 984
959 } // namespace net 985 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698