| Index: chrome/browser/devtools/devtools_protocol.cc
|
| diff --git a/chrome/browser/devtools/devtools_protocol.cc b/chrome/browser/devtools/devtools_protocol.cc
|
| index a22811053180c073bdcfd1f65072d176f448765c..be81f377327594f82b3c37409095bddf7287fea2 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 {
|
| @@ -34,7 +37,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);
|
| @@ -46,11 +49,11 @@ std::unique_ptr<base::DictionaryValue>
|
| DevToolsProtocol::CreateInvalidParamsResponse(int command_id,
|
| const std::string& param) {
|
| std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
|
| - 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;
|
| }
|
| @@ -61,8 +64,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;
|
| }
|
|
|