Commit 1dc52484 authored by Panos Astithas's avatar Panos Astithas Committed by Commit Bot

Remove base::DictionaryValue usage in net::GetNetConstants()

R=eroman@chromium.org

Bug: 646113
Change-Id: Ia62bfc2531336e289e315eb035fc0fcf15c81ebb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225279
Commit-Queue: Panos Astithas <pastithas@google.com>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774968}
parent cdca6879
......@@ -13,17 +13,15 @@
namespace net_log {
std::unique_ptr<base::Value> GetConstantsForNetLog(
base::Value GetConstantsForNetLog(
const base::CommandLine::StringType& command_line_string,
const std::string& channel_string) {
std::unique_ptr<base::DictionaryValue> constants_dict =
net::GetNetConstants();
DCHECK(constants_dict);
base::Value constants_dict = net::GetNetConstants();
auto platform_dict =
GetPlatformConstantsForNetLog(command_line_string, channel_string);
if (platform_dict)
constants_dict->MergeDictionary(platform_dict.get());
constants_dict.MergeDictionary(platform_dict.get());
return constants_dict;
}
......
......@@ -24,7 +24,7 @@ namespace net_log {
// names of error codes.
//
// Safe to call on any thread.
std::unique_ptr<base::Value> GetConstantsForNetLog(
base::Value GetConstantsForNetLog(
const base::CommandLine::StringType& command_line_string,
const std::string& channel_string);
......
......@@ -29,13 +29,12 @@ namespace content {
namespace {
std::unique_ptr<base::ListValue> GetNetworkErrorData() {
std::unique_ptr<base::DictionaryValue> error_codes = net::GetNetConstants();
base::Value error_codes = net::GetNetConstants();
const base::DictionaryValue* net_error_codes_dict = nullptr;
for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd();
itr.Advance()) {
if (itr.key() == kNetworkErrorKey) {
itr.value().GetAsDictionary(&net_error_codes_dict);
for (const auto& item : error_codes.DictItems()) {
if (item.first == kNetworkErrorKey) {
item.second.GetAsDictionary(&net_error_codes_dict);
break;
}
}
......
......@@ -227,13 +227,12 @@ bool URLDataManagerBackend::CheckURLIsValid(const GURL& url) {
}
bool URLDataManagerBackend::IsValidNetworkErrorCode(int error_code) {
std::unique_ptr<base::DictionaryValue> error_codes = net::GetNetConstants();
base::Value error_codes = net::GetNetConstants();
const base::DictionaryValue* net_error_codes_dict = nullptr;
for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd();
itr.Advance()) {
if (itr.key() == kNetworkErrorKey) {
itr.value().GetAsDictionary(&net_error_codes_dict);
for (const auto& item : error_codes.DictItems()) {
if (item.first == kNetworkErrorKey) {
item.second.GetAsDictionary(&net_error_codes_dict);
break;
}
}
......
......@@ -20,7 +20,8 @@ namespace {
std::unique_ptr<base::DictionaryValue> GetWebEngineConstants() {
std::unique_ptr<base::DictionaryValue> constants_dict =
net::GetNetConstants();
base::DictionaryValue::From(
base::Value::ToUniquePtrValue(net::GetNetConstants()));
base::DictionaryValue dict;
dict.SetKey("name", base::Value("WebEngine"));
......
......@@ -481,7 +481,8 @@ FileNetLogObserver::FileNetLogObserver(
write_queue_(std::move(write_queue)),
file_writer_(std::move(file_writer)) {
if (!constants)
constants = GetNetConstants();
constants = base::DictionaryValue::From(
base::Value::ToUniquePtrValue(GetNetConstants()));
file_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&FileNetLogObserver::FileWriter::Initialize,
base::Unretained(file_writer_.get()),
......
This diff is collapsed.
......@@ -33,8 +33,8 @@ enum NetInfoSource {
// Returns a friendly string to use for a given NetInfoSource in the net log.
NET_EXPORT const char* NetInfoSourceToString(NetInfoSource source);
// Create a dictionary containing a legend for net/ constants.
NET_EXPORT std::unique_ptr<base::DictionaryValue> GetNetConstants();
// Creates a dictionary containing a legend for net/ constants.
NET_EXPORT base::Value GetNetConstants();
// Retrieves a dictionary containing information about the current state of
// |context|. |info_sources| is a set of NetInfoSources OR'd together,
......
......@@ -27,7 +27,7 @@ namespace {
// Make sure GetNetConstants doesn't crash.
TEST(NetLogUtil, GetNetConstants) {
std::unique_ptr<base::Value> constants(GetNetConstants());
base::Value constants(GetNetConstants());
}
// Make sure GetNetInfo doesn't crash when called on contexts with and without
......
......@@ -181,7 +181,9 @@ void NetLogExporter::StartWithScratchDir(
state_ = STATE_RUNNING;
std::unique_ptr<base::DictionaryValue> constants = net::GetNetConstants();
std::unique_ptr<base::DictionaryValue> constants =
base::DictionaryValue::From(
base::Value::ToUniquePtrValue(net::GetNetConstants()));
if (extra_constants)
constants->MergeDictionary(extra_constants);
......
......@@ -462,7 +462,9 @@ void NetworkService::StartNetLog(base::File file,
net::NetLogCaptureMode capture_mode,
base::Value client_constants) {
DCHECK(client_constants.is_dict());
std::unique_ptr<base::DictionaryValue> constants = net::GetNetConstants();
std::unique_ptr<base::DictionaryValue> constants =
base::DictionaryValue::From(
base::Value::ToUniquePtrValue(net::GetNetConstants()));
constants->MergeDictionary(&client_constants);
file_net_log_observer_ = net::FileNetLogObserver::CreateUnboundedPreExisting(
......
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