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 "base/string_util.h" |
9 #include "net/base/mime_sniffer.h" | 9 #include "net/base/mime_sniffer.h" |
10 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" | 10 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" |
11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
12 #include "net/base/mime_sniffer.h" | 12 #include "net/base/mime_sniffer.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const int kMaxBytesToSniff = 512; | 18 const int kMaxBytesToSniff = 512; |
19 | 19 |
20 void RecordSnifferMetrics(bool sniffing_blocked, | 20 void RecordSnifferMetrics(bool sniffing_blocked, |
21 bool we_would_like_to_sniff, | 21 bool we_would_like_to_sniff, |
22 const std::string& mime_type) { | 22 const std::string& mime_type) { |
23 static BooleanHistogram nosniff_usage(L"nosniff.usage"); | 23 static BooleanHistogram nosniff_usage("nosniff.usage"); |
24 nosniff_usage.SetFlags(kUmaTargetedHistogramFlag); | 24 nosniff_usage.SetFlags(kUmaTargetedHistogramFlag); |
25 nosniff_usage.AddBoolean(sniffing_blocked); | 25 nosniff_usage.AddBoolean(sniffing_blocked); |
26 | 26 |
27 if (sniffing_blocked) { | 27 if (sniffing_blocked) { |
28 static BooleanHistogram nosniff_otherwise(L"nosniff.otherwise"); | 28 static BooleanHistogram nosniff_otherwise("nosniff.otherwise"); |
29 nosniff_otherwise.SetFlags(kUmaTargetedHistogramFlag); | 29 nosniff_otherwise.SetFlags(kUmaTargetedHistogramFlag); |
30 nosniff_otherwise.AddBoolean(we_would_like_to_sniff); | 30 nosniff_otherwise.AddBoolean(we_would_like_to_sniff); |
31 | 31 |
32 static BooleanHistogram nosniff_empty_mime_type(L"nosniff.empty_mime_type"); | 32 static BooleanHistogram nosniff_empty_mime_type("nosniff.empty_mime_type"); |
33 nosniff_empty_mime_type.SetFlags(kUmaTargetedHistogramFlag); | 33 nosniff_empty_mime_type.SetFlags(kUmaTargetedHistogramFlag); |
34 nosniff_empty_mime_type.AddBoolean(mime_type.empty()); | 34 nosniff_empty_mime_type.AddBoolean(mime_type.empty()); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 BufferedResourceHandler::BufferedResourceHandler(ResourceHandler* handler, | 40 BufferedResourceHandler::BufferedResourceHandler(ResourceHandler* handler, |
41 ResourceDispatcherHost* host, | 41 ResourceDispatcherHost* host, |
42 URLRequest* request) | 42 URLRequest* request) |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 real_handler_ = download_handler; | 272 real_handler_ = download_handler; |
273 } | 273 } |
274 return real_handler_->OnResponseStarted(request_id, response_); | 274 return real_handler_->OnResponseStarted(request_id, response_); |
275 } | 275 } |
276 | 276 |
277 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { | 277 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { |
278 const int kRequiredLength = 256; | 278 const int kRequiredLength = 256; |
279 | 279 |
280 return bytes_read >= kRequiredLength; | 280 return bytes_read >= kRequiredLength; |
281 } | 281 } |
OLD | NEW |