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/macros.h" |
7 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
8 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
10 #include "content/browser/download/download_resource_handler.h" | 11 #include "content/browser/download/download_resource_handler.h" |
11 #include "content/public/browser/download_interrupt_reasons.h" | 12 #include "content/public/browser/download_interrupt_reasons.h" |
12 #include "net/http/http_content_disposition.h" | 13 #include "net/http/http_content_disposition.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 namespace { | 17 namespace { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 void RecordDownloadCount(DownloadCountTypes type) { | 336 void RecordDownloadCount(DownloadCountTypes type) { |
336 UMA_HISTOGRAM_ENUMERATION( | 337 UMA_HISTOGRAM_ENUMERATION( |
337 "Download.Counts", type, DOWNLOAD_COUNT_TYPES_LAST_ENTRY); | 338 "Download.Counts", type, DOWNLOAD_COUNT_TYPES_LAST_ENTRY); |
338 } | 339 } |
339 | 340 |
340 void RecordDownloadSource(DownloadSource source) { | 341 void RecordDownloadSource(DownloadSource source) { |
341 UMA_HISTOGRAM_ENUMERATION( | 342 UMA_HISTOGRAM_ENUMERATION( |
342 "Download.Sources", source, DOWNLOAD_SOURCE_LAST_ENTRY); | 343 "Download.Sources", source, DOWNLOAD_SOURCE_LAST_ENTRY); |
343 } | 344 } |
344 | 345 |
345 void RecordDownloadCompleted(const base::TimeTicks& start, int64 download_len) { | 346 void RecordDownloadCompleted(const base::TimeTicks& start, |
| 347 int64_t download_len) { |
346 RecordDownloadCount(COMPLETED_COUNT); | 348 RecordDownloadCount(COMPLETED_COUNT); |
347 UMA_HISTOGRAM_LONG_TIMES("Download.Time", (base::TimeTicks::Now() - start)); | 349 UMA_HISTOGRAM_LONG_TIMES("Download.Time", (base::TimeTicks::Now() - start)); |
348 int64 max = 1024 * 1024 * 1024; // One Terabyte. | 350 int64_t max = 1024 * 1024 * 1024; // One Terabyte. |
349 download_len /= 1024; // In Kilobytes | 351 download_len /= 1024; // In Kilobytes |
350 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", | 352 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", |
351 download_len, | 353 download_len, |
352 1, | 354 1, |
353 max, | 355 max, |
354 256); | 356 256); |
355 } | 357 } |
356 | 358 |
357 void RecordDownloadInterrupted(DownloadInterruptReason reason, | 359 void RecordDownloadInterrupted(DownloadInterruptReason reason, |
358 int64 received, | 360 int64_t received, |
359 int64 total) { | 361 int64_t total) { |
360 RecordDownloadCount(INTERRUPTED_COUNT); | 362 RecordDownloadCount(INTERRUPTED_COUNT); |
361 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 363 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
362 "Download.InterruptedReason", | 364 "Download.InterruptedReason", |
363 reason, | 365 reason, |
364 base::CustomHistogram::ArrayToCustomRanges( | 366 base::CustomHistogram::ArrayToCustomRanges( |
365 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes))); | 367 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes))); |
366 | 368 |
367 // The maximum should be 2^kBuckets, to have the logarithmic bucket | 369 // The maximum should be 2^kBuckets, to have the logarithmic bucket |
368 // boundaries fall on powers of 2. | 370 // boundaries fall on powers of 2. |
369 static const int kBuckets = 30; | 371 static const int kBuckets = 30; |
370 static const int64 kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes. | 372 static const int64_t kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes. |
371 int64 delta_bytes = total - received; | 373 int64_t delta_bytes = total - received; |
372 bool unknown_size = total <= 0; | 374 bool unknown_size = total <= 0; |
373 int64 received_kb = received / 1024; | 375 int64_t received_kb = received / 1024; |
374 int64 total_kb = total / 1024; | 376 int64_t total_kb = total / 1024; |
375 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedReceivedSizeK", | 377 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedReceivedSizeK", |
376 received_kb, | 378 received_kb, |
377 1, | 379 1, |
378 kMaxKb, | 380 kMaxKb, |
379 kBuckets); | 381 kBuckets); |
380 if (!unknown_size) { | 382 if (!unknown_size) { |
381 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedTotalSizeK", | 383 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedTotalSizeK", |
382 total_kb, | 384 total_kb, |
383 1, | 385 1, |
384 kMaxKb, | 386 kMaxKb, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 void RecordDownloadWriteSize(size_t data_len) { | 457 void RecordDownloadWriteSize(size_t data_len) { |
456 int max = 1024 * 1024; // One Megabyte. | 458 int max = 1024 * 1024; // One Megabyte. |
457 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.WriteSize", data_len, 1, max, 256); | 459 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.WriteSize", data_len, 1, max, 256); |
458 } | 460 } |
459 | 461 |
460 void RecordDownloadWriteLoopCount(int count) { | 462 void RecordDownloadWriteLoopCount(int count) { |
461 UMA_HISTOGRAM_ENUMERATION("Download.WriteLoopCount", count, 20); | 463 UMA_HISTOGRAM_ENUMERATION("Download.WriteLoopCount", count, 20); |
462 } | 464 } |
463 | 465 |
464 void RecordAcceptsRanges(const std::string& accepts_ranges, | 466 void RecordAcceptsRanges(const std::string& accepts_ranges, |
465 int64 download_len, | 467 int64_t download_len, |
466 bool has_strong_validator) { | 468 bool has_strong_validator) { |
467 int64 max = 1024 * 1024 * 1024; // One Terabyte. | 469 int64_t max = 1024 * 1024 * 1024; // One Terabyte. |
468 download_len /= 1024; // In Kilobytes | 470 download_len /= 1024; // In Kilobytes |
469 static const int kBuckets = 50; | 471 static const int kBuckets = 50; |
470 | 472 |
471 if (base::LowerCaseEqualsASCII(accepts_ranges, "none")) { | 473 if (base::LowerCaseEqualsASCII(accepts_ranges, "none")) { |
472 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesNone.KBytes", | 474 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesNone.KBytes", |
473 download_len, | 475 download_len, |
474 1, | 476 1, |
475 max, | 477 max, |
476 kBuckets); | 478 kBuckets); |
477 } else if (base::LowerCaseEqualsASCII(accepts_ranges, "bytes")) { | 479 } else if (base::LowerCaseEqualsASCII(accepts_ranges, "bytes")) { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 int state) { | 754 int state) { |
753 if (is_partial) | 755 if (is_partial) |
754 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnPartialResumption", state, | 756 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnPartialResumption", state, |
755 ORIGIN_STATE_ON_RESUMPTION_MAX); | 757 ORIGIN_STATE_ON_RESUMPTION_MAX); |
756 else | 758 else |
757 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnFullResumption", state, | 759 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnFullResumption", state, |
758 ORIGIN_STATE_ON_RESUMPTION_MAX); | 760 ORIGIN_STATE_ON_RESUMPTION_MAX); |
759 } | 761 } |
760 | 762 |
761 } // namespace content | 763 } // namespace content |
OLD | NEW |