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 "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 size_t index = 1 + (sample - min_) / width_; | 52 size_t index = 1 + (sample - min_) / width_; |
53 DCHECK_LT(index, buckets_.size()); | 53 DCHECK_LT(index, buckets_.size()); |
54 ++buckets_[index]; | 54 ++buckets_[index]; |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void StatsEventSubscriber::SimpleHistogram::Reset() { | 58 void StatsEventSubscriber::SimpleHistogram::Reset() { |
59 buckets_.assign(buckets_.size(), 0); | 59 buckets_.assign(buckets_.size(), 0); |
60 } | 60 } |
61 | 61 |
62 scoped_ptr<base::ListValue> | 62 scoped_ptr<base::DictionaryValue> |
imcheng
2014/09/18 22:06:20
The problem with this approach is that the buckets
| |
63 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { | 63 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { |
64 scoped_ptr<base::ListValue> histo(new base::ListValue); | 64 scoped_ptr<base::DictionaryValue> histo(new base::DictionaryValue); |
65 | 65 histo->SetInteger(base::StringPrintf("< %" PRId64, min_), buckets_.front()); |
66 scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue); | |
67 | |
68 bucket->SetString("bucket", base::StringPrintf("< %" PRId64, min_)); | |
69 bucket->SetInteger("count", buckets_.front()); | |
70 histo->Append(bucket.release()); | |
71 | 66 |
72 for (size_t i = 1; i < buckets_.size() - 1; i++) { | 67 for (size_t i = 1; i < buckets_.size() - 1; i++) { |
73 bucket.reset(new base::DictionaryValue); | |
74 | |
75 int64 lower = min_ + (i - 1) * width_; | 68 int64 lower = min_ + (i - 1) * width_; |
76 int64 upper = lower + width_ - 1; | 69 int64 upper = lower + width_ - 1; |
77 bucket->SetString( | 70 histo->SetInteger( |
78 "bucket", base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper)); | 71 base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper), |
79 bucket->SetInteger("count", buckets_[i]); | 72 buckets_[i]); |
80 histo->Append(bucket.release()); | |
81 } | 73 } |
82 | 74 |
83 bucket.reset(new base::DictionaryValue); | 75 histo->SetInteger(base::StringPrintf(">= %" PRId64, max_), buckets_.back()); |
84 | |
85 bucket->SetString("bucket", base::StringPrintf(">= %" PRId64, max_)); | |
86 bucket->SetInteger("count", buckets_.back()); | |
87 histo->Append(bucket.release()); | |
88 | |
89 return histo.Pass(); | 76 return histo.Pass(); |
90 } | 77 } |
91 | 78 |
92 StatsEventSubscriber::StatsEventSubscriber( | 79 StatsEventSubscriber::StatsEventSubscriber( |
93 EventMediaType event_media_type, | 80 EventMediaType event_media_type, |
94 base::TickClock* clock, | 81 base::TickClock* clock, |
95 ReceiverTimeOffsetEstimator* offset_estimator) | 82 ReceiverTimeOffsetEstimator* offset_estimator) |
96 : event_media_type_(event_media_type), | 83 : event_media_type_(event_media_type), |
97 clock_(clock), | 84 clock_(clock), |
98 offset_estimator_(offset_estimator), | 85 offset_estimator_(offset_estimator), |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 : event_counter(0), sum_size(0) {} | 636 : event_counter(0), sum_size(0) {} |
650 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} | 637 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} |
651 | 638 |
652 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { | 639 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { |
653 } | 640 } |
654 StatsEventSubscriber::FrameInfo::~FrameInfo() { | 641 StatsEventSubscriber::FrameInfo::~FrameInfo() { |
655 } | 642 } |
656 | 643 |
657 } // namespace cast | 644 } // namespace cast |
658 } // namespace media | 645 } // namespace media |
OLD | NEW |