Commit 6fa12f99 authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Convert more instances of base::DictionaryValue in //net.

Bug: 646113
Change-Id: I7ba7eb2950593576f6552b3a681a74437f6bffa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1616150Reviewed-by: default avatarDavid Benjamin <davidben@chromium.org>
Commit-Queue: Eric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660675}
parent bf1f6c0d
......@@ -232,20 +232,20 @@ base::Value NetLogSpdyHeadersSentCallback(const spdy::SpdyHeaderBlock* headers,
bool exclusive,
NetLogSource source_dependency,
NetLogCaptureMode capture_mode) {
base::DictionaryValue dict;
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("headers", ElideSpdyHeaderBlockForNetLog(*headers, capture_mode));
dict.SetBoolean("fin", fin);
dict.SetInteger("stream_id", stream_id);
dict.SetBoolean("has_priority", has_priority);
dict.SetBoolKey("fin", fin);
dict.SetIntKey("stream_id", stream_id);
dict.SetBoolKey("has_priority", has_priority);
if (has_priority) {
dict.SetInteger("parent_stream_id", parent_stream_id);
dict.SetInteger("weight", weight);
dict.SetBoolean("exclusive", exclusive);
dict.SetIntKey("parent_stream_id", parent_stream_id);
dict.SetIntKey("weight", weight);
dict.SetBoolKey("exclusive", exclusive);
}
if (source_dependency.IsValid()) {
source_dependency.AddToEventParameters(&dict);
}
return std::move(dict);
return dict;
}
base::Value NetLogSpdyHeadersReceivedCallback(
......@@ -253,46 +253,46 @@ base::Value NetLogSpdyHeadersReceivedCallback(
bool fin,
spdy::SpdyStreamId stream_id,
NetLogCaptureMode capture_mode) {
base::DictionaryValue dict;
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("headers", ElideSpdyHeaderBlockForNetLog(*headers, capture_mode));
dict.SetBoolean("fin", fin);
dict.SetInteger("stream_id", stream_id);
return std::move(dict);
dict.SetBoolKey("fin", fin);
dict.SetIntKey("stream_id", stream_id);
return dict;
}
base::Value NetLogSpdySessionCloseCallback(
int net_error,
const std::string* description,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("net_error", net_error);
dict.SetString("description", *description);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("net_error", net_error);
dict.SetStringKey("description", *description);
return dict;
}
base::Value NetLogSpdySessionCallback(const HostPortProxyPair* host_pair,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetString("host", host_pair->first.ToString());
dict.SetString("proxy", host_pair->second.ToPacString());
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("host", host_pair->first.ToString());
dict.SetStringKey("proxy", host_pair->second.ToPacString());
return dict;
}
base::Value NetLogSpdyInitializedCallback(
NetLogSource source,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
base::Value dict(base::Value::Type::DICTIONARY);
if (source.IsValid()) {
source.AddToEventParameters(&dict);
}
dict.SetString("protocol", NextProtoToString(kProtoHTTP2));
return std::move(dict);
dict.SetStringKey("protocol", NextProtoToString(kProtoHTTP2));
return dict;
}
base::Value NetLogSpdySendSettingsCallback(
const spdy::SettingsMap* settings,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
base::Value dict(base::Value::Type::DICTIONARY);
base::ListValue settings_list;
for (auto it = settings->begin(); it != settings->end(); ++it) {
const spdy::SpdySettingsId id = it->first;
......@@ -302,62 +302,62 @@ base::Value NetLogSpdySendSettingsCallback(
spdy::SettingsIdToString(id).c_str(), value));
}
dict.SetKey("settings", std::move(settings_list));
return std::move(dict);
return dict;
}
base::Value NetLogSpdyRecvSettingCallback(
spdy::SpdySettingsId id,
uint32_t value,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetString(
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey(
"id",
base::StringPrintf("%u (%s)", id, spdy::SettingsIdToString(id).c_str()));
dict.SetInteger("value", value);
return std::move(dict);
dict.SetIntKey("value", value);
return dict;
}
base::Value NetLogSpdyWindowUpdateFrameCallback(
spdy::SpdyStreamId stream_id,
uint32_t delta,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", static_cast<int>(stream_id));
dict.SetInteger("delta", delta);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", static_cast<int>(stream_id));
dict.SetIntKey("delta", delta);
return dict;
}
base::Value NetLogSpdySessionWindowUpdateCallback(
int32_t delta,
int32_t window_size,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("delta", delta);
dict.SetInteger("window_size", window_size);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("delta", delta);
dict.SetIntKey("window_size", window_size);
return dict;
}
base::Value NetLogSpdyDataCallback(spdy::SpdyStreamId stream_id,
int size,
bool fin,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", static_cast<int>(stream_id));
dict.SetInteger("size", size);
dict.SetBoolean("fin", fin);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", static_cast<int>(stream_id));
dict.SetIntKey("size", size);
dict.SetBoolKey("fin", fin);
return dict;
}
base::Value NetLogSpdyRecvRstStreamCallback(
spdy::SpdyStreamId stream_id,
spdy::SpdyErrorCode error_code,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", static_cast<int>(stream_id));
dict.SetString(
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", static_cast<int>(stream_id));
dict.SetStringKey(
"error_code",
base::StringPrintf("%u (%s)", error_code, ErrorCodeToString(error_code)));
return std::move(dict);
return dict;
}
base::Value NetLogSpdySendRstStreamCallback(
......@@ -365,24 +365,24 @@ base::Value NetLogSpdySendRstStreamCallback(
spdy::SpdyErrorCode error_code,
const std::string* description,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", static_cast<int>(stream_id));
dict.SetString(
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", static_cast<int>(stream_id));
dict.SetStringKey(
"error_code",
base::StringPrintf("%u (%s)", error_code, ErrorCodeToString(error_code)));
dict.SetString("description", *description);
return std::move(dict);
dict.SetStringKey("description", *description);
return dict;
}
base::Value NetLogSpdyPingCallback(spdy::SpdyPingId unique_id,
bool is_ack,
const char* type,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("unique_id", static_cast<int>(unique_id));
dict.SetString("type", type);
dict.SetBoolean("is_ack", is_ack);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("unique_id", static_cast<int>(unique_id));
dict.SetStringKey("type", type);
dict.SetBoolKey("is_ack", is_ack);
return dict;
}
base::Value NetLogSpdyRecvGoAwayCallback(spdy::SpdyStreamId last_stream_id,
......@@ -391,16 +391,16 @@ base::Value NetLogSpdyRecvGoAwayCallback(spdy::SpdyStreamId last_stream_id,
spdy::SpdyErrorCode error_code,
base::StringPiece debug_data,
NetLogCaptureMode capture_mode) {
base::DictionaryValue dict;
dict.SetInteger("last_accepted_stream_id", static_cast<int>(last_stream_id));
dict.SetInteger("active_streams", active_streams);
dict.SetInteger("unclaimed_streams", unclaimed_streams);
dict.SetString(
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("last_accepted_stream_id", static_cast<int>(last_stream_id));
dict.SetIntKey("active_streams", active_streams);
dict.SetIntKey("unclaimed_streams", unclaimed_streams);
dict.SetStringKey(
"error_code",
base::StringPrintf("%u (%s)", error_code, ErrorCodeToString(error_code)));
dict.SetKey("debug_data",
ElideGoAwayDebugDataForNetLog(capture_mode, debug_data));
return std::move(dict);
return dict;
}
base::Value NetLogSpdyPushPromiseReceivedCallback(
......@@ -408,21 +408,21 @@ base::Value NetLogSpdyPushPromiseReceivedCallback(
spdy::SpdyStreamId stream_id,
spdy::SpdyStreamId promised_stream_id,
NetLogCaptureMode capture_mode) {
base::DictionaryValue dict;
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("headers", ElideSpdyHeaderBlockForNetLog(*headers, capture_mode));
dict.SetInteger("id", stream_id);
dict.SetInteger("promised_stream_id", promised_stream_id);
return std::move(dict);
dict.SetIntKey("id", stream_id);
dict.SetIntKey("promised_stream_id", promised_stream_id);
return dict;
}
base::Value NetLogSpdyAdoptedPushStreamCallback(
spdy::SpdyStreamId stream_id,
const GURL* url,
NetLogCaptureMode capture_mode) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", stream_id);
dict.SetString("url", url->spec());
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", stream_id);
dict.SetStringKey("url", url->spec());
return dict;
}
base::Value NetLogSpdySessionStalledCallback(size_t num_active_streams,
......@@ -431,13 +431,13 @@ base::Value NetLogSpdySessionStalledCallback(size_t num_active_streams,
size_t max_concurrent_streams,
const std::string& url,
NetLogCaptureMode capture_mode) {
base::DictionaryValue dict;
dict.SetInteger("num_active_streams", num_active_streams);
dict.SetInteger("num_created_streams", num_created_streams);
dict.SetInteger("num_pushed_streams", num_pushed_streams);
dict.SetInteger("max_concurrent_streams", max_concurrent_streams);
dict.SetString("url", url);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("num_active_streams", num_active_streams);
dict.SetIntKey("num_created_streams", num_created_streams);
dict.SetIntKey("num_pushed_streams", num_pushed_streams);
dict.SetIntKey("max_concurrent_streams", max_concurrent_streams);
dict.SetStringKey("url", url);
return dict;
}
base::Value NetLogSpdyPriorityCallback(spdy::SpdyStreamId stream_id,
......@@ -445,12 +445,12 @@ base::Value NetLogSpdyPriorityCallback(spdy::SpdyStreamId stream_id,
int weight,
bool exclusive,
NetLogCaptureMode capture_mode) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", stream_id);
dict.SetInteger("parent_stream_id", parent_stream_id);
dict.SetInteger("weight", weight);
dict.SetBoolean("exclusive", exclusive);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", stream_id);
dict.SetIntKey("parent_stream_id", parent_stream_id);
dict.SetIntKey("weight", weight);
dict.SetBoolKey("exclusive", exclusive);
return dict;
}
// Helper function to return the total size of an array of objects
......@@ -1437,44 +1437,44 @@ void SpdySession::MaybeFinishGoingAway() {
}
base::Value SpdySession::GetInfoAsValue() const {
base::DictionaryValue dict;
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetInteger("source_id", net_log_.source().id);
dict.SetIntKey("source_id", net_log_.source().id);
dict.SetString("host_port_pair", host_port_pair().ToString());
dict.SetStringKey("host_port_pair", host_port_pair().ToString());
if (!pooled_aliases_.empty()) {
auto alias_list = std::make_unique<base::ListValue>();
base::Value alias_list(base::Value::Type::LIST);
for (const auto& alias : pooled_aliases_) {
alias_list->AppendString(alias.host_port_pair().ToString());
alias_list.GetList().emplace_back(alias.host_port_pair().ToString());
}
dict.Set("aliases", std::move(alias_list));
dict.SetKey("aliases", std::move(alias_list));
}
dict.SetString("proxy", host_port_proxy_pair().second.ToURI());
dict.SetStringKey("proxy", host_port_proxy_pair().second.ToURI());
dict.SetInteger("active_streams", active_streams_.size());
dict.SetIntKey("active_streams", active_streams_.size());
dict.SetInteger("unclaimed_pushed_streams",
pool_->push_promise_index()->CountStreamsForSession(this));
dict.SetIntKey("unclaimed_pushed_streams",
pool_->push_promise_index()->CountStreamsForSession(this));
dict.SetString("negotiated_protocol",
NextProtoToString(socket_->GetNegotiatedProtocol()));
dict.SetStringKey("negotiated_protocol",
NextProtoToString(socket_->GetNegotiatedProtocol()));
dict.SetInteger("error", error_on_close_);
dict.SetInteger("max_concurrent_streams", max_concurrent_streams_);
dict.SetIntKey("error", error_on_close_);
dict.SetIntKey("max_concurrent_streams", max_concurrent_streams_);
dict.SetInteger("streams_initiated_count", streams_initiated_count_);
dict.SetInteger("streams_pushed_count", streams_pushed_count_);
dict.SetInteger("streams_pushed_and_claimed_count",
streams_pushed_and_claimed_count_);
dict.SetInteger("streams_abandoned_count", streams_abandoned_count_);
dict.SetIntKey("streams_initiated_count", streams_initiated_count_);
dict.SetIntKey("streams_pushed_count", streams_pushed_count_);
dict.SetIntKey("streams_pushed_and_claimed_count",
streams_pushed_and_claimed_count_);
dict.SetIntKey("streams_abandoned_count", streams_abandoned_count_);
DCHECK(buffered_spdy_framer_.get());
dict.SetInteger("frames_received", buffered_spdy_framer_->frames_received());
dict.SetIntKey("frames_received", buffered_spdy_framer_->frames_received());
dict.SetInteger("send_window_size", session_send_window_size_);
dict.SetInteger("recv_window_size", session_recv_window_size_);
dict.SetInteger("unacked_recv_window_bytes",
session_unacked_recv_window_bytes_);
return std::move(dict);
dict.SetIntKey("send_window_size", session_send_window_size_);
dict.SetIntKey("recv_window_size", session_recv_window_size_);
dict.SetIntKey("unacked_recv_window_bytes",
session_unacked_recv_window_bytes_);
return dict;
}
bool SpdySession::IsReused() const {
......
......@@ -37,11 +37,11 @@ base::Value NetLogSpdyStreamErrorCallback(
int net_error,
const std::string* description,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", static_cast<int>(stream_id));
dict.SetString("net_error", ErrorToShortString(net_error));
dict.SetString("description", *description);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", static_cast<int>(stream_id));
dict.SetStringKey("net_error", ErrorToShortString(net_error));
dict.SetStringKey("description", *description);
return dict;
}
base::Value NetLogSpdyStreamWindowUpdateCallback(
......@@ -49,11 +49,11 @@ base::Value NetLogSpdyStreamWindowUpdateCallback(
int32_t delta,
int32_t window_size,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", stream_id);
dict.SetInteger("delta", delta);
dict.SetInteger("window_size", window_size);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("stream_id", stream_id);
dict.SetIntKey("delta", delta);
dict.SetIntKey("window_size", window_size);
return dict;
}
} // namespace
......
......@@ -281,53 +281,52 @@ LoadStateWithParam URLRequest::GetLoadState() const {
}
base::Value URLRequest::GetStateAsValue() const {
base::DictionaryValue dict;
dict.SetString("url", original_url().possibly_invalid_spec());
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("url", original_url().possibly_invalid_spec());
if (url_chain_.size() > 1) {
base::ListValue list;
base::Value list(base::Value::Type::LIST);
for (const GURL& url : url_chain_) {
list.AppendString(url.possibly_invalid_spec());
list.GetList().emplace_back(url.possibly_invalid_spec());
}
dict.SetKey("url_chain", std::move(list));
}
dict.SetInteger("load_flags", load_flags_);
dict.SetIntKey("load_flags", load_flags_);
LoadStateWithParam load_state = GetLoadState();
dict.SetInteger("load_state", load_state.state);
dict.SetIntKey("load_state", load_state.state);
if (!load_state.param.empty())
dict.SetString("load_state_param", load_state.param);
dict.SetStringKey("load_state_param", load_state.param);
if (!blocked_by_.empty())
dict.SetString("delegate_blocked_by", blocked_by_);
dict.SetStringKey("delegate_blocked_by", blocked_by_);
dict.SetString("method", method_);
dict.SetBoolean("has_upload", has_upload());
dict.SetBoolean("is_pending", is_pending_);
dict.SetStringKey("method", method_);
dict.SetBoolKey("has_upload", has_upload());
dict.SetBoolKey("is_pending", is_pending_);
dict.SetInteger("traffic_annotation",
traffic_annotation_.unique_id_hash_code);
dict.SetIntKey("traffic_annotation", traffic_annotation_.unique_id_hash_code);
// Add the status of the request. The status should always be IO_PENDING, and
// the error should always be OK, unless something is holding onto a request
// that has finished or a request was leaked. Neither of these should happen.
switch (status_.status()) {
case URLRequestStatus::SUCCESS:
dict.SetString("status", "SUCCESS");
dict.SetStringKey("status", "SUCCESS");
break;
case URLRequestStatus::IO_PENDING:
dict.SetString("status", "IO_PENDING");
dict.SetStringKey("status", "IO_PENDING");
break;
case URLRequestStatus::CANCELED:
dict.SetString("status", "CANCELED");
dict.SetStringKey("status", "CANCELED");
break;
case URLRequestStatus::FAILED:
dict.SetString("status", "FAILED");
dict.SetStringKey("status", "FAILED");
break;
}
if (status_.error() != OK)
dict.SetInteger("net_error", status_.error());
return std::move(dict);
dict.SetIntKey("net_error", status_.error());
return dict;
}
void URLRequest::LogBlockedBy(const char* blocked_by) {
......
......@@ -37,9 +37,9 @@ namespace {
// Callback for TYPE_URL_REQUEST_FILTERS_SET net-internals event.
base::Value SourceStreamSetCallback(SourceStream* source_stream,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue event_params;
event_params.SetString("filters", source_stream->Description());
return std::move(event_params);
base::Value event_params(base::Value::Type::DICTIONARY);
event_params.SetStringKey("filters", source_stream->Description());
return event_params;
}
} // namespace
......
......@@ -18,11 +18,11 @@ base::Value NetLogURLRequestConstructorCallback(
RequestPriority priority,
NetworkTrafficAnnotationTag traffic_annotation,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetString("url", url->possibly_invalid_spec());
dict.SetString("priority", RequestPriorityToString(priority));
dict.SetInteger("traffic_annotation", traffic_annotation.unique_id_hash_code);
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("url", url->possibly_invalid_spec());
dict.SetStringKey("priority", RequestPriorityToString(priority));
dict.SetIntKey("traffic_annotation", traffic_annotation.unique_id_hash_code);
return dict;
}
base::Value NetLogURLRequestStartCallback(
......@@ -32,14 +32,14 @@ base::Value NetLogURLRequestStartCallback(
PrivacyMode privacy_mode,
int64_t upload_id,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetString("url", url->possibly_invalid_spec());
dict.SetString("method", *method);
dict.SetInteger("load_flags", load_flags);
dict.SetInteger("privacy_mode", privacy_mode == PRIVACY_MODE_ENABLED);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("url", url->possibly_invalid_spec());
dict.SetStringKey("method", *method);
dict.SetIntKey("load_flags", load_flags);
dict.SetIntKey("privacy_mode", privacy_mode == PRIVACY_MODE_ENABLED);
if (upload_id > -1)
dict.SetString("upload_id", base::NumberToString(upload_id));
return std::move(dict);
dict.SetStringKey("upload_id", base::NumberToString(upload_id));
return dict;
}
} // namespace net
......@@ -56,12 +56,12 @@ base::Value NetLogRejectedRequestCallback(
int num_failures,
const base::TimeDelta& release_after,
NetLogCaptureMode /* capture_mode */) {
base::DictionaryValue dict;
dict.SetString("url", *url_id);
dict.SetInteger("num_failures", num_failures);
dict.SetInteger("release_after_ms",
static_cast<int>(release_after.InMilliseconds()));
return std::move(dict);
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("url", *url_id);
dict.SetIntKey("num_failures", num_failures);
dict.SetIntKey("release_after_ms",
static_cast<int>(release_after.InMilliseconds()));
return dict;
}
URLRequestThrottlerEntry::URLRequestThrottlerEntry(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment