| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/metrics_handler.h" | 5 #include "chrome/browser/ui/webui/metrics_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 int int_value = static_cast<int>(value); | 57 int int_value = static_cast<int>(value); |
| 58 int int_boundary_value = static_cast<int>(boundary_value); | 58 int int_boundary_value = static_cast<int>(boundary_value); |
| 59 if (int_boundary_value >= 4000 || | 59 if (int_boundary_value >= 4000 || |
| 60 int_value > int_boundary_value || | 60 int_value > int_boundary_value || |
| 61 int_value < 0) { | 61 int_value < 0) { |
| 62 NOTREACHED(); | 62 NOTREACHED(); |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 | 65 |
| 66 int bucket_count = int_boundary_value; | 66 int bucket_count = int_boundary_value; |
| 67 while (bucket_count >= 100) { | 67 while (bucket_count > 100) { |
| 68 bucket_count /= 10; | 68 bucket_count /= 10; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // As |histogram_name| may change between calls, the UMA_HISTOGRAM_ENUMERATION | 71 // As |histogram_name| may change between calls, the UMA_HISTOGRAM_ENUMERATION |
| 72 // macro cannot be used here. | 72 // macro cannot be used here. |
| 73 base::Histogram* counter = | 73 base::Histogram* counter = |
| 74 base::LinearHistogram::FactoryGet( | 74 base::LinearHistogram::FactoryGet( |
| 75 histogram_name, 1, int_boundary_value, bucket_count + 1, | 75 histogram_name, 1, int_boundary_value, bucket_count + 1, |
| 76 base::Histogram::kUmaTargetedHistogramFlag); | 76 base::Histogram::kUmaTargetedHistogramFlag); |
| 77 counter->Add(int_value); | 77 counter->Add(int_value); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 99 // The new tab page has finished loading; reset it. | 99 // The new tab page has finished loading; reset it. |
| 100 tab->SetNewTabStartTime(base::TimeTicks()); | 100 tab->SetNewTabStartTime(base::TimeTicks()); |
| 101 } else { | 101 } else { |
| 102 NOTREACHED(); | 102 NOTREACHED(); |
| 103 } | 103 } |
| 104 content::NotificationService::current()->Notify( | 104 content::NotificationService::current()->Notify( |
| 105 chrome::NOTIFICATION_METRIC_EVENT_DURATION, | 105 chrome::NOTIFICATION_METRIC_EVENT_DURATION, |
| 106 content::Source<WebContents>(tab), | 106 content::Source<WebContents>(tab), |
| 107 content::Details<MetricEventDurationDetails>(&details)); | 107 content::Details<MetricEventDurationDetails>(&details)); |
| 108 } | 108 } |
| OLD | NEW |