Skip to content

Commit

Permalink
3656234: [CodeHealth] Remove uses of base::ListValue::Append() (Final…
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jun 3, 2022
1 parent 479647e commit e15d611
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3773,7 +3773,7 @@ void WebContents::DevToolsRequestFileSystems() {

base::ListValue file_system_value;
for (const auto& file_system : file_systems)
file_system_value.Append(CreateFileSystemValue(file_system));
file_system_value.Append(base::Value::FromUniquePtrValue(CreateFileSystemValue(file_system)));
inspectable_web_contents_->CallClientFunction(
"DevToolsAPI.fileSystemsLoaded", &file_system_value, nullptr, nullptr);
}
Expand Down
6 changes: 3 additions & 3 deletions shell/browser/api/gpu_info_enumerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ void GPUInfoEnumerator::EndGPUDevice() {
if (top_value->HasKey(kGPUDeviceKey)) {
base::ListValue* list;
top_value->GetList(kGPUDeviceKey, &list);
list->Append(std::move(current));
list->Append(base::Value::FromUniquePtrValue(std::move(current)));
} else {
auto gpus = std::make_unique<base::ListValue>();
gpus->Append(std::move(current));
std::unique_ptr<base::ListValue> gpus(new base::ListValue());
gpus->Append(base::Value::FromUniquePtrValue(std::move(current)));
top_value->SetList(kGPUDeviceKey, std::move(gpus));
}
current = std::move(top_value);
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/ui/inspectable_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ void InspectableWebContents::AddDevToolsExtensionsToClient() {
"exposeExperimentalAPIs",
extension->permissions_data()->HasAPIPermission(
extensions::mojom::APIPermissionID::kExperimental));
results.Append(std::move(extension_info));
results.Append(base::Value::FromUniquePtrValue(std::move(extension_info)));
}

CallClientFunction("DevToolsAPI.addExtensions", &results, NULL, NULL);
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/ui/webui/accessibility_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ void HandleAccessibilityRequestCallback(
descriptor->SetBoolean(kWeb, is_web_enabled);
descriptor->SetBoolean(kLabelImages,
are_accessibility_image_labels_enabled);
rvh_list->Append(std::move(descriptor));
rvh_list->Append(base::Value::FromUniquePtrValue(std::move(descriptor)));
}

data.Set(kPagesField, std::move(rvh_list));

auto window_list = std::make_unique<base::ListValue>();
for (auto* window : electron::WindowList::GetWindows()) {
window_list->Append(BuildTargetDescriptor(window));
window_list->Append(base::Value::FromUniquePtrValue(BuildTargetDescriptor(window)));
}

data.Set(kBrowsersField, std::move(window_list));
Expand Down
13 changes: 7 additions & 6 deletions shell/common/v8_value_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ std::unique_ptr<base::Value> V8ValueConverter::FromV8Array(
scope =
std::make_unique<v8::Context::Scope>(val->GetCreationContextChecked());

auto result = std::make_unique<base::ListValue>();
std::unique_ptr<base::ListValue> result(new base::ListValue());

// Only fields with integer keys are carried over to the ListValue.
for (uint32_t i = 0; i < val->Length(); ++i) {
Expand All @@ -409,18 +409,19 @@ std::unique_ptr<base::Value> V8ValueConverter::FromV8Array(

if (!val->HasRealIndexedProperty(isolate->GetCurrentContext(), i)
.FromMaybe(false)) {
result->Append(std::make_unique<base::Value>());
result->Append(base::Value());
continue;
}

std::unique_ptr<base::Value> child =
FromV8ValueImpl(state, child_v8, isolate);
if (child)
result->Append(std::move(child));
else
if (child) {
result->Append(base::Value::FromUniquePtrValue(std::move(child)));
} else {
// JSON.stringify puts null in places where values don't serialize, for
// example undefined and functions. Emulate that behavior.
result->Append(std::make_unique<base::Value>());
result->Append(base::Value());
}
}
return std::move(result);
}
Expand Down

0 comments on commit e15d611

Please sign in to comment.