Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "net/base/auth.h" | 11 #include "net/base/auth.h" |
| 12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 13 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
| 14 #include "net/base/mime_util.h" | 14 #include "net/base/mime_util.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
| 17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 18 #include "net/url_request/url_request_job_metrics.h" | 18 #include "net/url_request/url_request_job_metrics.h" |
| 19 #include "net/url_request/url_request_job_tracker.h" | 19 #include "net/url_request/url_request_job_tracker.h" |
| 20 | 20 |
| 21 using base::Time; | 21 using base::Time; |
| 22 using base::TimeTicks; | 22 using base::TimeTicks; |
| 23 | 23 |
| 24 // Buffer size allocated when de-compressing data. | 24 // Buffer size allocated when de-compressing data. |
| 25 // static | 25 // static |
| 26 const int URLRequestJob::kFilterBufSize = 32 * 1024; | 26 const int URLRequestJob::kFilterBufSize = 32 * 1024; |
| 27 | 27 |
| 28 URLRequestJob::URLRequestJob(URLRequest* request) | 28 URLRequestJob::URLRequestJob(net::URLRequest* request) |
|
wtc
2010/11/30 19:29:08
Instead of adding net:: to this file, please put t
tfarina
2010/11/30 21:46:09
Done.
| |
| 29 : request_(request), | 29 : request_(request), |
| 30 prefilter_bytes_read_(0), | 30 prefilter_bytes_read_(0), |
| 31 postfilter_bytes_read_(0), | 31 postfilter_bytes_read_(0), |
| 32 is_compressible_content_(false), | 32 is_compressible_content_(false), |
| 33 is_compressed_(false), | 33 is_compressed_(false), |
| 34 done_(false), | 34 done_(false), |
| 35 filter_needs_more_output_space_(false), | 35 filter_needs_more_output_space_(false), |
| 36 filtered_read_buffer_len_(0), | 36 filtered_read_buffer_len_(0), |
| 37 has_handled_response_(false), | 37 has_handled_response_(false), |
| 38 expected_content_size_(-1), | 38 expected_content_size_(-1), |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 if (!request_ || !request_->delegate()) | 436 if (!request_ || !request_->delegate()) |
| 437 return; // The request was destroyed, so there is no more work to do. | 437 return; // The request was destroyed, so there is no more work to do. |
| 438 | 438 |
| 439 if (has_handled_response_) | 439 if (has_handled_response_) |
| 440 return; | 440 return; |
| 441 | 441 |
| 442 DCHECK(!request_->status().is_io_pending()); | 442 DCHECK(!request_->status().is_io_pending()); |
| 443 | 443 |
| 444 // Initialize to the current time, and let the subclass optionally override | 444 // Initialize to the current time, and let the subclass optionally override |
| 445 // the time stamps if it has that information. The default request_time is | 445 // the time stamps if it has that information. The default request_time is |
| 446 // set by URLRequest before it calls our Start method. | 446 // set by net::URLRequest before it calls our Start method. |
| 447 request_->response_info_.response_time = Time::Now(); | 447 request_->response_info_.response_time = Time::Now(); |
| 448 GetResponseInfo(&request_->response_info_); | 448 GetResponseInfo(&request_->response_info_); |
| 449 | 449 |
| 450 // When notifying the delegate, the delegate can release the request | 450 // When notifying the delegate, the delegate can release the request |
| 451 // (and thus release 'this'). After calling to the delgate, we must | 451 // (and thus release 'this'). After calling to the delgate, we must |
| 452 // check the request pointer to see if it still exists, and return | 452 // check the request pointer to see if it still exists, and return |
| 453 // immediately if it has been destroyed. self_preservation ensures our | 453 // immediately if it has been destroyed. self_preservation ensures our |
| 454 // survival until we can get out of this method. | 454 // survival until we can get out of this method. |
| 455 scoped_refptr<URLRequestJob> self_preservation(this); | 455 scoped_refptr<URLRequestJob> self_preservation(this); |
| 456 | 456 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 923 return; | 923 return; |
| 924 } | 924 } |
| 925 | 925 |
| 926 if (is_compressed_) { | 926 if (is_compressed_) { |
| 927 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); | 927 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); |
| 928 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); | 928 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); |
| 929 } else { | 929 } else { |
| 930 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); | 930 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); |
| 931 } | 931 } |
| 932 } | 932 } |
| OLD | NEW |