| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/logging/stats_event_subscriber.h" | 5 #include "media/cast/logging/stats_event_subscriber.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 size_t index = 1 + (sample - min_) / width_; | 55 size_t index = 1 + (sample - min_) / width_; |
| 56 DCHECK_LT(index, buckets_.size()); | 56 DCHECK_LT(index, buckets_.size()); |
| 57 ++buckets_[index]; | 57 ++buckets_[index]; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 void StatsEventSubscriber::SimpleHistogram::Reset() { | 61 void StatsEventSubscriber::SimpleHistogram::Reset() { |
| 62 buckets_.assign(buckets_.size(), 0); | 62 buckets_.assign(buckets_.size(), 0); |
| 63 } | 63 } |
| 64 | 64 |
| 65 scoped_ptr<base::ListValue> | 65 std::unique_ptr<base::ListValue> |
| 66 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { | 66 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { |
| 67 scoped_ptr<base::ListValue> histo(new base::ListValue); | 67 std::unique_ptr<base::ListValue> histo(new base::ListValue); |
| 68 | 68 |
| 69 scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue); | 69 std::unique_ptr<base::DictionaryValue> bucket(new base::DictionaryValue); |
| 70 | 70 |
| 71 if (buckets_.front()) { | 71 if (buckets_.front()) { |
| 72 bucket->SetInteger(base::StringPrintf("<%" PRId64, min_), | 72 bucket->SetInteger(base::StringPrintf("<%" PRId64, min_), |
| 73 buckets_.front()); | 73 buckets_.front()); |
| 74 histo->Append(bucket.release()); | 74 histo->Append(bucket.release()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 for (size_t i = 1; i < buckets_.size() - 1; i++) { | 77 for (size_t i = 1; i < buckets_.size() - 1; i++) { |
| 78 if (!buckets_[i]) | 78 if (!buckets_[i]) |
| 79 continue; | 79 continue; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } else { | 216 } else { |
| 217 first_event_time_ = std::min(first_event_time_, timestamp); | 217 first_event_time_ = std::min(first_event_time_, timestamp); |
| 218 } | 218 } |
| 219 if (last_event_time_.is_null()) { | 219 if (last_event_time_.is_null()) { |
| 220 last_event_time_ = timestamp; | 220 last_event_time_ = timestamp; |
| 221 } else { | 221 } else { |
| 222 last_event_time_ = std::max(last_event_time_, timestamp); | 222 last_event_time_ = std::max(last_event_time_, timestamp); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 scoped_ptr<base::DictionaryValue> StatsEventSubscriber::GetStats() const { | 226 std::unique_ptr<base::DictionaryValue> StatsEventSubscriber::GetStats() const { |
| 227 StatsMap stats_map; | 227 StatsMap stats_map; |
| 228 GetStatsInternal(&stats_map); | 228 GetStatsInternal(&stats_map); |
| 229 scoped_ptr<base::DictionaryValue> ret(new base::DictionaryValue); | 229 std::unique_ptr<base::DictionaryValue> ret(new base::DictionaryValue); |
| 230 | 230 |
| 231 scoped_ptr<base::DictionaryValue> stats(new base::DictionaryValue); | 231 std::unique_ptr<base::DictionaryValue> stats(new base::DictionaryValue); |
| 232 for (StatsMap::const_iterator it = stats_map.begin(); it != stats_map.end(); | 232 for (StatsMap::const_iterator it = stats_map.begin(); it != stats_map.end(); |
| 233 ++it) { | 233 ++it) { |
| 234 // Round to 3 digits after the decimal point. | 234 // Round to 3 digits after the decimal point. |
| 235 stats->SetDouble(CastStatToString(it->first), | 235 stats->SetDouble(CastStatToString(it->first), |
| 236 round(it->second * 1000.0) / 1000.0); | 236 round(it->second * 1000.0) / 1000.0); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // Populate all histograms. | 239 // Populate all histograms. |
| 240 for (HistogramMap::const_iterator it = histograms_.begin(); | 240 for (HistogramMap::const_iterator it = histograms_.begin(); |
| 241 it != histograms_.end(); | 241 it != histograms_.end(); |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 : event_counter(0), sum_size(0) {} | 747 : event_counter(0), sum_size(0) {} |
| 748 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} | 748 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} |
| 749 | 749 |
| 750 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { | 750 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { |
| 751 } | 751 } |
| 752 StatsEventSubscriber::FrameInfo::~FrameInfo() { | 752 StatsEventSubscriber::FrameInfo::~FrameInfo() { |
| 753 } | 753 } |
| 754 | 754 |
| 755 } // namespace cast | 755 } // namespace cast |
| 756 } // namespace media | 756 } // namespace media |
| OLD | NEW |