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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 1327763003: Added and implemented URLRequest::GetTotalSentBytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spdy_sent_bytes_impl
Patch Set: Addressed nits Created 5 years, 3 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_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 request_time_snapshot_(), 191 request_time_snapshot_(),
192 final_packet_time_(), 192 final_packet_time_(),
193 filter_context_(new HttpFilterContext(this)), 193 filter_context_(new HttpFilterContext(this)),
194 on_headers_received_callback_( 194 on_headers_received_callback_(
195 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback, 195 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback,
196 base::Unretained(this))), 196 base::Unretained(this))),
197 awaiting_callback_(false), 197 awaiting_callback_(false),
198 http_user_agent_settings_(http_user_agent_settings), 198 http_user_agent_settings_(http_user_agent_settings),
199 backoff_manager_(request->context()->backoff_manager()), 199 backoff_manager_(request->context()->backoff_manager()),
200 total_received_bytes_from_previous_transactions_(0), 200 total_received_bytes_from_previous_transactions_(0),
201 total_sent_bytes_from_previous_transactions_(0),
201 weak_factory_(this) { 202 weak_factory_(this) {
202 URLRequestThrottlerManager* manager = request->context()->throttler_manager(); 203 URLRequestThrottlerManager* manager = request->context()->throttler_manager();
203 if (manager) 204 if (manager)
204 throttling_entry_ = manager->RegisterRequestUrl(request->url()); 205 throttling_entry_ = manager->RegisterRequestUrl(request->url());
205 206
206 ResetTimer(); 207 ResetTimer();
207 } 208 }
208 209
209 URLRequestHttpJob::~URLRequestHttpJob() { 210 URLRequestHttpJob::~URLRequestHttpJob() {
210 CHECK(!awaiting_callback_); 211 CHECK(!awaiting_callback_);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 URLRequestJob::NotifyDone(status); 419 URLRequestJob::NotifyDone(status);
419 } 420 }
420 421
421 void URLRequestHttpJob::DestroyTransaction() { 422 void URLRequestHttpJob::DestroyTransaction() {
422 DCHECK(transaction_.get()); 423 DCHECK(transaction_.get());
423 424
424 DoneWithRequest(ABORTED); 425 DoneWithRequest(ABORTED);
425 426
426 total_received_bytes_from_previous_transactions_ += 427 total_received_bytes_from_previous_transactions_ +=
427 transaction_->GetTotalReceivedBytes(); 428 transaction_->GetTotalReceivedBytes();
429 total_sent_bytes_from_previous_transactions_ +=
430 transaction_->GetTotalSentBytes();
428 transaction_.reset(); 431 transaction_.reset();
429 response_info_ = NULL; 432 response_info_ = NULL;
430 receive_headers_end_ = base::TimeTicks(); 433 receive_headers_end_ = base::TimeTicks();
431 } 434 }
432 435
433 void URLRequestHttpJob::StartTransaction() { 436 void URLRequestHttpJob::StartTransaction() {
434 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. 437 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed.
435 tracked_objects::ScopedTracker tracking_profile( 438 tracked_objects::ScopedTracker tracking_profile(
436 FROM_HERE_WITH_EXPLICIT_FUNCTION( 439 FROM_HERE_WITH_EXPLICIT_FUNCTION(
437 "456327 URLRequestHttpJob::StartTransaction")); 440 "456327 URLRequestHttpJob::StartTransaction"));
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 } 1366 }
1364 1367
1365 int64 URLRequestHttpJob::GetTotalReceivedBytes() const { 1368 int64 URLRequestHttpJob::GetTotalReceivedBytes() const {
1366 int64_t total_received_bytes = 1369 int64_t total_received_bytes =
1367 total_received_bytes_from_previous_transactions_; 1370 total_received_bytes_from_previous_transactions_;
1368 if (transaction_) 1371 if (transaction_)
1369 total_received_bytes += transaction_->GetTotalReceivedBytes(); 1372 total_received_bytes += transaction_->GetTotalReceivedBytes();
1370 return total_received_bytes; 1373 return total_received_bytes;
1371 } 1374 }
1372 1375
1376 int64_t URLRequestHttpJob::GetTotalSentBytes() const {
1377 int64_t total_sent_bytes = total_sent_bytes_from_previous_transactions_;
1378 if (transaction_)
1379 total_sent_bytes += transaction_->GetTotalSentBytes();
1380 return total_sent_bytes;
1381 }
1382
1373 void URLRequestHttpJob::DoneReading() { 1383 void URLRequestHttpJob::DoneReading() {
1374 if (transaction_) { 1384 if (transaction_) {
1375 transaction_->DoneReading(); 1385 transaction_->DoneReading();
1376 } 1386 }
1377 DoneWithRequest(FINISHED); 1387 DoneWithRequest(FINISHED);
1378 } 1388 }
1379 1389
1380 void URLRequestHttpJob::DoneReadingRedirectResponse() { 1390 void URLRequestHttpJob::DoneReadingRedirectResponse() {
1381 if (transaction_) { 1391 if (transaction_) {
1382 if (transaction_->GetResponseInfo()->headers->IsRedirect(NULL)) { 1392 if (transaction_->GetResponseInfo()->headers->IsRedirect(NULL)) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 return override_response_headers_.get() ? 1567 return override_response_headers_.get() ?
1558 override_response_headers_.get() : 1568 override_response_headers_.get() :
1559 transaction_->GetResponseInfo()->headers.get(); 1569 transaction_->GetResponseInfo()->headers.get();
1560 } 1570 }
1561 1571
1562 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1572 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1563 awaiting_callback_ = false; 1573 awaiting_callback_ = false;
1564 } 1574 }
1565 1575
1566 } // namespace net 1576 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_http_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698