| 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 "cc/base/histograms.h" | 5 #include "cc/base/histograms.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 8 #include <cmath> | 10 #include <cmath> |
| 9 #include <cstring> | 11 #include <cstring> |
| 10 #include <limits> | 12 #include <limits> |
| 11 | 13 |
| 12 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 13 #include "base/logging.h" | 15 #include "base/logging.h" |
| 14 #include "base/numerics/safe_conversions.h" | 16 #include "base/numerics/safe_conversions.h" |
| 15 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 16 | 18 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 45 if (!old_client_name) | 47 if (!old_client_name) |
| 46 g_client_name = client_name; | 48 g_client_name = client_name; |
| 47 } | 49 } |
| 48 | 50 |
| 49 const char* GetClientNameForMetrics() { | 51 const char* GetClientNameForMetrics() { |
| 50 base::AutoLock auto_lock(g_client_name_lock.Get()); | 52 base::AutoLock auto_lock(g_client_name_lock.Get()); |
| 51 return g_client_name; | 53 return g_client_name; |
| 52 } | 54 } |
| 53 | 55 |
| 54 // Minimum elapsed time of 1us to limit weighting of fast calls. | 56 // Minimum elapsed time of 1us to limit weighting of fast calls. |
| 55 static const int64 kMinimumTimeMicroseconds = 1; | 57 static const int64_t kMinimumTimeMicroseconds = 1; |
| 56 | 58 |
| 57 ScopedUMAHistogramAreaTimerBase::ScopedUMAHistogramAreaTimerBase() : area_(0) { | 59 ScopedUMAHistogramAreaTimerBase::ScopedUMAHistogramAreaTimerBase() : area_(0) { |
| 58 } | 60 } |
| 59 | 61 |
| 60 ScopedUMAHistogramAreaTimerBase::~ScopedUMAHistogramAreaTimerBase() { | 62 ScopedUMAHistogramAreaTimerBase::~ScopedUMAHistogramAreaTimerBase() { |
| 61 } | 63 } |
| 62 | 64 |
| 63 bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues( | 65 bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues( |
| 64 Sample* time_microseconds, | 66 Sample* time_microseconds, |
| 65 Sample* pixels_per_ms) const { | 67 Sample* pixels_per_ms) const { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 80 // It is not clear how NaN can get here, but we've gotten crashes from | 82 // It is not clear how NaN can get here, but we've gotten crashes from |
| 81 // saturated_cast. http://crbug.com/486214 | 83 // saturated_cast. http://crbug.com/486214 |
| 82 if (std::isnan(area_per_time)) | 84 if (std::isnan(area_per_time)) |
| 83 return false; | 85 return false; |
| 84 *time_microseconds = base::saturated_cast<Sample>(elapsed.InMicroseconds()); | 86 *time_microseconds = base::saturated_cast<Sample>(elapsed.InMicroseconds()); |
| 85 *pixels_per_ms = base::saturated_cast<Sample>(area_per_time); | 87 *pixels_per_ms = base::saturated_cast<Sample>(area_per_time); |
| 86 return true; | 88 return true; |
| 87 } | 89 } |
| 88 | 90 |
| 89 } // namespace cc | 91 } // namespace cc |
| OLD | NEW |