OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_job.h" | 5 #include "net/url_request/url_request_job.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // static | 21 // static |
22 const int URLRequestJob::kFilterBufSize = 32 * 1024; | 22 const int URLRequestJob::kFilterBufSize = 32 * 1024; |
23 | 23 |
24 URLRequestJob::URLRequestJob(URLRequest* request) | 24 URLRequestJob::URLRequestJob(URLRequest* request) |
25 : request_(request), | 25 : request_(request), |
26 done_(false), | 26 done_(false), |
27 filter_needs_more_output_space_(false), | 27 filter_needs_more_output_space_(false), |
28 read_buffer_(NULL), | 28 read_buffer_(NULL), |
29 read_buffer_len_(0), | 29 read_buffer_len_(0), |
30 has_handled_response_(false), | 30 has_handled_response_(false), |
31 expected_content_size_(-1) { | 31 expected_content_size_(-1), |
| 32 filter_input_byte_count_(0) { |
32 is_profiling_ = request->enable_profiling(); | 33 is_profiling_ = request->enable_profiling(); |
33 if (is_profiling()) { | 34 if (is_profiling()) { |
34 metrics_.reset(new URLRequestJobMetrics()); | 35 metrics_.reset(new URLRequestJobMetrics()); |
35 metrics_->start_time_ = TimeTicks::Now(); | 36 metrics_->start_time_ = TimeTicks::Now(); |
36 } | 37 } |
37 g_url_request_job_tracker.AddNewJob(this); | 38 g_url_request_job_tracker.AddNewJob(this); |
38 } | 39 } |
39 | 40 |
40 URLRequestJob::~URLRequestJob() { | 41 URLRequestJob::~URLRequestJob() { |
41 g_url_request_job_tracker.RemoveJob(this); | 42 g_url_request_job_tracker.RemoveJob(this); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 NOTREACHED(); | 80 NOTREACHED(); |
80 } | 81 } |
81 | 82 |
82 void URLRequestJob::ContinueDespiteLastError() { | 83 void URLRequestJob::ContinueDespiteLastError() { |
83 // Implementations should know how to recover from errors they generate. | 84 // Implementations should know how to recover from errors they generate. |
84 // If this code was reached, we are trying to recover from an error that | 85 // If this code was reached, we are trying to recover from an error that |
85 // we don't know how to recover from. | 86 // we don't know how to recover from. |
86 NOTREACHED(); | 87 NOTREACHED(); |
87 } | 88 } |
88 | 89 |
| 90 int64 URLRequestJob::GetByteReadCount() const { |
| 91 return filter_input_byte_count_ ; |
| 92 } |
| 93 |
89 bool URLRequestJob::GetURL(GURL* gurl) const { | 94 bool URLRequestJob::GetURL(GURL* gurl) const { |
90 if (!request_) | 95 if (!request_) |
91 return false; | 96 return false; |
92 *gurl = request_->url(); | 97 *gurl = request_->url(); |
93 return true; | 98 return true; |
94 } | 99 } |
95 | 100 |
96 base::Time URLRequestJob::GetRequestTime() const { | 101 base::Time URLRequestJob::GetRequestTime() const { |
97 if (!request_) | 102 if (!request_) |
98 return base::Time(); | 103 return base::Time(); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 int rv = request_->Redirect(location, http_status_code); | 503 int rv = request_->Redirect(location, http_status_code); |
499 if (rv != net::OK) | 504 if (rv != net::OK) |
500 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 505 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
501 } | 506 } |
502 | 507 |
503 void URLRequestJob::RecordBytesRead(int bytes_read) { | 508 void URLRequestJob::RecordBytesRead(int bytes_read) { |
504 if (is_profiling()) { | 509 if (is_profiling()) { |
505 ++(metrics_->number_of_read_IO_); | 510 ++(metrics_->number_of_read_IO_); |
506 metrics_->total_bytes_read_ += bytes_read; | 511 metrics_->total_bytes_read_ += bytes_read; |
507 } | 512 } |
| 513 filter_input_byte_count_ += bytes_read; |
508 g_url_request_job_tracker.OnBytesRead(this, bytes_read); | 514 g_url_request_job_tracker.OnBytesRead(this, bytes_read); |
509 } | 515 } |
510 | 516 |
511 const URLRequestStatus URLRequestJob::GetStatus() { | 517 const URLRequestStatus URLRequestJob::GetStatus() { |
512 if (request_) | 518 if (request_) |
513 return request_->status(); | 519 return request_->status(); |
514 // If the request is gone, we must be cancelled. | 520 // If the request is gone, we must be cancelled. |
515 return URLRequestStatus(URLRequestStatus::CANCELED, | 521 return URLRequestStatus(URLRequestStatus::CANCELED, |
516 net::ERR_ABORTED); | 522 net::ERR_ABORTED); |
517 } | 523 } |
518 | 524 |
519 void URLRequestJob::SetStatus(const URLRequestStatus &status) { | 525 void URLRequestJob::SetStatus(const URLRequestStatus &status) { |
520 if (request_) | 526 if (request_) |
521 request_->set_status(status); | 527 request_->set_status(status); |
522 } | 528 } |
OLD | NEW |