0

[Code Health] Replace remaining base.Value.SetIntKey with dict Set

Bug: 1303949
Change-Id: I80555fcda6c17d01fb69d3cff4aa126b78a60f7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4508954
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Nick Harper <nharper@chromium.org>
Reviewed-by: Sean Topping <seantopping@chromium.org>
Commit-Queue: Sergii Bykov <sbykov@google.com>
Cr-Commit-Position: refs/heads/main@{#1140496}
This commit is contained in:
Sergii Bykov
2023-05-06 10:17:00 +00:00
committed by Chromium LUCI CQ
parent 611c9e76b3
commit 92a1429435
19 changed files with 103 additions and 101 deletions

@@ -5,10 +5,6 @@
#include "ash/projector/projector_metadata_model.h" #include "ash/projector/projector_metadata_model.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "media/mojo/mojom/speech_recognition.mojom.h"
namespace ash { namespace ash {
namespace { namespace {
@@ -65,11 +61,12 @@ ProjectorKeyIdea::~ProjectorKeyIdea() = default;
// "startOffset": INT // "startOffset": INT
// "endOffset": INT // "endOffset": INT
// "text": STRING // "text": STRING
base::Value ProjectorKeyIdea::ToJson() { base::Value::Dict ProjectorKeyIdea::ToJson() {
base::Value transcript(base::Value::Type::DICT); auto transcript =
transcript.SetIntKey(kStartOffsetKey, start_time_.InMilliseconds()); base::Value::Dict()
transcript.SetIntKey(kEndOffsetKey, end_time_.InMilliseconds()); .Set(kStartOffsetKey, static_cast<int>(start_time_.InMilliseconds()))
transcript.SetStringKey(kTextKey, text_); .Set(kEndOffsetKey, static_cast<int>(end_time_.InMilliseconds()))
.Set(kTextKey, text_);
return transcript; return transcript;
} }
@@ -108,7 +105,7 @@ ProjectorTranscript::~ProjectorTranscript() = default;
// "text": STRING // "text": STRING
// "hypothesisParts": DICT LIST // "hypothesisParts": DICT LIST
// //
base::Value ProjectorTranscript::ToJson() { base::Value::Dict ProjectorTranscript::ToJson() {
base::Value::Dict transcript; base::Value::Dict transcript;
transcript.Set(kStartOffsetKey, transcript.Set(kStartOffsetKey,
static_cast<int>(start_time_.InMilliseconds())); static_cast<int>(start_time_.InMilliseconds()));
@@ -120,7 +117,7 @@ base::Value ProjectorTranscript::ToJson() {
hypothesis_parts_list.Append(HypothesisPartsToDict(hypothesis_part)); hypothesis_parts_list.Append(HypothesisPartsToDict(hypothesis_part));
transcript.Set(kHypothesisPartsKey, std::move(hypothesis_parts_list)); transcript.Set(kHypothesisPartsKey, std::move(hypothesis_parts_list));
return base::Value(std::move(transcript)); return transcript;
} }
ProjectorMetadata::ProjectorMetadata() = default; ProjectorMetadata::ProjectorMetadata() = default;
@@ -192,7 +189,7 @@ std::string ProjectorMetadata::Serialize() {
// "captionLanguage": STRING // "captionLanguage": STRING
// "tableOfContent": LIST // "tableOfContent": LIST
// "recognitionStatus": INTEGER // "recognitionStatus": INTEGER
base::Value ProjectorMetadata::ToJson() { base::Value::Dict ProjectorMetadata::ToJson() {
base::Value::Dict metadata; base::Value::Dict metadata;
metadata.Set(kCaptionLanguage, caption_language_); metadata.Set(kCaptionLanguage, caption_language_);
@@ -207,7 +204,7 @@ base::Value ProjectorMetadata::ToJson() {
metadata.Set(kKeyIdeasKey, std::move(key_ideas_list)); metadata.Set(kKeyIdeasKey, std::move(key_ideas_list));
metadata.Set(kRecognitionStatus, metadata.Set(kRecognitionStatus,
static_cast<int>(speech_recognition_status_)); static_cast<int>(speech_recognition_status_));
return base::Value(std::move(metadata)); return metadata;
} }
} // namespace ash } // namespace ash

@@ -11,11 +11,8 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "media/mojo/mojom/speech_recognition.mojom.h" #include "base/values.h"
#include "media/mojo/mojom/speech_recognition_result.h"
namespace base {
class Value;
} // namespace base
namespace ash { namespace ash {
@@ -46,7 +43,7 @@ class MetadataItem {
base::TimeDelta& end_time() { return end_time_; } base::TimeDelta& end_time() { return end_time_; }
// Return the serialized metadata item. This is used for storage. // Return the serialized metadata item. This is used for storage.
virtual base::Value ToJson() = 0; virtual base::Value::Dict ToJson() = 0;
protected: protected:
// The start time of the metadata item from the start of the recording // The start time of the metadata item from the start of the recording
@@ -68,7 +65,7 @@ class ASH_EXPORT ProjectorKeyIdea : public MetadataItem {
ProjectorKeyIdea& operator=(const ProjectorKeyIdea&) = delete; ProjectorKeyIdea& operator=(const ProjectorKeyIdea&) = delete;
~ProjectorKeyIdea() override; ~ProjectorKeyIdea() override;
base::Value ToJson() override; base::Value::Dict ToJson() override;
}; };
// Class to describe a transcription. // Class to describe a transcription.
@@ -83,7 +80,7 @@ class ASH_EXPORT ProjectorTranscript : public MetadataItem {
ProjectorTranscript& operator=(const ProjectorTranscript&) = delete; ProjectorTranscript& operator=(const ProjectorTranscript&) = delete;
~ProjectorTranscript() override; ~ProjectorTranscript() override;
base::Value ToJson() override; base::Value::Dict ToJson() override;
private: private:
std::vector<media::HypothesisParts> hypothesis_parts_; std::vector<media::HypothesisParts> hypothesis_parts_;
@@ -114,7 +111,7 @@ class ASH_EXPORT ProjectorMetadata {
size_t GetTranscriptsCount() const { return transcripts_.size(); } size_t GetTranscriptsCount() const { return transcripts_.size(); }
private: private:
base::Value ToJson(); base::Value::Dict ToJson();
std::vector<std::unique_ptr<ProjectorTranscript>> transcripts_; std::vector<std::unique_ptr<ProjectorTranscript>> transcripts_;
std::vector<std::unique_ptr<ProjectorKeyIdea>> key_ideas_; std::vector<std::unique_ptr<ProjectorKeyIdea>> key_ideas_;

@@ -1173,10 +1173,6 @@ Value* Value::SetKey(StringPiece key, Value&& value) {
return GetDict().Set(key, std::move(value)); return GetDict().Set(key, std::move(value));
} }
Value* Value::SetIntKey(StringPiece key, int value) {
return GetDict().Set(key, value);
}
Value* Value::SetStringKey(StringPiece key, StringPiece value) { Value* Value::SetStringKey(StringPiece key, StringPiece value) {
return GetDict().Set(key, value); return GetDict().Set(key, value);
} }

@@ -785,8 +785,6 @@ class BASE_EXPORT GSL_OWNER Value {
// ambiguities in the value type. // ambiguities in the value type.
// //
// DEPRECATED: Prefer `Value::Dict::Set()`. // DEPRECATED: Prefer `Value::Dict::Set()`.
Value* SetIntKey(StringPiece key, int val);
// DEPRECATED: Prefer `Value::Dict::Set()`.
Value* SetStringKey(StringPiece key, StringPiece val); Value* SetStringKey(StringPiece key, StringPiece val);
// DEPRECATED: Prefer `Value::Dict::Set()`. // DEPRECATED: Prefer `Value::Dict::Set()`.
Value* SetStringKey(StringPiece key, StringPiece16 val); Value* SetStringKey(StringPiece key, StringPiece16 val);

@@ -89,16 +89,16 @@ std::string GetInputEventSourceKey(InputEventSource event_source) {
} }
} }
base::Value ConvertEventCountsToValue( base::Value::Dict ConvertEventCountsToValue(
const AppPlatformInputMetrics::EventSourceToCounts& event_counts) { const AppPlatformInputMetrics::EventSourceToCounts& event_counts) {
base::Value event_counts_dict(base::Value::Type::DICT); base::Value::Dict event_counts_dict;
for (const auto& counts : event_counts) { for (const auto& counts : event_counts) {
base::Value count_dict(base::Value::Type::DICT); base::Value::Dict count_dict;
for (const auto& it : counts.second) { for (const auto& it : counts.second) {
count_dict.SetIntKey(GetAppTypeHistogramName(it.first), it.second); count_dict.Set(GetAppTypeHistogramName(it.first), it.second);
} }
event_counts_dict.SetKey(GetInputEventSourceKey(counts.first), event_counts_dict.Set(GetInputEventSourceKey(counts.first),
std::move(count_dict)); std::move(count_dict));
} }
return event_counts_dict; return event_counts_dict;
} }

@@ -33,20 +33,31 @@ TEST_F(GuestIdTest, GuestIdEquality) {
} }
TEST_F(GuestIdTest, GuestIdFromDictValue) { TEST_F(GuestIdTest, GuestIdFromDictValue) {
base::Value dict(base::Value::Type::DICT); {
dict.SetStringKey(prefs::kVmNameKey, "foo"); auto dict = base::Value::Dict()
dict.SetStringKey(prefs::kContainerNameKey, "bar"); .Set(prefs::kVmNameKey, "foo")
EXPECT_TRUE(GuestId(dict) == GuestId(VmType::TERMINA, "foo", "bar")); .Set(prefs::kContainerNameKey, "bar");
EXPECT_TRUE(GuestId(base::Value(std::move(dict))) ==
GuestId(VmType::TERMINA, "foo", "bar"));
}
dict.SetIntKey(prefs::kVmTypeKey, 0); {
dict.SetStringKey(prefs::kVmNameKey, "foo"); auto dict = base::Value::Dict()
dict.SetStringKey(prefs::kContainerNameKey, "bar"); .Set(prefs::kVmTypeKey, 0)
EXPECT_TRUE(GuestId(dict) == GuestId(VmType::TERMINA, "foo", "bar")); .Set(prefs::kVmNameKey, "foo")
.Set(prefs::kContainerNameKey, "bar");
EXPECT_TRUE(GuestId(base::Value(std::move(dict))) ==
GuestId(VmType::TERMINA, "foo", "bar"));
}
dict.SetIntKey(prefs::kVmTypeKey, 1); {
dict.SetStringKey(prefs::kVmNameKey, "foo"); auto dict = base::Value::Dict()
dict.SetStringKey(prefs::kContainerNameKey, "bar"); .Set(prefs::kVmTypeKey, 1)
EXPECT_TRUE(GuestId(dict) == GuestId(VmType::PLUGIN_VM, "foo", "bar")); .Set(prefs::kVmNameKey, "foo")
.Set(prefs::kContainerNameKey, "bar");
EXPECT_TRUE(GuestId(base::Value(std::move(dict))) ==
GuestId(VmType::PLUGIN_VM, "foo", "bar"));
}
} }
TEST_F(GuestIdTest, GuestIdFromNonDictValue) { TEST_F(GuestIdTest, GuestIdFromNonDictValue) {

@@ -9,10 +9,9 @@
namespace ash { namespace ash {
base::Value SystemWebAppData::AsDebugValue() const { base::Value::Dict SystemWebAppData::AsDebugValue() const {
base::Value root(base::Value::Type::DICT); return base::Value::Dict().Set("system_app_type",
root.SetIntKey("system_app_type", static_cast<int>(system_app_type)); static_cast<int>(system_app_type));
return root;
} }
bool operator==(const SystemWebAppData& chromeos_data1, bool operator==(const SystemWebAppData& chromeos_data1,

@@ -16,7 +16,7 @@ namespace ash {
// System Web App during reinstall, i.e. before // System Web App during reinstall, i.e. before
// `SystemWebAppManager::OnAppsSynchronized` is called. // `SystemWebAppManager::OnAppsSynchronized` is called.
struct SystemWebAppData { struct SystemWebAppData {
base::Value AsDebugValue() const; base::Value::Dict AsDebugValue() const;
SystemWebAppType system_app_type; SystemWebAppType system_app_type;
}; };

@@ -20,7 +20,7 @@ namespace {
HostDescriptionNode GetNodeWithLabel(const char* name, int label) { HostDescriptionNode GetNodeWithLabel(const char* name, int label) {
HostDescriptionNode node = {name, std::string(), HostDescriptionNode node = {name, std::string(),
base::Value(base::Value::Type::DICT)}; base::Value(base::Value::Type::DICT)};
node.representation.SetIntKey("label", label); node.representation.GetDict().Set("label", label);
return node; return node;
} }

@@ -487,12 +487,12 @@ void ImportantSitesUtil::RecordExcludedAndIgnoredImportantSites(
// We clear our ignore counter for sites that the user chose. // We clear our ignore counter for sites that the user chose.
for (const std::string& excluded_site : excluded_sites) { for (const std::string& excluded_site : excluded_sites) {
GURL origin("http://" + excluded_site); GURL origin("http://" + excluded_site);
base::Value dict(base::Value::Type::DICT); base::Value::Dict dict;
dict.SetIntKey(kNumTimesIgnoredName, 0); dict.Set(kNumTimesIgnoredName, 0);
dict.RemoveKey(kTimeLastIgnored); dict.Remove(kTimeLastIgnored);
map->SetWebsiteSettingDefaultScope(origin, origin, map->SetWebsiteSettingDefaultScope(origin, origin,
ContentSettingsType::IMPORTANT_SITE_INFO, ContentSettingsType::IMPORTANT_SITE_INFO,
std::move(dict)); base::Value(std::move(dict)));
} }
// Finally, record our old crossed-stats. // Finally, record our old crossed-stats.

@@ -152,11 +152,11 @@ TEST_F(UsbChooserContextTest, CheckGrantAndRevokePermission) {
device_manager_.CreateAndAddDevice(0, 0, "Google", "Gizmo", "123ABC"); device_manager_.CreateAndAddDevice(0, 0, "Google", "Gizmo", "123ABC");
UsbChooserContext* store = GetChooserContext(profile()); UsbChooserContext* store = GetChooserContext(profile());
base::Value object(base::Value::Type::DICT); auto object = base::Value(base::Value::Dict()
object.SetStringKey(kDeviceNameKey, "Gizmo"); .Set(kDeviceNameKey, "Gizmo")
object.SetIntKey(kVendorIdKey, 0); .Set(kVendorIdKey, 0)
object.SetIntKey(kProductIdKey, 0); .Set(kProductIdKey, 0)
object.SetStringKey(kSerialNumberKey, "123ABC"); .Set(kSerialNumberKey, "123ABC"));
EXPECT_FALSE(store->HasDevicePermission(origin, *device_info)); EXPECT_FALSE(store->HasDevicePermission(origin, *device_info));
EXPECT_CALL(*mock_permission_observers_[profile()], EXPECT_CALL(*mock_permission_observers_[profile()],
@@ -205,11 +205,12 @@ TEST_F(UsbChooserContextTest, CheckGrantAndRevokeEphemeralPermission) {
UsbChooserContext* store = GetChooserContext(profile()); UsbChooserContext* store = GetChooserContext(profile());
base::Value object(base::Value::Type::DICT); auto object = base::Value(
object.SetStringKey(kDeviceNameKey, "Gizmo"); base::Value::Dict()
object.SetStringKey(kGuidKey, device_info->guid); .Set(kDeviceNameKey, "Gizmo")
object.SetIntKey(kVendorIdKey, device_info->vendor_id); .Set(kGuidKey, device_info->guid)
object.SetIntKey(kProductIdKey, device_info->product_id); .Set(kVendorIdKey, static_cast<int>(device_info->vendor_id))
.Set(kProductIdKey, static_cast<int>(device_info->product_id)));
EXPECT_FALSE(store->HasDevicePermission(origin, *device_info)); EXPECT_FALSE(store->HasDevicePermission(origin, *device_info));
EXPECT_CALL(*mock_permission_observers_[profile()], EXPECT_CALL(*mock_permission_observers_[profile()],
@@ -726,7 +727,7 @@ class DeviceLoginScreenWebUsbChooserContextTest : public UsbChooserContextTest {
builder.SetPath(base::FilePath(FILE_PATH_LITERAL(chrome::kInitialProfile))); builder.SetPath(base::FilePath(FILE_PATH_LITERAL(chrome::kInitialProfile)));
signin_profile_ = builder.Build(); signin_profile_ = builder.Build();
} }
~DeviceLoginScreenWebUsbChooserContextTest() override {} ~DeviceLoginScreenWebUsbChooserContextTest() override = default;
protected: protected:
Profile* GetSigninProfile() { return signin_profile_.get(); } Profile* GetSigninProfile() { return signin_profile_.get(); }

@@ -637,7 +637,7 @@ base::Value WebApp::ClientData::AsDebugValue() const {
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
root.Set("system_web_app_data", system_web_app_data root.Set("system_web_app_data", system_web_app_data
? system_web_app_data->AsDebugValue() ? system_web_app_data->AsDebugValue()
: base::Value()); : base::Value::Dict());
#endif #endif
return base::Value(std::move(root)); return base::Value(std::move(root));
} }

@@ -14,6 +14,7 @@
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/credential_provider/gaiacp/event_logging_api_manager.h" #include "chrome/credential_provider/gaiacp/event_logging_api_manager.h"
#include "chrome/credential_provider/gaiacp/gcp_utils.h" #include "chrome/credential_provider/gaiacp/gcp_utils.h"
#include "chrome/credential_provider/gaiacp/gcpw_strings.h" #include "chrome/credential_provider/gaiacp/gcpw_strings.h"
@@ -428,8 +429,7 @@ HRESULT EventLogsUploadManager::UploadEventViewerLogs(
chunk_id = std::max(chunk_id, log_entry.event_id); chunk_id = std::max(chunk_id, log_entry.event_id);
base::Value log_entry_value(base::Value::Type::DICT); base::Value::Dict log_entry_value = log_entry.ToValue();
log_entry.ToValue(log_entry_value);
// Get the JSON for the log to keep track of payload size. // Get the JSON for the log to keep track of payload size.
std::string log_entry_json; std::string log_entry_json;
@@ -517,16 +517,18 @@ HRESULT EventLogsUploadManager::MakeUploadLogChunkRequest(
return S_OK; return S_OK;
} }
void EventLogsUploadManager::EventLogEntry::ToValue(base::Value& dict) const { base::Value::Dict EventLogsUploadManager::EventLogEntry::ToValue() const {
base::Value timestamp(base::Value::Type::DICT); return base::Value::Dict()
timestamp.SetIntKey(kEventLogTimeStampSecondsParameterName, .Set(kEventLogDataParameterName, base::WideToUTF8(data))
created_ts.seconds); .Set(kEventLogEventIdParameterName, static_cast<int>(event_id))
timestamp.SetIntKey(kEventLogTimeStampNanosParameterName, created_ts.nanos); .Set(kEventLogSeverityLevelParameterName,
static_cast<int>(severity_level))
dict.SetStringKey(kEventLogDataParameterName, base::WideToUTF8(data)); .Set(kEventLogTimeStampParameterName,
dict.SetIntKey(kEventLogEventIdParameterName, event_id); base::Value::Dict()
dict.SetIntKey(kEventLogSeverityLevelParameterName, severity_level); .Set(kEventLogTimeStampSecondsParameterName,
dict.SetKey(kEventLogTimeStampParameterName, std::move(timestamp)); static_cast<int>(created_ts.seconds))
.Set(kEventLogTimeStampNanosParameterName,
static_cast<int>(created_ts.nanos)));
} }
} // namespace credential_provider } // namespace credential_provider

@@ -58,7 +58,7 @@ class EventLogsUploadManager {
: event_id(id), created_ts(ts), data(data), severity_level(level) {} : event_id(id), created_ts(ts), data(data), severity_level(level) {}
// Converts to dictionary in a base::Value. // Converts to dictionary in a base::Value.
void ToValue(base::Value& dict) const; base::Value::Dict ToValue() const;
}; };
protected: protected:

@@ -111,14 +111,15 @@ bool PadSecret(const std::string& secret, std::string* out) {
std::memcpy(&padded_secret[padded_length - secret.size()], secret.data(), std::memcpy(&padded_secret[padded_length - secret.size()], secret.data(),
secret.size()); secret.size());
base::Value pwd_padding_dict(base::Value::Type::DICT); auto pwd_padding_dict =
pwd_padding_dict.SetStringKey(kPaddedPassword, padded_secret); base::Value::Dict()
pwd_padding_dict.SetIntKey(kPasswordLength, secret.size()); .Set(kPaddedPassword, padded_secret)
.Set(kPasswordLength, static_cast<int>(secret.size()));
SecurelyClearString(padded_secret); SecurelyClearString(padded_secret);
auto result = base::JSONWriter::Write(pwd_padding_dict, out); auto result = base::JSONWriter::Write(pwd_padding_dict, out);
const std::string* password_value = const std::string* password_value =
pwd_padding_dict.FindStringKey(kPaddedPassword); pwd_padding_dict.FindString(kPaddedPassword);
if (password_value) if (password_value)
SecurelyClearString(*const_cast<std::string*>(password_value)); SecurelyClearString(*const_cast<std::string*>(password_value));

@@ -43,9 +43,9 @@ TEST_P(GcpWinHttpUrlFetcherTest,
base::TimeDelta request_timeout = base::Milliseconds(timeout_in_millis); base::TimeDelta request_timeout = base::Milliseconds(timeout_in_millis);
absl::optional<base::Value> request_result; absl::optional<base::Value> request_result;
base::Value expected_result(base::Value::Type::DICT); auto expected_result = base::Value::Dict()
expected_result.SetStringKey("response-str-key", "response-str-value"); .Set("response-str-key", "response-str-value")
expected_result.SetIntKey("response-int-key", 4321); .Set("response-int-key", 4321);
std::string expected_response; std::string expected_response;
base::JSONWriter::Write(expected_result, &expected_response); base::JSONWriter::Write(expected_result, &expected_response);

@@ -98,19 +98,19 @@ MULTIPROCESS_TEST_MAIN(gls_main) {
expected_gaia_id = gaia_id_override; expected_gaia_id = gaia_id_override;
} }
base::Value dict(base::Value::Type::DICT); base::Value::Dict dict;
if (!gaia_id_override.empty() && gaia_id_override != expected_gaia_id) { if (!gaia_id_override.empty() && gaia_id_override != expected_gaia_id) {
dict.SetIntKey(kKeyExitCode, kUiecEMailMissmatch); dict.Set(kKeyExitCode, kUiecEMailMissmatch);
} else { } else {
dict.SetIntKey(kKeyExitCode, static_cast<UiExitCodes>(default_exit_code)); dict.Set(kKeyExitCode, static_cast<UiExitCodes>(default_exit_code));
dict.SetStringKey(kKeyEmail, expected_email); dict.Set(kKeyEmail, expected_email);
dict.SetStringKey(kKeyFullname, full_name); dict.Set(kKeyFullname, full_name);
dict.SetStringKey(kKeyId, expected_gaia_id); dict.Set(kKeyId, expected_gaia_id);
dict.SetStringKey(kKeyAccessToken, "at-123456"); dict.Set(kKeyAccessToken, "at-123456");
dict.SetStringKey(kKeyMdmIdToken, "idt-123456"); dict.Set(kKeyMdmIdToken, "idt-123456");
dict.SetStringKey(kKeyPassword, gaia_password); dict.Set(kKeyPassword, gaia_password);
dict.SetStringKey(kKeyRefreshToken, "rt-123456"); dict.Set(kKeyRefreshToken, "rt-123456");
dict.SetStringKey(kKeyTokenHandle, "th-123456"); dict.Set(kKeyTokenHandle, "th-123456");
} }
std::string json; std::string json;

@@ -603,7 +603,7 @@ TEST_F(DeviceCapabilitiesImplTest, MergeDictionary) {
// Now just update one of the fields. Make sure the updated value is changed // Now just update one of the fields. Make sure the updated value is changed
// in DeviceCapabilities and the other field remains untouched. // in DeviceCapabilities and the other field remains untouched.
deserialized_value->SetIntKey("dummy_field_int", 100); deserialized_value->GetDict().Set("dummy_field_int", 100);
ASSERT_TRUE(deserialized_value->RemoveKey("dummy_field_bool")); ASSERT_TRUE(deserialized_value->RemoveKey("dummy_field_bool"));
capabilities()->MergeDictionary(*deserialized_value); capabilities()->MergeDictionary(*deserialized_value);

@@ -55,7 +55,7 @@ Also consider the maximum size of any string parameters:
NetLog parameters are specified as a JSON serializable `base::Value` which does NetLog parameters are specified as a JSON serializable `base::Value` which does
not support 64-bit integers. not support 64-bit integers.
Be careful when using `base::Value::SetIntKey()` as it will truncate 64-bit Be careful when using `base::Value::Dict::Set()` as it will truncate 64-bit
values to 32-bits. values to 32-bits.
Instead use `NetLogNumberValue()`. Instead use `NetLogNumberValue()`.