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 "chrome/browser/renderer_host/buffered_resource_handler.h" | 5 #include "chrome/browser/renderer_host/buffered_resource_handler.h" |
6 | 6 |
7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/string_util.h" |
8 #include "net/base/mime_sniffer.h" | 9 #include "net/base/mime_sniffer.h" |
9 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" | 10 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" |
10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
11 #include "net/base/mime_sniffer.h" | 12 #include "net/base/mime_sniffer.h" |
12 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/http/http_response_headers.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 const int kMaxBytesToSniff = 512; | 18 const int kMaxBytesToSniff = 512; |
17 | 19 |
18 void RecordSnifferMetrics(bool sniffing_blocked, | 20 void RecordSnifferMetrics(bool sniffing_blocked, |
19 bool we_would_like_to_sniff, | 21 bool we_would_like_to_sniff, |
20 const std::string& mime_type) { | 22 const std::string& mime_type) { |
21 static BooleanHistogram nosniff_usage(L"nosniff.usage"); | 23 static BooleanHistogram nosniff_usage(L"nosniff.usage"); |
22 nosniff_usage.SetFlags(kUmaTargetedHistogramFlag); | 24 nosniff_usage.SetFlags(kUmaTargetedHistogramFlag); |
(...skipping 247 matching lines...) Loading... |
270 real_handler_ = download_handler; | 272 real_handler_ = download_handler; |
271 } | 273 } |
272 return real_handler_->OnResponseStarted(request_id, response_); | 274 return real_handler_->OnResponseStarted(request_id, response_); |
273 } | 275 } |
274 | 276 |
275 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { | 277 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { |
276 const int kRequiredLength = 256; | 278 const int kRequiredLength = 256; |
277 | 279 |
278 return bytes_read >= kRequiredLength; | 280 return bytes_read >= kRequiredLength; |
279 } | 281 } |
OLD | NEW |