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

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

Issue 1284993005: Notify NetworkDelegate when bytes have been received over the network. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed empty cronet OnRawBytesRead implementation 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bytes_observed_in_packets_(0), 190 bytes_observed_in_packets_(0),
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 weak_factory_(this) { 201 weak_factory_(this) {
201 URLRequestThrottlerManager* manager = request->context()->throttler_manager(); 202 URLRequestThrottlerManager* manager = request->context()->throttler_manager();
202 if (manager) 203 if (manager)
203 throttling_entry_ = manager->RegisterRequestUrl(request->url()); 204 throttling_entry_ = manager->RegisterRequestUrl(request->url());
204 205
205 ResetTimer(); 206 ResetTimer();
206 } 207 }
207 208
208 URLRequestHttpJob::~URLRequestHttpJob() { 209 URLRequestHttpJob::~URLRequestHttpJob() {
209 CHECK(!awaiting_callback_); 210 CHECK(!awaiting_callback_);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 415
415 void URLRequestHttpJob::NotifyDone(const URLRequestStatus& status) { 416 void URLRequestHttpJob::NotifyDone(const URLRequestStatus& status) {
416 DoneWithRequest(FINISHED); 417 DoneWithRequest(FINISHED);
417 URLRequestJob::NotifyDone(status); 418 URLRequestJob::NotifyDone(status);
418 } 419 }
419 420
420 void URLRequestHttpJob::DestroyTransaction() { 421 void URLRequestHttpJob::DestroyTransaction() {
421 DCHECK(transaction_.get()); 422 DCHECK(transaction_.get());
422 423
423 DoneWithRequest(ABORTED); 424 DoneWithRequest(ABORTED);
425
426 total_received_bytes_from_previous_transactions_ +=
427 transaction_->GetTotalReceivedBytes();
424 transaction_.reset(); 428 transaction_.reset();
425 response_info_ = NULL; 429 response_info_ = NULL;
426 receive_headers_end_ = base::TimeTicks(); 430 receive_headers_end_ = base::TimeTicks();
427 } 431 }
428 432
429 void URLRequestHttpJob::StartTransaction() { 433 void URLRequestHttpJob::StartTransaction() {
430 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. 434 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed.
431 tracked_objects::ScopedTracker tracking_profile( 435 tracked_objects::ScopedTracker tracking_profile(
432 FROM_HERE_WITH_EXPLICIT_FUNCTION( 436 FROM_HERE_WITH_EXPLICIT_FUNCTION(
433 "456327 URLRequestHttpJob::StartTransaction")); 437 "456327 URLRequestHttpJob::StartTransaction"));
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 1356
1353 bool URLRequestHttpJob::GetFullRequestHeaders( 1357 bool URLRequestHttpJob::GetFullRequestHeaders(
1354 HttpRequestHeaders* headers) const { 1358 HttpRequestHeaders* headers) const {
1355 if (!transaction_) 1359 if (!transaction_)
1356 return false; 1360 return false;
1357 1361
1358 return transaction_->GetFullRequestHeaders(headers); 1362 return transaction_->GetFullRequestHeaders(headers);
1359 } 1363 }
1360 1364
1361 int64 URLRequestHttpJob::GetTotalReceivedBytes() const { 1365 int64 URLRequestHttpJob::GetTotalReceivedBytes() const {
1362 if (!transaction_) 1366 int64_t total_received_bytes =
1363 return 0; 1367 total_received_bytes_from_previous_transactions_;
1364 1368 if (transaction_)
1365 return transaction_->GetTotalReceivedBytes(); 1369 total_received_bytes += transaction_->GetTotalReceivedBytes();
1370 return total_received_bytes;
1366 } 1371 }
1367 1372
1368 void URLRequestHttpJob::DoneReading() { 1373 void URLRequestHttpJob::DoneReading() {
1369 if (transaction_) { 1374 if (transaction_) {
1370 transaction_->DoneReading(); 1375 transaction_->DoneReading();
1371 } 1376 }
1372 DoneWithRequest(FINISHED); 1377 DoneWithRequest(FINISHED);
1373 } 1378 }
1374 1379
1375 void URLRequestHttpJob::DoneReadingRedirectResponse() { 1380 void URLRequestHttpJob::DoneReadingRedirectResponse() {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 return override_response_headers_.get() ? 1557 return override_response_headers_.get() ?
1553 override_response_headers_.get() : 1558 override_response_headers_.get() :
1554 transaction_->GetResponseInfo()->headers.get(); 1559 transaction_->GetResponseInfo()->headers.get();
1555 } 1560 }
1556 1561
1557 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1562 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1558 awaiting_callback_ = false; 1563 awaiting_callback_ = false;
1559 } 1564 }
1560 1565
1561 } // namespace net 1566 } // 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