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

Unified Diff: content/renderer/media/peer_connection_tracker.cc

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Rebase Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/devtools/devtools_agent.cc ('k') | content/shell/browser/shell_devtools_bindings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « content/renderer/devtools/devtools_agent.cc ('k') | content/shell/browser/shell_devtools_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698