Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1314)

Unified Diff: content/browser/gpu/gpu_internals_ui.cc

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/gpu/gpu_internals_ui.cc
diff --git a/content/browser/gpu/gpu_internals_ui.cc b/content/browser/gpu/gpu_internals_ui.cc
index 45f2f6d2745f5092a74d04c79b80a0f0bdbf2171..066f6d030d3e83f2da2b6eea6766a6b836e5e27d 100644
--- a/content/browser/gpu/gpu_internals_ui.cc
+++ b/content/browser/gpu/gpu_internals_ui.cc
@@ -80,17 +80,17 @@ std::unique_ptr<base::DictionaryValue> NewDescriptionValuePair(
std::unique_ptr<base::DictionaryValue> NewDescriptionValuePair(
const std::string& desc,
- base::Value* value) {
+ std::unique_ptr<base::Value> value) {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetString("description", desc);
- dict->Set("value", value);
+ dict->Set("value", std::move(value));
return dict;
}
#if defined(OS_WIN)
// Output DxDiagNode tree as nested array of {description,value} pairs
-base::ListValue* DxDiagNodeToList(const gpu::DxDiagNode& node) {
- base::ListValue* list = new base::ListValue();
+std::unique_ptr<base::ListValue> DxDiagNodeToList(const gpu::DxDiagNode& node) {
+ auto list = base::MakeUnique<base::ListValue>();
for (std::map<std::string, std::string>::const_iterator it =
node.values.begin();
it != node.values.end();
@@ -102,8 +102,8 @@ base::ListValue* DxDiagNodeToList(const gpu::DxDiagNode& node) {
node.children.begin();
it != node.children.end();
++it) {
- base::ListValue* sublist = DxDiagNodeToList(it->second);
- list->Append(NewDescriptionValuePair(it->first, sublist));
+ std::unique_ptr<base::ListValue> sublist = DxDiagNodeToList(it->second);
+ list->Append(NewDescriptionValuePair(it->first, std::move(sublist)));
}
return list;
}
@@ -120,21 +120,23 @@ std::string GPUDeviceToString(const gpu::GPUInfo::GPUDevice& gpu) {
vendor.c_str(), device.c_str(), gpu.active ? " *ACTIVE*" : "");
}
-base::DictionaryValue* GpuInfoAsDictionaryValue() {
+std::unique_ptr<base::DictionaryValue> GpuInfoAsDictionaryValue() {
gpu::GPUInfo gpu_info = GpuDataManagerImpl::GetInstance()->GetGPUInfo();
- base::ListValue* basic_info = new base::ListValue();
+ auto basic_info = base::MakeUnique<base::ListValue>();
basic_info->Append(NewDescriptionValuePair(
"Initialization time",
base::Int64ToString(gpu_info.initialization_time.InMilliseconds())));
basic_info->Append(NewDescriptionValuePair(
- "In-process GPU", new base::Value(gpu_info.in_process_gpu)));
+ "In-process GPU",
+ base::MakeUnique<base::Value>(gpu_info.in_process_gpu)));
basic_info->Append(NewDescriptionValuePair(
"Passthrough Command Decoder",
- new base::Value(gpu_info.passthrough_cmd_decoder)));
+ base::MakeUnique<base::Value>(gpu_info.passthrough_cmd_decoder)));
basic_info->Append(NewDescriptionValuePair(
- "Supports overlays", new base::Value(gpu_info.supports_overlays)));
+ "Supports overlays",
+ base::MakeUnique<base::Value>(gpu_info.supports_overlays)));
basic_info->Append(NewDescriptionValuePair(
- "Sandboxed", new base::Value(gpu_info.sandboxed)));
+ "Sandboxed", base::MakeUnique<base::Value>(gpu_info.sandboxed)));
basic_info->Append(NewDescriptionValuePair(
"GPU0", GPUDeviceToString(gpu_info.gpu)));
for (size_t i = 0; i < gpu_info.secondary_gpus.size(); ++i) {
@@ -142,12 +144,13 @@ base::DictionaryValue* GpuInfoAsDictionaryValue() {
base::StringPrintf("GPU%d", static_cast<int>(i + 1)),
GPUDeviceToString(gpu_info.secondary_gpus[i])));
}
- basic_info->Append(
- NewDescriptionValuePair("Optimus", new base::Value(gpu_info.optimus)));
- basic_info->Append(
- NewDescriptionValuePair("Optimus", new base::Value(gpu_info.optimus)));
basic_info->Append(NewDescriptionValuePair(
- "AMD switchable", new base::Value(gpu_info.amd_switchable)));
+ "Optimus", base::MakeUnique<base::Value>(gpu_info.optimus)));
+ basic_info->Append(NewDescriptionValuePair(
+ "Optimus", base::MakeUnique<base::Value>(gpu_info.optimus)));
+ basic_info->Append(NewDescriptionValuePair(
+ "AMD switchable",
+ base::MakeUnique<base::Value>(gpu_info.amd_switchable)));
#if defined(OS_WIN)
std::string compositor =
ui::win::IsAeroGlassEnabled() ? "Aero Glass" : "none";
@@ -232,17 +235,16 @@ base::DictionaryValue* GpuInfoAsDictionaryValue() {
basic_info->Append(NewDescriptionValuePair(
"Reset notification strategy", reset_strategy));
- basic_info->Append(
- NewDescriptionValuePair("GPU process crash count",
- new base::Value(gpu_info.process_crash_count)));
+ basic_info->Append(NewDescriptionValuePair(
+ "GPU process crash count",
+ base::MakeUnique<base::Value>(gpu_info.process_crash_count)));
- base::DictionaryValue* info = new base::DictionaryValue();
- info->Set("basic_info", basic_info);
+ auto info = base::MakeUnique<base::DictionaryValue>();
#if defined(OS_WIN)
auto dx_info = base::MakeUnique<base::Value>();
if (gpu_info.dx_diagnostics.children.size())
- dx_info.reset(DxDiagNodeToList(gpu_info.dx_diagnostics));
+ dx_info = DxDiagNodeToList(gpu_info.dx_diagnostics);
info->Set("diagnostics", std::move(dx_info));
#endif
@@ -253,6 +255,7 @@ base::DictionaryValue* GpuInfoAsDictionaryValue() {
"RGBA visual ID", base::Uint64ToString(gpu_info.rgba_visual)));
#endif
+ info->Set("basic_info", std::move(basic_info));
return info;
}
@@ -314,8 +317,8 @@ const char* BufferUsageToString(gfx::BufferUsage usage) {
return nullptr;
}
-base::ListValue* CompositorInfo() {
- base::ListValue* compositor_info = new base::ListValue();
+std::unique_ptr<base::ListValue> CompositorInfo() {
+ auto compositor_info = base::MakeUnique<base::ListValue>();
compositor_info->Append(NewDescriptionValuePair(
"Tile Update Mode",
@@ -326,8 +329,8 @@ base::ListValue* CompositorInfo() {
return compositor_info;
}
-base::ListValue* GpuMemoryBufferInfo() {
- base::ListValue* gpu_memory_buffer_info = new base::ListValue();
+std::unique_ptr<base::ListValue> GpuMemoryBufferInfo() {
+ auto gpu_memory_buffer_info = base::MakeUnique<base::ListValue>();
BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager =
BrowserGpuMemoryBufferManager::current();
@@ -381,8 +384,10 @@ class GpuMessageHandler
void OnCallAsync(const base::ListValue* list);
// Submessages dispatched from OnCallAsync
- base::Value* OnRequestClientInfo(const base::ListValue* list);
- base::Value* OnRequestLogMessages(const base::ListValue* list);
+ std::unique_ptr<base::DictionaryValue> OnRequestClientInfo(
+ const base::ListValue* list);
+ std::unique_ptr<base::ListValue> OnRequestLogMessages(
+ const base::ListValue* list);
private:
// True if observing the GpuDataManager (re-attaching as observer would
@@ -431,7 +436,7 @@ void GpuMessageHandler::OnCallAsync(const base::ListValue* args) {
ok = args->GetString(1, &submessage);
DCHECK(ok);
- base::ListValue* submessageArgs = new base::ListValue();
+ auto submessageArgs = base::MakeUnique<base::ListValue>();
for (size_t i = 2; i < args->GetSize(); ++i) {
const base::Value* arg;
ok = args->Get(i, &arg);
@@ -441,23 +446,20 @@ void GpuMessageHandler::OnCallAsync(const base::ListValue* args) {
}
// call the submessage handler
- base::Value* ret = NULL;
+ std::unique_ptr<base::Value> ret;
if (submessage == "requestClientInfo") {
- ret = OnRequestClientInfo(submessageArgs);
+ ret = OnRequestClientInfo(submessageArgs.get());
} else if (submessage == "requestLogMessages") {
- ret = OnRequestLogMessages(submessageArgs);
+ ret = OnRequestLogMessages(submessageArgs.get());
} else { // unrecognized submessage
NOTREACHED();
- delete submessageArgs;
return;
}
- delete submessageArgs;
// call BrowserBridge.onCallAsyncReply with result
if (ret) {
web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onCallAsyncReply",
*requestId, *ret);
- delete ret;
} else {
web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onCallAsyncReply",
*requestId);
@@ -484,11 +486,11 @@ void GpuMessageHandler::OnBrowserBridgeInitialized(
OnGpuInfoUpdate();
}
-base::Value* GpuMessageHandler::OnRequestClientInfo(
+std::unique_ptr<base::DictionaryValue> GpuMessageHandler::OnRequestClientInfo(
const base::ListValue* list) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::DictionaryValue* dict = new base::DictionaryValue();
+ auto dict = base::MakeUnique<base::DictionaryValue>();
dict->SetString("version", GetContentClient()->GetProduct());
dict->SetString("command_line",
@@ -508,7 +510,8 @@ base::Value* GpuMessageHandler::OnRequestClientInfo(
return dict;
}
-base::Value* GpuMessageHandler::OnRequestLogMessages(const base::ListValue*) {
+std::unique_ptr<base::ListValue> GpuMessageHandler::OnRequestLogMessages(
+ const base::ListValue*) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return GpuDataManagerImpl::GetInstance()->GetLogMessages();
@@ -520,14 +523,14 @@ void GpuMessageHandler::OnGpuInfoUpdate() {
GpuInfoAsDictionaryValue());
// Add in blacklisting features
- base::DictionaryValue* feature_status = new base::DictionaryValue;
+ auto feature_status = base::MakeUnique<base::DictionaryValue>();
feature_status->Set("featureStatus", GetFeatureStatus());
feature_status->Set("problems", GetProblems());
- base::ListValue* workarounds = new base::ListValue();
+ auto workarounds = base::MakeUnique<base::ListValue>();
for (const std::string& workaround : GetDriverBugWorkarounds())
workarounds->AppendString(workaround);
- feature_status->Set("workarounds", workarounds);
- gpu_info_val->Set("featureStatus", feature_status);
+ feature_status->Set("workarounds", std::move(workarounds));
+ gpu_info_val->Set("featureStatus", std::move(feature_status));
gpu_info_val->Set("compositorInfo", CompositorInfo());
gpu_info_val->Set("gpuMemoryBufferInfo", GpuMemoryBufferInfo());
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl_private.cc ('k') | content/browser/indexed_db/indexed_db_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698