Skip to content

Commit

Permalink
[base] Replace GetList().{emplace,push}_back with Append in //net
Browse files Browse the repository at this point in the history
This change replaces usages of base::Value::GetList() followed by either
emplace_back() or push_back() with base::Value::Append(). This is
because of the upcoming change to GetList() to return a base::span
instead, which does not support either emplace_back() or push_back().

This is a completely mechanical change. Steps to reproduce:
- sed -i 's/GetList().push_back/Append/g'
- sed -i 's/GetList().emplace_back/Append/g'
- git cl format

Bug: 646113
Change-Id: I36d53904d2be2d95d410ef88e3c973884a7777c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1796428
Reviewed-by: Ryan Sleevi <rsleevi@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695306}
  • Loading branch information
jdoerrie authored and Commit Bot committed Sep 10, 2019
1 parent 13c4664 commit ba777f3
Show file tree
Hide file tree
Showing 24 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion net/base/address_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ base::Value AddressList::NetLogParams() const {
base::Value list(base::Value::Type::LIST);

for (const auto& ip_endpoint : *this)
list.GetList().emplace_back(ip_endpoint.ToString());
list.Append(ip_endpoint.ToString());

dict.SetKey("address_list", std::move(list));
dict.SetStringKey("canonical_name", canonical_name());
Expand Down
6 changes: 2 additions & 4 deletions net/base/network_isolation_key.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ bool NetworkIsolationKey::ToValue(base::Value* out_value) const {
*out_value = base::Value(base::Value::Type::LIST);
// Store origins GURLs, since GURL has validation logic that can be used when
// loading, while Origin only has DCHECKs.
out_value->GetList().emplace_back(
base::Value(top_frame_origin_->GetURL().spec()));
out_value->Append(base::Value(top_frame_origin_->GetURL().spec()));

if (use_frame_origin_)
out_value->GetList().emplace_back(
base::Value(frame_origin_->GetURL().spec()));
out_value->Append(base::Value(frame_origin_->GetURL().spec()));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion net/cert/ct_signed_certificate_timestamp_log_param.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ base::Value SCTListToPrintableValues(
const SignedCertificateTimestampAndStatusList& sct_and_status_list) {
base::Value output_scts(base::Value::Type::LIST);
for (const auto& sct_and_status : sct_and_status_list)
output_scts.GetList().push_back(
output_scts.Append(
SCTToDictionary(*(sct_and_status.sct.get()), sct_and_status.status));

return output_scts;
Expand Down
2 changes: 1 addition & 1 deletion net/cert/x509_certificate_net_log_param.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ base::Value NetLogX509CertificateParams(const X509Certificate* certificate) {
std::vector<std::string> encoded_chain;
certificate->GetPEMEncodedChain(&encoded_chain);
for (auto& pem : encoded_chain)
certs.GetList().emplace_back(std::move(pem));
certs.Append(std::move(pem));
dict.SetKey("certificates", std::move(certs));
return dict;
}
Expand Down
2 changes: 1 addition & 1 deletion net/dns/dns_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ std::unique_ptr<base::Value> DnsConfig::ToValue() const {
val.GetAsDictionary(&dict);
dict->SetString("server_template", server.server_template);
dict->SetBoolean("use_post", server.use_post);
list->GetList().push_back(std::move(val));
list->Append(std::move(val));
}
dict->Set("doh_servers", std::move(list));
dict->SetInteger("secure_dns_mode", static_cast<int>(secure_dns_mode));
Expand Down
8 changes: 4 additions & 4 deletions net/dns/host_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ base::DictionaryValue HostCache::Entry::GetAsValue(
// Append all of the resolved addresses.
base::ListValue addresses_value;
for (const IPEndPoint& address : addresses().value()) {
addresses_value.GetList().emplace_back(address.ToStringWithoutPort());
addresses_value.Append(address.ToStringWithoutPort());
}
entry_dict.SetKey(kAddressesKey, std::move(addresses_value));
}
Expand All @@ -331,7 +331,7 @@ base::DictionaryValue HostCache::Entry::GetAsValue(
// Append all resolved text records.
base::ListValue text_list_value;
for (const std::string& text_record : text_records().value()) {
text_list_value.GetList().emplace_back(text_record);
text_list_value.Append(text_record);
}
entry_dict.SetKey(kTextRecordsKey, std::move(text_list_value));
}
Expand All @@ -341,8 +341,8 @@ base::DictionaryValue HostCache::Entry::GetAsValue(
base::ListValue hostnames_value;
base::ListValue host_ports_value;
for (const HostPortPair& hostname : hostnames().value()) {
hostnames_value.GetList().emplace_back(hostname.host());
host_ports_value.GetList().emplace_back(hostname.port());
hostnames_value.Append(hostname.host());
host_ports_value.Append(hostname.port());
}
entry_dict.SetKey(kHostnameResultsKey, std::move(hostnames_value));
entry_dict.SetKey(kHostPortsKey, std::move(host_ports_value));
Expand Down
2 changes: 1 addition & 1 deletion net/ftp/ftp_ctrl_response_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace {
base::Value NetLogFtpCtrlResponseParams(const FtpCtrlResponse* response) {
base::ListValue lines;
for (const auto& line : response->lines)
lines.GetList().push_back(NetLogStringValue(line));
lines.Append(NetLogStringValue(line));

base::DictionaryValue dict;
dict.SetInteger("status_code", response->status_code);
Expand Down
2 changes: 1 addition & 1 deletion net/http/http_auth_gssapi_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ base::Value GetGssStatusCodeValue(GSSAPILibrary* gssapi_lib,
if (!base::IsStringUTF8(message_string))
continue;

messages.GetList().emplace_back(message_string);
messages.Append(message_string);
} while (message_context != 0 && ++iterations < kMaxDisplayIterations);

if (messages.GetList().size() > 0)
Expand Down
2 changes: 1 addition & 1 deletion net/http/http_request_headers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ base::Value HttpRequestHeaders::NetLogParams(
for (auto it = headers_.begin(); it != headers_.end(); ++it) {
std::string log_value =
ElideHeaderValueForNetLog(capture_mode, it->key, it->value);
headers->GetList().push_back(
headers->Append(
NetLogStringValue(base::StrCat({it->key, ": ", log_value})));
}
dict.Set("headers", std::move(headers));
Expand Down
5 changes: 2 additions & 3 deletions net/http/http_response_headers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1334,15 +1334,14 @@ base::Value HttpResponseHeaders::NetLogParams(
NetLogCaptureMode capture_mode) const {
base::DictionaryValue dict;
base::ListValue headers;
headers.GetList().push_back(NetLogStringValue(GetStatusLine()));
headers.Append(NetLogStringValue(GetStatusLine()));
size_t iterator = 0;
std::string name;
std::string value;
while (EnumerateHeaderLines(&iterator, &name, &value)) {
std::string log_value =
ElideHeaderValueForNetLog(capture_mode, name, value);
headers.GetList().push_back(
NetLogStringValue(base::StrCat({name, ": ", log_value})));
headers.Append(NetLogStringValue(base::StrCat({name, ": ", log_value})));
}
dict.SetKey("headers", std::move(headers));
return std::move(dict);
Expand Down
6 changes: 3 additions & 3 deletions net/http/http_server_properties_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ void HttpServerPropertiesManager::WriteToPrefs(
server_dict.SetStringKey(kServerKey, key.server.Serialize());
server_dict.SetKey(kNetworkIsolationKey,
std::move(network_isolation_key_value));
servers_list.GetList().emplace_back(std::move(server_dict));
servers_list.Append(std::move(server_dict));
}
http_server_properties_dict.SetKey(kServersKey, std::move(servers_list));

Expand Down Expand Up @@ -861,7 +861,7 @@ void HttpServerPropertiesManager::SaveBrokenAlternativeServicesToPrefs(
}
entry_dict.SetKey(kBrokenCountKey, base::Value(broken_count));
json_list_index_map[broken_alt_service] = json_list->GetList().size();
json_list->GetList().push_back(std::move(entry_dict));
json_list->Append(std::move(entry_dict));
}
}

Expand Down Expand Up @@ -898,7 +898,7 @@ void HttpServerPropertiesManager::SaveBrokenAlternativeServicesToPrefs(
}
entry_dict.SetKey(kBrokenUntilKey,
base::Value(base::NumberToString(expiration_int64)));
json_list->GetList().push_back(std::move(entry_dict));
json_list->Append(std::move(entry_dict));
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions net/http/http_server_properties_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1042,21 +1042,20 @@ TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
alternative_service_dict.SetStringKey("protocol_str", "quic");
alternative_service_dict.SetIntKey("port", i);
base::Value alternative_service_list(base::Value::Type::LIST);
alternative_service_list.GetList().emplace_back(
std::move(alternative_service_dict));
alternative_service_list.Append(std::move(alternative_service_dict));
server_dict.SetKey("alternative_service",
std::move(alternative_service_list));
server_dict.SetStringKey("server",
StringPrintf("https://www.google.com:%d", i));
server_dict.SetKey("isolation", base::Value(base::Value::Type::LIST));
servers_list->GetList().emplace_back(std::move(server_dict));
servers_list->Append(std::move(server_dict));
}

// Set the server preference for http://mail.google.com server.
base::Value server_dict2(base::Value::Type::DICTIONARY);
server_dict2.SetStringKey("server", "https://mail.google.com");
server_dict2.SetKey("isolation", base::Value(base::Value::Type::LIST));
servers_list->GetList().emplace_back(std::move(server_dict2));
servers_list->Append(std::move(server_dict2));

base::DictionaryValue http_server_properties_dict = DictWithVersion();
http_server_properties_dict.SetWithoutPathExpansion("servers",
Expand Down
2 changes: 1 addition & 1 deletion net/network_error_logging/network_error_logging_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {

base::Value cert_url_list = base::Value(base::Value::Type::LIST);
if (details.cert_url.is_valid())
cert_url_list.GetList().push_back(base::Value(details.cert_url.spec()));
cert_url_list.Append(base::Value(details.cert_url.spec()));
sxg_body->SetKey(kCertUrlKey, std::move(cert_url_list));
body->SetDictionary(kSignedExchangeBodyKey, std::move(sxg_body));

Expand Down
2 changes: 1 addition & 1 deletion net/proxy_resolution/dhcp_pac_file_fetcher_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ base::Value NetLogGetAdaptersDoneParams(DhcpAdapterNamesLoggingInfo* info) {
bool skipped = !IsDhcpCapableAdapter(adapter);
adapter_value.SetKey("skipped", base::Value(skipped));

adapters_value.GetList().push_back(std::move(adapter_value));
adapters_value.Append(std::move(adapter_value));
}
result.SetKey("adapters", std::move(adapters_value));

Expand Down
2 changes: 1 addition & 1 deletion net/proxy_resolution/proxy_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ base::Value ProxyConfig::ToValue() const {
base::Value list(base::Value::Type::LIST);

for (const auto& bypass_rule : bypass.rules())
list.GetList().emplace_back(bypass_rule->ToString());
list.Append(bypass_rule->ToString());

dict.SetKey("bypass_list", std::move(list));
}
Expand Down
2 changes: 1 addition & 1 deletion net/proxy_resolution/proxy_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ std::string ProxyList::ToPacString() const {
base::Value ProxyList::ToValue() const {
base::Value list(base::Value::Type::LIST);
for (const auto& proxy : proxies_)
list.GetList().emplace_back(proxy.ToURI());
list.Append(proxy.ToURI());
return list;
}

Expand Down
2 changes: 1 addition & 1 deletion net/proxy_resolution/proxy_resolution_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ base::Value NetLogBadProxyListParams(const ProxyRetryInfoMap* retry_info) {
base::Value list(base::Value::Type::LIST);

for (const auto& retry_info_pair : *retry_info)
list.GetList().emplace_back(retry_info_pair.first);
list.Append(retry_info_pair.first);
dict.SetKey("bad_proxy_list", std::move(list));
return dict;
}
Expand Down
4 changes: 2 additions & 2 deletions net/quic/quic_connection_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ base::Value NetLogQuicAckFrameParams(const quic::QuicAckFrame* frame) {
for (quic::QuicPacketNumber packet = frame->packets.Min();
packet < frame->largest_acked; ++packet) {
if (!frame->packets.Contains(packet)) {
missing->GetList().push_back(NetLogNumberValue(packet.ToUint64()));
missing->Append(NetLogNumberValue(packet.ToUint64()));
}
}
}
Expand Down Expand Up @@ -237,7 +237,7 @@ base::Value NetLogQuicCertificateVerifiedParams(
base::DictionaryValue dict;
auto subjects = std::make_unique<base::ListValue>();
for (auto& dns_name : dns_names) {
subjects->GetList().emplace_back(std::move(dns_name));
subjects->Append(std::move(dns_name));
}
dict.Set("subjects", std::move(subjects));
return std::move(dict);
Expand Down
2 changes: 1 addition & 1 deletion net/quic/quic_stream_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ std::unique_ptr<base::Value> QuicStreamFactory::QuicStreamFactoryInfoToValue()
hosts.insert(HostPortPair(alias_it->server_id().host(),
alias_it->server_id().port()));
}
list->GetList().push_back(session->GetInfoAsValue(hosts));
list->Append(session->GetInfoAsValue(hosts));
}
}
return std::move(list);
Expand Down
2 changes: 1 addition & 1 deletion net/socket/client_socket_pool_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ClientSocketPoolManagerImpl::SocketPoolInfoToValue() const {
} else {
type = "http_proxy_socket_pool";
}
list->GetList().push_back(
list->Append(
socket_pool.second->GetInfoAsValue(socket_pool.first.ToURI(), type));
}

Expand Down
2 changes: 1 addition & 1 deletion net/spdy/spdy_log_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ base::ListValue ElideSpdyHeaderBlockForNetLog(
for (const auto& header : headers) {
base::StringPiece key = header.first;
base::StringPiece value = header.second;
headers_list.GetList().push_back(NetLogStringValue(
headers_list.Append(NetLogStringValue(
base::StrCat({key, ": ",
ElideHeaderValueForNetLog(capture_mode, key.as_string(),
value.as_string())})));
Expand Down
2 changes: 1 addition & 1 deletion net/spdy/spdy_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ base::Value SpdySession::GetInfoAsValue() const {
if (!pooled_aliases_.empty()) {
base::Value alias_list(base::Value::Type::LIST);
for (const auto& alias : pooled_aliases_) {
alias_list.GetList().emplace_back(alias.host_port_pair().ToString());
alias_list.Append(alias.host_port_pair().ToString());
}
dict.SetKey("aliases", std::move(alias_list));
}
Expand Down
2 changes: 1 addition & 1 deletion net/spdy/spdy_session_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ std::unique_ptr<base::Value> SpdySessionPool::SpdySessionPoolInfoToValue()
const SpdySessionKey& key = it->first;
const SpdySessionKey& session_key = it->second->spdy_session_key();
if (key == session_key)
list->GetList().push_back(it->second->GetInfoAsValue());
list->Append(it->second->GetInfoAsValue());
}
return std::move(list);
}
Expand Down
2 changes: 1 addition & 1 deletion net/url_request/url_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ base::Value URLRequest::GetStateAsValue() const {
if (url_chain_.size() > 1) {
base::Value list(base::Value::Type::LIST);
for (const GURL& url : url_chain_) {
list.GetList().emplace_back(url.possibly_invalid_spec());
list.Append(url.possibly_invalid_spec());
}
dict.SetKey("url_chain", std::move(list));
}
Expand Down

0 comments on commit ba777f3

Please sign in to comment.