Chromium Code Reviews| Index: media/cast/logging/stats_event_subscriber.cc |
| diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc |
| index b9cf26532f24e89b4e82f64e7c12e3e4e87069d5..b74949a5a32411600fda85493a2b8b5cf694dea5 100644 |
| --- a/media/cast/logging/stats_event_subscriber.cc |
| +++ b/media/cast/logging/stats_event_subscriber.cc |
| @@ -65,25 +65,32 @@ StatsEventSubscriber::SimpleHistogram::GetHistogram() const { |
| scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue); |
| - bucket->SetString("bucket", base::StringPrintf("< %" PRId64, min_)); |
| - bucket->SetInteger("count", buckets_.front()); |
| + bucket->SetInteger(base::StringPrintf("< %" PRId64, min_), |
|
imcheng
2014/09/19 20:48:14
I think you can also get rid of the spaces between
Alpha Left Google
2014/09/19 20:57:55
Done.
|
| + buckets_.front()); |
| histo->Append(bucket.release()); |
| - for (size_t i = 1; i < buckets_.size() - 1; i++) { |
| + size_t index = 1; |
| + while (index < buckets_.size() - 1) { |
| bucket.reset(new base::DictionaryValue); |
| + size_t end_index = index; |
| - int64 lower = min_ + (i - 1) * width_; |
| - int64 upper = lower + width_ - 1; |
| - bucket->SetString( |
| - "bucket", base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper)); |
| - bucket->SetInteger("count", buckets_[i]); |
| + // Find as many consecutive zero buckets as possible. |
| + if (!buckets_[index]) { |
|
imcheng
2014/09/19 20:52:33
nit: prefer explicitly checking != 0.
Alpha Left Google
2014/09/19 20:57:55
Done.
|
| + while (end_index + 2 < buckets_.size() && !buckets_[end_index + 1]) |
|
imcheng
2014/09/19 20:52:33
ditto
Alpha Left Google
2014/09/19 20:57:55
Done.
|
| + ++end_index; |
| + } |
| + int64 lower = min_ + (index - 1) * width_; |
| + int64 upper = min_ + end_index * width_ - 1; |
|
imcheng
2014/09/19 20:52:33
Shouldn't this be min_ + (end_index - index) * wid
imcheng
2014/09/19 20:53:56
Never mind, I misread this.
|
| + bucket->SetInteger( |
| + base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper), |
| + buckets_[index]); |
| + index = end_index + 1; |
| histo->Append(bucket.release()); |
| } |
| bucket.reset(new base::DictionaryValue); |
| - |
| - bucket->SetString("bucket", base::StringPrintf(">= %" PRId64, max_)); |
| - bucket->SetInteger("count", buckets_.back()); |
| + bucket->SetInteger(base::StringPrintf(">= %" PRId64, max_), |
| + buckets_.back()); |
| histo->Append(bucket.release()); |
| return histo.Pass(); |