| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/safe_browsing/srt_fetcher_win.h" | 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 // histogram name. The UMA_HISTOGRAM macros can't be used because they | 446 // histogram name. The UMA_HISTOGRAM macros can't be used because they |
| 447 // require a constant string. | 447 // require a constant string. |
| 448 | 448 |
| 449 std::string FullName(const std::string& name) const { | 449 std::string FullName(const std::string& name) const { |
| 450 if (suffix_.empty()) | 450 if (suffix_.empty()) |
| 451 return name; | 451 return name; |
| 452 return base::StringPrintf("%s_%s", name.c_str(), suffix_.c_str()); | 452 return base::StringPrintf("%s_%s", name.c_str(), suffix_.c_str()); |
| 453 } | 453 } |
| 454 | 454 |
| 455 void RecordBooleanHistogram(const std::string& name, bool sample) const { | 455 void RecordBooleanHistogram(const std::string& name, bool sample) const { |
| 456 auto histogram = | 456 auto* histogram = |
| 457 base::BooleanHistogram::FactoryGet(FullName(name), kUmaHistogramFlag); | 457 base::BooleanHistogram::FactoryGet(FullName(name), kUmaHistogramFlag); |
| 458 if (histogram) | 458 if (histogram) |
| 459 histogram->AddBoolean(sample); | 459 histogram->AddBoolean(sample); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void RecordEnumerationHistogram(const std::string& name, | 462 void RecordEnumerationHistogram(const std::string& name, |
| 463 Sample sample, | 463 Sample sample, |
| 464 Sample boundary) const { | 464 Sample boundary) const { |
| 465 // See HISTOGRAM_ENUMERATION_WITH_FLAG for the parameters to |FactoryGet|. | 465 // See HISTOGRAM_ENUMERATION_WITH_FLAG for the parameters to |FactoryGet|. |
| 466 auto histogram = base::LinearHistogram::FactoryGet( | 466 auto* histogram = base::LinearHistogram::FactoryGet( |
| 467 FullName(name), 1, boundary, boundary + 1, kUmaHistogramFlag); | 467 FullName(name), 1, boundary, boundary + 1, kUmaHistogramFlag); |
| 468 if (histogram) | 468 if (histogram) |
| 469 histogram->Add(sample); | 469 histogram->Add(sample); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void RecordLongTimesHistogram(const std::string& name, | 472 void RecordLongTimesHistogram(const std::string& name, |
| 473 const base::TimeDelta& sample) const { | 473 const base::TimeDelta& sample) const { |
| 474 // See UMA_HISTOGRAM_LONG_TIMES for the parameters to |FactoryTimeGet|. | 474 // See UMA_HISTOGRAM_LONG_TIMES for the parameters to |FactoryTimeGet|. |
| 475 auto histogram = base::Histogram::FactoryTimeGet( | 475 auto* histogram = base::Histogram::FactoryTimeGet( |
| 476 FullName(name), base::TimeDelta::FromMilliseconds(1), | 476 FullName(name), base::TimeDelta::FromMilliseconds(1), |
| 477 base::TimeDelta::FromHours(1), 100, kUmaHistogramFlag); | 477 base::TimeDelta::FromHours(1), 100, kUmaHistogramFlag); |
| 478 if (histogram) | 478 if (histogram) |
| 479 histogram->AddTime(sample); | 479 histogram->AddTime(sample); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void RecordMemoryKBHistogram(const std::string& name, Sample sample) const { | 482 void RecordMemoryKBHistogram(const std::string& name, Sample sample) const { |
| 483 // See UMA_HISTOGRAM_MEMORY_KB for the parameters to |FactoryGet|. | 483 // See UMA_HISTOGRAM_MEMORY_KB for the parameters to |FactoryGet|. |
| 484 auto histogram = base::Histogram::FactoryGet(FullName(name), 1000, 500000, | 484 auto* histogram = base::Histogram::FactoryGet(FullName(name), 1000, 500000, |
| 485 50, kUmaHistogramFlag); | 485 50, kUmaHistogramFlag); |
| 486 if (histogram) | 486 if (histogram) |
| 487 histogram->Add(sample); | 487 histogram->Add(sample); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void RecordSparseHistogram(const std::string& name, Sample sample) const { | 490 void RecordSparseHistogram(const std::string& name, Sample sample) const { |
| 491 auto histogram = | 491 auto* histogram = |
| 492 base::SparseHistogram::FactoryGet(FullName(name), kUmaHistogramFlag); | 492 base::SparseHistogram::FactoryGet(FullName(name), kUmaHistogramFlag); |
| 493 if (histogram) | 493 if (histogram) |
| 494 histogram->Add(sample); | 494 histogram->Add(sample); |
| 495 } | 495 } |
| 496 | 496 |
| 497 void RecordSparseHistogramCount(const std::string& name, | 497 void RecordSparseHistogramCount(const std::string& name, |
| 498 Sample sample, | 498 Sample sample, |
| 499 int count) const { | 499 int count) const { |
| 500 auto histogram = | 500 auto* histogram = |
| 501 base::SparseHistogram::FactoryGet(FullName(name), kUmaHistogramFlag); | 501 base::SparseHistogram::FactoryGet(FullName(name), kUmaHistogramFlag); |
| 502 if (histogram) | 502 if (histogram) |
| 503 histogram->AddCount(sample, count); | 503 histogram->AddCount(sample, count); |
| 504 } | 504 } |
| 505 | 505 |
| 506 const std::string suffix_; | 506 const std::string suffix_; |
| 507 const std::wstring registry_key_; | 507 const std::wstring registry_key_; |
| 508 }; | 508 }; |
| 509 | 509 |
| 510 // Records the reporter step without a suffix. (For steps that are never run by | 510 // Records the reporter step without a suffix. (For steps that are never run by |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), | 1079 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), |
| 1080 KEY_QUERY_VALUE) == ERROR_SUCCESS && | 1080 KEY_QUERY_VALUE) == ERROR_SUCCESS && |
| 1081 srt_cleaner_key.GetValueCount() > 0; | 1081 srt_cleaner_key.GetValueCount() > 0; |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { | 1084 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { |
| 1085 g_testing_delegate_ = delegate; | 1085 g_testing_delegate_ = delegate; |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 } // namespace safe_browsing | 1088 } // namespace safe_browsing |
| OLD | NEW |