Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: media/cast/logging/stats_event_subscriber.cc

Issue 2911033002: Remove raw base::DictionaryValue::Set (Closed)
Patch Set: Proper Windows Fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_message_unittest.cc ('k') | media/cdm/json_web_key.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <utility>
10 10
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 16
16 #define STAT_ENUM_TO_STRING(enum) \ 17 #define STAT_ENUM_TO_STRING(enum) \
17 case enum: \ 18 case enum: \
18 return #enum 19 return #enum
19 20
20 namespace media { 21 namespace media {
21 namespace cast { 22 namespace cast {
22 23
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (last_event_time_.is_null()) { 221 if (last_event_time_.is_null()) {
221 last_event_time_ = timestamp; 222 last_event_time_ = timestamp;
222 } else { 223 } else {
223 last_event_time_ = std::max(last_event_time_, timestamp); 224 last_event_time_ = std::max(last_event_time_, timestamp);
224 } 225 }
225 } 226 }
226 227
227 std::unique_ptr<base::DictionaryValue> StatsEventSubscriber::GetStats() const { 228 std::unique_ptr<base::DictionaryValue> StatsEventSubscriber::GetStats() const {
228 StatsMap stats_map; 229 StatsMap stats_map;
229 GetStatsInternal(&stats_map); 230 GetStatsInternal(&stats_map);
230 std::unique_ptr<base::DictionaryValue> ret(new base::DictionaryValue); 231 auto ret = base::MakeUnique<base::DictionaryValue>();
231 232
232 std::unique_ptr<base::DictionaryValue> stats(new base::DictionaryValue); 233 auto stats = base::MakeUnique<base::DictionaryValue>();
233 for (StatsMap::const_iterator it = stats_map.begin(); it != stats_map.end(); 234 for (StatsMap::const_iterator it = stats_map.begin(); it != stats_map.end();
234 ++it) { 235 ++it) {
235 // Round to 3 digits after the decimal point. 236 // Round to 3 digits after the decimal point.
236 stats->SetDouble(CastStatToString(it->first), 237 stats->SetDouble(CastStatToString(it->first),
237 round(it->second * 1000.0) / 1000.0); 238 round(it->second * 1000.0) / 1000.0);
238 } 239 }
239 240
240 // Populate all histograms. 241 // Populate all histograms.
241 for (HistogramMap::const_iterator it = histograms_.begin(); 242 for (HistogramMap::const_iterator it = histograms_.begin();
242 it != histograms_.end(); 243 it != histograms_.end();
243 ++it) { 244 ++it) {
244 stats->Set(CastStatToString(it->first), 245 stats->Set(CastStatToString(it->first), it->second->GetHistogram());
245 it->second->GetHistogram().release());
246 } 246 }
247 247
248 ret->Set(event_media_type_ == AUDIO_EVENT ? "audio" : "video", 248 ret->Set(event_media_type_ == AUDIO_EVENT ? "audio" : "video",
249 stats.release()); 249 std::move(stats));
250 250
251 return ret; 251 return ret;
252 } 252 }
253 253
254 void StatsEventSubscriber::Reset() { 254 void StatsEventSubscriber::Reset() {
255 DCHECK(thread_checker_.CalledOnValidThread()); 255 DCHECK(thread_checker_.CalledOnValidThread());
256 256
257 frame_stats_.clear(); 257 frame_stats_.clear();
258 packet_stats_.clear(); 258 packet_stats_.clear();
259 total_capture_latency_ = base::TimeDelta(); 259 total_capture_latency_ = base::TimeDelta();
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 : event_counter(0), sum_size(0) {} 748 : event_counter(0), sum_size(0) {}
749 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} 749 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {}
750 750
751 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { 751 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) {
752 } 752 }
753 StatsEventSubscriber::FrameInfo::~FrameInfo() { 753 StatsEventSubscriber::FrameInfo::~FrameInfo() {
754 } 754 }
755 755
756 } // namespace cast 756 } // namespace cast
757 } // namespace media 757 } // namespace media
OLDNEW
« no previous file with comments | « ipc/ipc_message_unittest.cc ('k') | media/cdm/json_web_key.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698