Index: content/renderer/media/peer_connection_tracker.cc |
diff --git a/content/renderer/media/peer_connection_tracker.cc b/content/renderer/media/peer_connection_tracker.cc |
index b68adf40b7e0d17e6495a79788f0cea8db511d44..40cb37c071a2f42e34f458f3dc11c4342c01f515 100644 |
--- a/content/renderer/media/peer_connection_tracker.cc |
+++ b/content/renderer/media/peer_connection_tracker.cc |
@@ -10,9 +10,11 @@ |
#include <memory> |
#include <utility> |
+#include "base/memory/ptr_util.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/threading/thread_task_runner_handle.h" |
+#include "base/values.h" |
#include "content/common/media/peer_connection_tracker_messages.h" |
#include "content/renderer/media/rtc_peer_connection_handler.h" |
#include "content/renderer/render_thread_impl.h" |
@@ -244,19 +246,15 @@ static const char* GetIceGatheringStateString( |
} |
// Builds a DictionaryValue from the StatsReport. |
-// The caller takes the ownership of the returned value. |
// Note: |
// The format must be consistent with what webrtc_internals.js expects. |
// If you change it here, you must change webrtc_internals.js as well. |
-static base::DictionaryValue* GetDictValueStats(const StatsReport& report) { |
+static std::unique_ptr<base::DictionaryValue> GetDictValueStats( |
+ const StatsReport& report) { |
if (report.values().empty()) |
return NULL; |
- base::DictionaryValue* dict = new base::DictionaryValue(); |
- dict->SetDouble("timestamp", report.timestamp()); |
- |
- base::ListValue* values = new base::ListValue(); |
- dict->Set("values", values); |
+ auto values = base::MakeUnique<base::ListValue>(); |
for (const auto& v : report.values()) { |
const StatsReport::ValuePtr& value = v.second; |
@@ -286,6 +284,10 @@ static base::DictionaryValue* GetDictValueStats(const StatsReport& report) { |
} |
} |
+ auto dict = base::MakeUnique<base::DictionaryValue>(); |
+ dict->SetDouble("timestamp", report.timestamp()); |
+ dict->Set("values", std::move(values)); |
+ |
return dict; |
} |
@@ -293,17 +295,15 @@ static base::DictionaryValue* GetDictValueStats(const StatsReport& report) { |
// The caller takes the ownership of the returned value. |
static std::unique_ptr<base::DictionaryValue> GetDictValue( |
const StatsReport& report) { |
- std::unique_ptr<base::DictionaryValue> stats, result; |
- |
- stats.reset(GetDictValueStats(report)); |
+ std::unique_ptr<base::DictionaryValue> stats = GetDictValueStats(report); |
if (!stats) |
return NULL; |
- result.reset(new base::DictionaryValue()); |
// Note: |
// The format must be consistent with what webrtc_internals.js expects. |
// If you change it here, you must change webrtc_internals.js as well. |
- result->Set("stats", stats.release()); |
+ auto result = base::MakeUnique<base::DictionaryValue>(); |
+ result->Set("stats", std::move(stats)); |
result->SetString("id", report.id()->ToString()); |
result->SetString("type", report.TypeToString()); |