OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/download/download_stats.h" | 5 #include "content/browser/download/download_stats.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "content/browser/download/download_resource_handler.h" | 10 #include "content/browser/download/download_resource_handler.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 }; | 24 }; |
25 | 25 |
26 // These values are based on net::HttpContentDisposition::ParseResult values. | 26 // These values are based on net::HttpContentDisposition::ParseResult values. |
27 // Values other than HEADER_PRESENT and IS_VALID are only measured if |IS_VALID| | 27 // Values other than HEADER_PRESENT and IS_VALID are only measured if |IS_VALID| |
28 // is true. | 28 // is true. |
29 enum ContentDispositionCountTypes { | 29 enum ContentDispositionCountTypes { |
30 // Count of downloads which had a Content-Disposition headers. The total | 30 // Count of downloads which had a Content-Disposition headers. The total |
31 // number of downloads is measured by UNTHROTTLED_COUNT. | 31 // number of downloads is measured by UNTHROTTLED_COUNT. |
32 CONTENT_DISPOSITION_HEADER_PRESENT = 0, | 32 CONTENT_DISPOSITION_HEADER_PRESENT = 0, |
33 | 33 |
34 // At least one of 'name', 'filename' or 'filenae*' attributes were valid and | 34 // Either 'filename' or 'filename*' attributes were valid and |
35 // yielded a non-empty filename. | 35 // yielded a non-empty filename. |
36 CONTENT_DISPOSITION_IS_VALID, | 36 CONTENT_DISPOSITION_IS_VALID, |
37 | 37 |
38 // The following enum values correspond to | 38 // The following enum values correspond to |
39 // net::HttpContentDisposition::ParseResult. | 39 // net::HttpContentDisposition::ParseResult. |
40 CONTENT_DISPOSITION_HAS_DISPOSITION_TYPE, | 40 CONTENT_DISPOSITION_HAS_DISPOSITION_TYPE, |
41 CONTENT_DISPOSITION_HAS_UNKNOWN_TYPE, | 41 CONTENT_DISPOSITION_HAS_UNKNOWN_TYPE, |
42 CONTENT_DISPOSITION_HAS_NAME, | 42 |
| 43 CONTENT_DISPOSITION_HAS_NAME, // Obsolete; kept for UMA compatiblity. |
| 44 |
43 CONTENT_DISPOSITION_HAS_FILENAME, | 45 CONTENT_DISPOSITION_HAS_FILENAME, |
44 CONTENT_DISPOSITION_HAS_EXT_FILENAME, | 46 CONTENT_DISPOSITION_HAS_EXT_FILENAME, |
45 CONTENT_DISPOSITION_HAS_NON_ASCII_STRINGS, | 47 CONTENT_DISPOSITION_HAS_NON_ASCII_STRINGS, |
46 CONTENT_DISPOSITION_HAS_PERCENT_ENCODED_STRINGS, | 48 CONTENT_DISPOSITION_HAS_PERCENT_ENCODED_STRINGS, |
47 CONTENT_DISPOSITION_HAS_RFC2047_ENCODED_STRINGS, | 49 CONTENT_DISPOSITION_HAS_RFC2047_ENCODED_STRINGS, |
48 | 50 |
49 // Only have the 'name' attribute is present. | 51 CONTENT_DISPOSITION_HAS_NAME_ONLY, // Obsolete; kept for UMA compatiblity. |
50 CONTENT_DISPOSITION_HAS_NAME_ONLY, | |
51 | 52 |
52 CONTENT_DISPOSITION_LAST_ENTRY | 53 CONTENT_DISPOSITION_LAST_ENTRY |
53 }; | 54 }; |
54 | 55 |
55 void RecordContentDispositionCount(ContentDispositionCountTypes type, | 56 void RecordContentDispositionCount(ContentDispositionCountTypes type, |
56 bool record) { | 57 bool record) { |
57 if (!record) | 58 if (!record) |
58 return; | 59 return; |
59 UMA_HISTOGRAM_ENUMERATION( | 60 UMA_HISTOGRAM_ENUMERATION( |
60 "Download.ContentDisposition", type, CONTENT_DISPOSITION_LAST_ENTRY); | 61 "Download.ContentDisposition", type, CONTENT_DISPOSITION_LAST_ENTRY); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 if (!is_valid) | 499 if (!is_valid) |
499 return; | 500 return; |
500 | 501 |
501 RecordContentDispositionCountFlag( | 502 RecordContentDispositionCountFlag( |
502 CONTENT_DISPOSITION_HAS_DISPOSITION_TYPE, result, | 503 CONTENT_DISPOSITION_HAS_DISPOSITION_TYPE, result, |
503 net::HttpContentDisposition::HAS_DISPOSITION_TYPE); | 504 net::HttpContentDisposition::HAS_DISPOSITION_TYPE); |
504 RecordContentDispositionCountFlag( | 505 RecordContentDispositionCountFlag( |
505 CONTENT_DISPOSITION_HAS_UNKNOWN_TYPE, result, | 506 CONTENT_DISPOSITION_HAS_UNKNOWN_TYPE, result, |
506 net::HttpContentDisposition::HAS_UNKNOWN_DISPOSITION_TYPE); | 507 net::HttpContentDisposition::HAS_UNKNOWN_DISPOSITION_TYPE); |
507 RecordContentDispositionCountFlag( | 508 RecordContentDispositionCountFlag( |
508 CONTENT_DISPOSITION_HAS_NAME, result, | |
509 net::HttpContentDisposition::HAS_NAME); | |
510 RecordContentDispositionCountFlag( | |
511 CONTENT_DISPOSITION_HAS_FILENAME, result, | 509 CONTENT_DISPOSITION_HAS_FILENAME, result, |
512 net::HttpContentDisposition::HAS_FILENAME); | 510 net::HttpContentDisposition::HAS_FILENAME); |
513 RecordContentDispositionCountFlag( | 511 RecordContentDispositionCountFlag( |
514 CONTENT_DISPOSITION_HAS_EXT_FILENAME, result, | 512 CONTENT_DISPOSITION_HAS_EXT_FILENAME, result, |
515 net::HttpContentDisposition::HAS_EXT_FILENAME); | 513 net::HttpContentDisposition::HAS_EXT_FILENAME); |
516 RecordContentDispositionCountFlag( | 514 RecordContentDispositionCountFlag( |
517 CONTENT_DISPOSITION_HAS_NON_ASCII_STRINGS, result, | 515 CONTENT_DISPOSITION_HAS_NON_ASCII_STRINGS, result, |
518 net::HttpContentDisposition::HAS_NON_ASCII_STRINGS); | 516 net::HttpContentDisposition::HAS_NON_ASCII_STRINGS); |
519 RecordContentDispositionCountFlag( | 517 RecordContentDispositionCountFlag( |
520 CONTENT_DISPOSITION_HAS_PERCENT_ENCODED_STRINGS, result, | 518 CONTENT_DISPOSITION_HAS_PERCENT_ENCODED_STRINGS, result, |
521 net::HttpContentDisposition::HAS_PERCENT_ENCODED_STRINGS); | 519 net::HttpContentDisposition::HAS_PERCENT_ENCODED_STRINGS); |
522 RecordContentDispositionCountFlag( | 520 RecordContentDispositionCountFlag( |
523 CONTENT_DISPOSITION_HAS_RFC2047_ENCODED_STRINGS, result, | 521 CONTENT_DISPOSITION_HAS_RFC2047_ENCODED_STRINGS, result, |
524 net::HttpContentDisposition::HAS_RFC2047_ENCODED_STRINGS); | 522 net::HttpContentDisposition::HAS_RFC2047_ENCODED_STRINGS); |
525 | |
526 RecordContentDispositionCount( | |
527 CONTENT_DISPOSITION_HAS_NAME_ONLY, | |
528 (result & (net::HttpContentDisposition::HAS_NAME | | |
529 net::HttpContentDisposition::HAS_FILENAME | | |
530 net::HttpContentDisposition::HAS_EXT_FILENAME)) == | |
531 net::HttpContentDisposition::HAS_NAME); | |
532 } | 523 } |
533 | 524 |
534 void RecordFileThreadReceiveBuffers(size_t num_buffers) { | 525 void RecordFileThreadReceiveBuffers(size_t num_buffers) { |
535 UMA_HISTOGRAM_CUSTOM_COUNTS( | 526 UMA_HISTOGRAM_CUSTOM_COUNTS( |
536 "Download.FileThreadReceiveBuffers", num_buffers, 1, | 527 "Download.FileThreadReceiveBuffers", num_buffers, 1, |
537 100, 100); | 528 100, 100); |
538 } | 529 } |
539 | 530 |
540 void RecordBandwidth(double actual_bandwidth, double potential_bandwidth) { | 531 void RecordBandwidth(double actual_bandwidth, double potential_bandwidth) { |
541 UMA_HISTOGRAM_CUSTOM_COUNTS( | 532 UMA_HISTOGRAM_CUSTOM_COUNTS( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 int state) { | 624 int state) { |
634 if (is_partial) | 625 if (is_partial) |
635 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnPartialResumption", state, | 626 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnPartialResumption", state, |
636 ORIGIN_STATE_ON_RESUMPTION_MAX); | 627 ORIGIN_STATE_ON_RESUMPTION_MAX); |
637 else | 628 else |
638 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnFullResumption", state, | 629 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnFullResumption", state, |
639 ORIGIN_STATE_ON_RESUMPTION_MAX); | 630 ORIGIN_STATE_ON_RESUMPTION_MAX); |
640 } | 631 } |
641 | 632 |
642 } // namespace content | 633 } // namespace content |
OLD | NEW |