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

Unified Diff: chrome/browser/devtools/devtools_protocol.cc

Issue 2811673002: Reland: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Workaround with std::move Created 3 years, 8 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: chrome/browser/devtools/devtools_protocol.cc
diff --git a/chrome/browser/devtools/devtools_protocol.cc b/chrome/browser/devtools/devtools_protocol.cc
index 8581d8b6279fd050ad9be9801d33dbe60bfb9ee1..b58184e9de7a6475814de4c8c1936de2a552fafe 100644
--- a/chrome/browser/devtools/devtools_protocol.cc
+++ b/chrome/browser/devtools/devtools_protocol.cc
@@ -4,8 +4,11 @@
#include "chrome/browser/devtools/devtools_protocol.h"
+#include <utility>
+
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
namespace {
@@ -32,7 +35,7 @@ std::string DevToolsProtocol::SerializeCommand(
command.SetInteger(kIdParam, command_id);
command.SetString(kMethodParam, method);
if (params)
- command.Set(kParamsParam, params.release());
+ command.Set(kParamsParam, std::move(params));
std::string json_command;
base::JSONWriter::Write(command, &json_command);
@@ -45,11 +48,11 @@ DevToolsProtocol::CreateInvalidParamsResponse(int command_id,
const std::string& param) {
std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
response->SetInteger(kIdParam, command_id);
- base::DictionaryValue* error_object = new base::DictionaryValue();
- response->Set(kErrorParam, error_object);
+ auto error_object = base::MakeUnique<base::DictionaryValue>();
error_object->SetInteger(kErrorCodeParam, kErrorInvalidParams);
error_object->SetString(kErrorMessageParam,
base::StringPrintf("Missing or invalid '%s' parameter", param.c_str()));
+ response->Set(kErrorParam, std::move(error_object));
return response;
}
@@ -73,8 +76,9 @@ std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateSuccessResponse(
std::unique_ptr<base::DictionaryValue> result) {
std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
response->SetInteger(kIdParam, command_id);
- response->Set(kResultParam,
- result ? result.release() : new base::DictionaryValue());
+ response->Set(kResultParam, result
+ ? std::move(result)
+ : base::MakeUnique<base::DictionaryValue>());
return response;
}
« no previous file with comments | « chrome/browser/custom_handlers/protocol_handler_registry.cc ('k') | chrome/browser/devtools/devtools_targets_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698