| 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 #include <utility> |
| 9 | 10 |
| 10 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 | 15 |
| 15 #define STAT_ENUM_TO_STRING(enum) \ | 16 #define STAT_ENUM_TO_STRING(enum) \ |
| 16 case enum: \ | 17 case enum: \ |
| 17 return #enum | 18 return #enum |
| 18 | 19 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 65 |
| 65 std::unique_ptr<base::ListValue> | 66 std::unique_ptr<base::ListValue> |
| 66 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { | 67 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { |
| 67 std::unique_ptr<base::ListValue> histo(new base::ListValue); | 68 std::unique_ptr<base::ListValue> histo(new base::ListValue); |
| 68 | 69 |
| 69 std::unique_ptr<base::DictionaryValue> bucket(new base::DictionaryValue); | 70 std::unique_ptr<base::DictionaryValue> bucket(new base::DictionaryValue); |
| 70 | 71 |
| 71 if (buckets_.front()) { | 72 if (buckets_.front()) { |
| 72 bucket->SetInteger(base::StringPrintf("<%" PRId64, min_), | 73 bucket->SetInteger(base::StringPrintf("<%" PRId64, min_), |
| 73 buckets_.front()); | 74 buckets_.front()); |
| 74 histo->Append(bucket.release()); | 75 histo->Append(std::move(bucket)); |
| 75 } | 76 } |
| 76 | 77 |
| 77 for (size_t i = 1; i < buckets_.size() - 1; i++) { | 78 for (size_t i = 1; i < buckets_.size() - 1; i++) { |
| 78 if (!buckets_[i]) | 79 if (!buckets_[i]) |
| 79 continue; | 80 continue; |
| 80 bucket.reset(new base::DictionaryValue); | 81 bucket.reset(new base::DictionaryValue); |
| 81 int64_t lower = min_ + (i - 1) * width_; | 82 int64_t lower = min_ + (i - 1) * width_; |
| 82 int64_t upper = lower + width_ - 1; | 83 int64_t upper = lower + width_ - 1; |
| 83 bucket->SetInteger( | 84 bucket->SetInteger( |
| 84 base::StringPrintf("%" PRId64 "-%" PRId64, lower, upper), | 85 base::StringPrintf("%" PRId64 "-%" PRId64, lower, upper), |
| 85 buckets_[i]); | 86 buckets_[i]); |
| 86 histo->Append(bucket.release()); | 87 histo->Append(std::move(bucket)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 if (buckets_.back()) { | 90 if (buckets_.back()) { |
| 90 bucket.reset(new base::DictionaryValue); | 91 bucket.reset(new base::DictionaryValue); |
| 91 bucket->SetInteger(base::StringPrintf(">=%" PRId64, max_), | 92 bucket->SetInteger(base::StringPrintf(">=%" PRId64, max_), |
| 92 buckets_.back()); | 93 buckets_.back()); |
| 93 histo->Append(bucket.release()); | 94 histo->Append(std::move(bucket)); |
| 94 } | 95 } |
| 95 return histo; | 96 return histo; |
| 96 } | 97 } |
| 97 | 98 |
| 98 StatsEventSubscriber::StatsEventSubscriber( | 99 StatsEventSubscriber::StatsEventSubscriber( |
| 99 EventMediaType event_media_type, | 100 EventMediaType event_media_type, |
| 100 base::TickClock* clock, | 101 base::TickClock* clock, |
| 101 ReceiverTimeOffsetEstimator* offset_estimator) | 102 ReceiverTimeOffsetEstimator* offset_estimator) |
| 102 : event_media_type_(event_media_type), | 103 : event_media_type_(event_media_type), |
| 103 clock_(clock), | 104 clock_(clock), |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 : event_counter(0), sum_size(0) {} | 748 : event_counter(0), sum_size(0) {} |
| 748 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} | 749 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} |
| 749 | 750 |
| 750 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { | 751 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { |
| 751 } | 752 } |
| 752 StatsEventSubscriber::FrameInfo::~FrameInfo() { | 753 StatsEventSubscriber::FrameInfo::~FrameInfo() { |
| 753 } | 754 } |
| 754 | 755 |
| 755 } // namespace cast | 756 } // namespace cast |
| 756 } // namespace media | 757 } // namespace media |
| OLD | NEW |