| 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;
|
| }
|
|
|