| 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/host_port_pair.h" | 12 #include "net/base/host_port_pair.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
| 15 #include "net/base/mime_util.h" | 15 #include "net/base/mime_util.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/base/network_delegate.h" | 17 #include "net/base/network_delegate.h" |
| 18 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 19 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
| 20 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 21 #include "net/url_request/url_request_job_metrics.h" | 21 #include "net/url_request/url_request_job_metrics.h" |
| 22 #include "net/url_request/url_request_job_tracker.h" | 22 #include "net/url_request/url_request_job_tracker.h" |
| 23 | 23 |
| 24 using base::Time; | 24 using base::Time; |
| 25 using base::TimeTicks; | 25 using base::TimeTicks; |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 | 28 |
| 29 // Buffer size allocated when de-compressing data. | |
| 30 // static | |
| 31 const int URLRequestJob::kFilterBufSize = 32 * 1024; | |
| 32 | |
| 33 URLRequestJob::URLRequestJob(URLRequest* request) | 29 URLRequestJob::URLRequestJob(URLRequest* request) |
| 34 : request_(request), | 30 : request_(request), |
| 35 prefilter_bytes_read_(0), | 31 prefilter_bytes_read_(0), |
| 36 postfilter_bytes_read_(0), | 32 postfilter_bytes_read_(0), |
| 37 is_compressible_content_(false), | 33 is_compressible_content_(false), |
| 38 is_compressed_(false), | 34 is_compressed_(false), |
| 39 done_(false), | 35 done_(false), |
| 40 filter_needs_more_output_space_(false), | 36 filter_needs_more_output_space_(false), |
| 41 filtered_read_buffer_len_(0), | 37 filtered_read_buffer_len_(0), |
| 42 has_handled_response_(false), | 38 has_handled_response_(false), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 252 } |
| 257 | 253 |
| 258 int64 URLRequestJob::GetByteReadCount() const { | 254 int64 URLRequestJob::GetByteReadCount() const { |
| 259 return filter_input_byte_count_; | 255 return filter_input_byte_count_; |
| 260 } | 256 } |
| 261 | 257 |
| 262 int URLRequestJob::GetResponseCode() const { | 258 int URLRequestJob::GetResponseCode() const { |
| 263 return -1; | 259 return -1; |
| 264 } | 260 } |
| 265 | 261 |
| 266 int URLRequestJob::GetInputStreamBufferSize() const { | |
| 267 return kFilterBufSize; | |
| 268 } | |
| 269 | |
| 270 void URLRequestJob::RecordPacketStats(StatisticSelector statistic) const { | 262 void URLRequestJob::RecordPacketStats(StatisticSelector statistic) const { |
| 271 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) | 263 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) |
| 272 return; | 264 return; |
| 273 | 265 |
| 274 // Caller should verify that we're not cached content, but we can't always | 266 // Caller should verify that we're not cached content, but we can't always |
| 275 // really check for it here because we may (at destruction time) call our own | 267 // really check for it here because we may (at destruction time) call our own |
| 276 // class method and get a bogus const answer of false. This DCHECK only helps | 268 // class method and get a bogus const answer of false. This DCHECK only helps |
| 277 // when this method has a valid overridden definition. | 269 // when this method has a valid overridden definition. |
| 278 DCHECK(!IsCachedContent()); | 270 DCHECK(!IsCachedContent()); |
| 279 | 271 |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 | 937 |
| 946 if (is_compressed_) { | 938 if (is_compressed_) { |
| 947 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); | 939 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); |
| 948 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); | 940 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); |
| 949 } else { | 941 } else { |
| 950 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); | 942 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); |
| 951 } | 943 } |
| 952 } | 944 } |
| 953 | 945 |
| 954 } // namespace net | 946 } // namespace net |
| OLD | NEW |