Chromium Code Reviews| Index: media/cast/logging/stats_converter.cc |
| diff --git a/media/cast/logging/stats_converter.cc b/media/cast/logging/stats_converter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a802275bd7aa61ac3d83cf06783b75e1e8908706 |
| --- /dev/null |
| +++ b/media/cast/logging/stats_converter.cc |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/cast/logging/stats_converter.h" |
| + |
| +#include "base/json/json_writer.h" |
| +#include "base/values.h" |
| + |
| +namespace media { |
| +namespace cast { |
| + |
| +scoped_ptr<base::DictionaryValue> ConvertStats( |
|
Alpha Left Google
2014/03/04 21:13:35
Move this to logging_stats.cc?
imcheng
2014/03/05 00:20:26
Done.
|
| + const FrameStatsMap& frame_stats_map, |
| + const PacketStatsMap& packet_stats_map) { |
| + scoped_ptr<base::DictionaryValue> overall_stats(new base::DictionaryValue); |
| + |
| + scoped_ptr<base::DictionaryValue> overall_frame_stats( |
| + new base::DictionaryValue); |
| + for (FrameStatsMap::const_iterator it = frame_stats_map.begin(); |
| + it != frame_stats_map.end(); |
| + ++it) { |
| + scoped_ptr<base::DictionaryValue> frame_stats(new base::DictionaryValue); |
| + |
| + frame_stats->SetDouble("firstEventTime", |
| + it->second.first_event_time.ToInternalValue()); |
| + frame_stats->SetDouble("lastEventTime", |
| + it->second.last_event_time.ToInternalValue()); |
| + frame_stats->SetInteger("count", it->second.event_counter); |
| + frame_stats->SetInteger("sizeTotal", it->second.sum_size); |
| + frame_stats->SetInteger("minDelayMs", |
| + it->second.min_delay.InMilliseconds()); |
| + frame_stats->SetInteger("maxDelayMs", |
| + it->second.max_delay.InMilliseconds()); |
| + frame_stats->SetInteger("sumDelayMs", |
| + it->second.sum_delay.InMilliseconds()); |
| + |
| + overall_frame_stats->Set(CastLoggingToString(it->first), |
| + frame_stats.release()); |
| + } |
| + |
| + overall_stats->Set("frameStats", overall_frame_stats.release()); |
| + |
| + scoped_ptr<base::DictionaryValue> overall_packet_stats( |
| + new base::DictionaryValue); |
| + for (PacketStatsMap::const_iterator it = packet_stats_map.begin(); |
| + it != packet_stats_map.end(); |
| + ++it) { |
| + scoped_ptr<base::DictionaryValue> packet_stats(new base::DictionaryValue); |
| + |
| + packet_stats->SetDouble("firstEventTime", |
| + it->second.first_event_time.ToInternalValue()); |
| + packet_stats->SetDouble("lastEventTime", |
| + it->second.last_event_time.ToInternalValue()); |
| + packet_stats->SetDouble("lastEventTime", |
| + it->second.last_event_time.ToInternalValue()); |
| + packet_stats->SetInteger("count", it->second.event_counter); |
| + packet_stats->SetInteger("sizeTotal", it->second.sum_size); |
| + |
| + overall_packet_stats->Set(CastLoggingToString(it->first), |
| + packet_stats.release()); |
| + } |
| + |
| + overall_stats->Set("packetStats", overall_packet_stats.release()); |
| + |
| + return overall_stats.Pass(); |
| +} |
| + |
| +} // namespace cast |
| +} // namespace media |