| OLD | NEW |
| 1 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 1 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the LICENSE file in the root of the source | 4 // that can be found in the LICENSE file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // | 8 // |
| 9 | 9 |
| 10 #include "webrtc/system_wrappers/include/metrics_default.h" | 10 #include "webrtc/system_wrappers/include/metrics_default.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 int MinSample() const { | 87 int MinSample() const { |
| 88 rtc::CritScope cs(&crit_); | 88 rtc::CritScope cs(&crit_); |
| 89 return (info_.samples.empty()) ? -1 : info_.samples.begin()->first; | 89 return (info_.samples.empty()) ? -1 : info_.samples.begin()->first; |
| 90 } | 90 } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 rtc::CriticalSection crit_; | 93 rtc::CriticalSection crit_; |
| 94 const int min_; | 94 const int min_; |
| 95 const int max_; | 95 const int max_; |
| 96 SampleInfo info_ GUARDED_BY(crit_); | 96 SampleInfo info_ RTC_GUARDED_BY(crit_); |
| 97 | 97 |
| 98 RTC_DISALLOW_COPY_AND_ASSIGN(RtcHistogram); | 98 RTC_DISALLOW_COPY_AND_ASSIGN(RtcHistogram); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 class RtcHistogramMap { | 101 class RtcHistogramMap { |
| 102 public: | 102 public: |
| 103 RtcHistogramMap() {} | 103 RtcHistogramMap() {} |
| 104 ~RtcHistogramMap() {} | 104 ~RtcHistogramMap() {} |
| 105 | 105 |
| 106 Histogram* GetCountsHistogram(const std::string& name, | 106 Histogram* GetCountsHistogram(const std::string& name, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 int MinSample(const std::string& name) const { | 160 int MinSample(const std::string& name) const { |
| 161 rtc::CritScope cs(&crit_); | 161 rtc::CritScope cs(&crit_); |
| 162 const auto& it = map_.find(name); | 162 const auto& it = map_.find(name); |
| 163 return (it == map_.end()) ? -1 : it->second->MinSample(); | 163 return (it == map_.end()) ? -1 : it->second->MinSample(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 private: | 166 private: |
| 167 rtc::CriticalSection crit_; | 167 rtc::CriticalSection crit_; |
| 168 std::map<std::string, std::unique_ptr<RtcHistogram>> map_ GUARDED_BY(crit_); | 168 std::map<std::string, std::unique_ptr<RtcHistogram>> map_ |
| 169 RTC_GUARDED_BY(crit_); |
| 169 | 170 |
| 170 RTC_DISALLOW_COPY_AND_ASSIGN(RtcHistogramMap); | 171 RTC_DISALLOW_COPY_AND_ASSIGN(RtcHistogramMap); |
| 171 }; | 172 }; |
| 172 | 173 |
| 173 // RtcHistogramMap is allocated upon call to Enable(). | 174 // RtcHistogramMap is allocated upon call to Enable(). |
| 174 // The histogram getter functions, which return pointer values to the histograms | 175 // The histogram getter functions, which return pointer values to the histograms |
| 175 // in the map, are cached in WebRTC. Therefore, this memory is not freed by the | 176 // in the map, are cached in WebRTC. Therefore, this memory is not freed by the |
| 176 // application (the memory will be reclaimed by the OS). | 177 // application (the memory will be reclaimed by the OS). |
| 177 static RtcHistogramMap* volatile g_rtc_histogram_map = nullptr; | 178 static RtcHistogramMap* volatile g_rtc_histogram_map = nullptr; |
| 178 | 179 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 return map ? map->NumSamples(name) : 0; | 299 return map ? map->NumSamples(name) : 0; |
| 299 } | 300 } |
| 300 | 301 |
| 301 int MinSample(const std::string& name) { | 302 int MinSample(const std::string& name) { |
| 302 RtcHistogramMap* map = GetMap(); | 303 RtcHistogramMap* map = GetMap(); |
| 303 return map ? map->MinSample(name) : -1; | 304 return map ? map->MinSample(name) : -1; |
| 304 } | 305 } |
| 305 | 306 |
| 306 } // namespace metrics | 307 } // namespace metrics |
| 307 } // namespace webrtc | 308 } // namespace webrtc |
| OLD | NEW |