| 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 namespace net { | 24 namespace net { |
| 25 | 25 |
| 26 // Buffer size allocated when de-compressing data. | |
| 27 // static | |
| 28 const int URLRequestJob::kFilterBufSize = 32 * 1024; | |
| 29 | |
| 30 URLRequestJob::URLRequestJob(URLRequest* request) | 26 URLRequestJob::URLRequestJob(URLRequest* request) |
| 31 : request_(request), | 27 : request_(request), |
| 32 prefilter_bytes_read_(0), | 28 prefilter_bytes_read_(0), |
| 33 postfilter_bytes_read_(0), | 29 postfilter_bytes_read_(0), |
| 34 is_compressible_content_(false), | 30 is_compressible_content_(false), |
| 35 is_compressed_(false), | 31 is_compressed_(false), |
| 36 done_(false), | 32 done_(false), |
| 37 filter_needs_more_output_space_(false), | 33 filter_needs_more_output_space_(false), |
| 38 filtered_read_buffer_len_(0), | 34 filtered_read_buffer_len_(0), |
| 39 has_handled_response_(false), | 35 has_handled_response_(false), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 249 } |
| 254 | 250 |
| 255 int64 URLRequestJob::GetByteReadCount() const { | 251 int64 URLRequestJob::GetByteReadCount() const { |
| 256 return filter_input_byte_count_; | 252 return filter_input_byte_count_; |
| 257 } | 253 } |
| 258 | 254 |
| 259 int URLRequestJob::GetResponseCode() const { | 255 int URLRequestJob::GetResponseCode() const { |
| 260 return -1; | 256 return -1; |
| 261 } | 257 } |
| 262 | 258 |
| 263 int URLRequestJob::GetInputStreamBufferSize() const { | |
| 264 return kFilterBufSize; | |
| 265 } | |
| 266 | |
| 267 void URLRequestJob::RecordPacketStats(StatisticSelector statistic) const { | 259 void URLRequestJob::RecordPacketStats(StatisticSelector statistic) const { |
| 268 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) | 260 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) |
| 269 return; | 261 return; |
| 270 | 262 |
| 271 // Caller should verify that we're not cached content, but we can't always | 263 // Caller should verify that we're not cached content, but we can't always |
| 272 // really check for it here because we may (at destruction time) call our own | 264 // really check for it here because we may (at destruction time) call our own |
| 273 // class method and get a bogus const answer of false. This DCHECK only helps | 265 // class method and get a bogus const answer of false. This DCHECK only helps |
| 274 // when this method has a valid overridden definition. | 266 // when this method has a valid overridden definition. |
| 275 DCHECK(!IsCachedContent()); | 267 DCHECK(!IsCachedContent()); |
| 276 | 268 |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 | 919 |
| 928 if (is_compressed_) { | 920 if (is_compressed_) { |
| 929 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); | 921 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); |
| 930 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); | 922 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); |
| 931 } else { | 923 } else { |
| 932 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); | 924 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); |
| 933 } | 925 } |
| 934 } | 926 } |
| 935 | 927 |
| 936 } // namespace net | 928 } // namespace net |
| OLD | NEW |