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

Unified Diff: net/quic/chromium/quic_connection_logger.cc

Issue 2899723003: Remove raw base::DictionaryValue::Set in //net (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 | « net/proxy/proxy_service.cc ('k') | net/socket/ssl_client_socket_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/chromium/quic_connection_logger.cc
diff --git a/net/quic/chromium/quic_connection_logger.cc b/net/quic/chromium/quic_connection_logger.cc
index 2d3e872630923673065c709cb0bbde866bd738d4..7741b974ac23b1d762cf557ecb1c2a9af8acbbb0 100644
--- a/net/quic/chromium/quic_connection_logger.cc
+++ b/net/quic/chromium/quic_connection_logger.cc
@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
@@ -108,14 +109,13 @@ std::unique_ptr<base::Value> NetLogQuicStreamFrameCallback(
std::unique_ptr<base::Value> NetLogQuicAckFrameCallback(
const QuicAckFrame* frame,
NetLogCaptureMode /* capture_mode */) {
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ auto dict = base::MakeUnique<base::DictionaryValue>();
dict->SetString("largest_observed",
base::Uint64ToString(frame->largest_observed));
dict->SetString("delta_time_largest_observed_us",
base::Int64ToString(frame->ack_delay_time.ToMicroseconds()));
- base::ListValue* missing = new base::ListValue();
- dict->Set("missing_packets", missing);
+ auto missing = base::MakeUnique<base::ListValue>();
if (!frame->packets.Empty()) {
// V34 and above express acked packets, but only print
// missing packets, because it's typically a shorter list.
@@ -126,18 +126,19 @@ std::unique_ptr<base::Value> NetLogQuicAckFrameCallback(
}
}
}
+ dict->Set("missing_packets", std::move(missing));
- base::ListValue* received = new base::ListValue();
- dict->Set("received_packet_times", received);
+ auto received = base::MakeUnique<base::ListValue>();
const PacketTimeVector& received_times = frame->received_packet_times;
for (PacketTimeVector::const_iterator it = received_times.begin();
it != received_times.end(); ++it) {
- std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue());
+ auto info = base::MakeUnique<base::DictionaryValue>();
info->SetInteger("packet_number", static_cast<int>(it->first));
info->SetString("received",
base::Int64ToString(it->second.ToDebuggingValue()));
received->Append(std::move(info));
}
+ dict->Set("received_packet_times", std::move(received));
return std::move(dict);
}
@@ -190,24 +191,24 @@ std::unique_ptr<base::Value> NetLogQuicGoAwayFrameCallback(
std::unique_ptr<base::Value> NetLogQuicStopWaitingFrameCallback(
const QuicStopWaitingFrame* frame,
NetLogCaptureMode /* capture_mode */) {
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- base::DictionaryValue* sent_info = new base::DictionaryValue();
- dict->Set("sent_info", sent_info);
+ auto dict = base::MakeUnique<base::DictionaryValue>();
+ auto sent_info = base::MakeUnique<base::DictionaryValue>();
sent_info->SetString("least_unacked",
base::Uint64ToString(frame->least_unacked));
+ dict->Set("sent_info", std::move(sent_info));
return std::move(dict);
}
std::unique_ptr<base::Value> NetLogQuicVersionNegotiationPacketCallback(
const QuicVersionNegotiationPacket* packet,
NetLogCaptureMode /* capture_mode */) {
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- base::ListValue* versions = new base::ListValue();
- dict->Set("versions", versions);
+ auto dict = base::MakeUnique<base::DictionaryValue>();
+ auto versions = base::MakeUnique<base::ListValue>();
for (QuicVersionVector::const_iterator it = packet->versions.begin();
it != packet->versions.end(); ++it) {
versions->AppendString(QuicVersionToString(*it));
}
+ dict->Set("versions", std::move(versions));
return std::move(dict);
}
@@ -248,13 +249,12 @@ std::unique_ptr<base::Value> NetLogQuicCertificateVerifiedCallback(
// More fields could be logged in the future.
std::vector<std::string> dns_names;
cert->GetDNSNames(&dns_names);
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- base::ListValue* subjects = new base::ListValue();
- for (std::vector<std::string>::const_iterator it = dns_names.begin();
- it != dns_names.end(); it++) {
- subjects->AppendString(*it);
+ auto dict = base::MakeUnique<base::DictionaryValue>();
+ auto subjects = base::MakeUnique<base::ListValue>();
+ for (auto& dns_name : dns_names) {
+ subjects->GetList().emplace_back(std::move(dns_name));
}
- dict->Set("subjects", subjects);
+ dict->Set("subjects", std::move(subjects));
return std::move(dict);
}
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | net/socket/ssl_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698