| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/devtools/protocol/devtools_protocol_client.h" | 5 #include "content/browser/devtools/protocol/devtools_protocol_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "content/browser/devtools/protocol/devtools_protocol_delegate.h" | 9 #include "content/browser/devtools/protocol/devtools_protocol_delegate.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 void DevToolsProtocolClient::SendMessage(int session_id, | 47 void DevToolsProtocolClient::SendMessage(int session_id, |
| 48 const base::DictionaryValue& message) { | 48 const base::DictionaryValue& message) { |
| 49 std::string json_message; | 49 std::string json_message; |
| 50 base::JSONWriter::Write(message, &json_message); | 50 base::JSONWriter::Write(message, &json_message); |
| 51 notifier_->SendProtocolResponse(session_id, json_message); | 51 notifier_->SendProtocolResponse(session_id, json_message); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void DevToolsProtocolClient::SendNotification( | 54 void DevToolsProtocolClient::SendNotification( |
| 55 const std::string& method, | 55 const std::string& method, |
| 56 scoped_ptr<base::DictionaryValue> params) { | 56 std::unique_ptr<base::DictionaryValue> params) { |
| 57 base::DictionaryValue notification; | 57 base::DictionaryValue notification; |
| 58 notification.SetString(kMethodParam, method); | 58 notification.SetString(kMethodParam, method); |
| 59 if (params) | 59 if (params) |
| 60 notification.Set(kParamsParam, params.release()); | 60 notification.Set(kParamsParam, params.release()); |
| 61 | 61 |
| 62 std::string json_message; | 62 std::string json_message; |
| 63 base::JSONWriter::Write(notification, &json_message); | 63 base::JSONWriter::Write(notification, &json_message); |
| 64 SendRawNotification(json_message); | 64 SendRawNotification(json_message); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void DevToolsProtocolClient::SendSuccess( | 67 void DevToolsProtocolClient::SendSuccess( |
| 68 DevToolsCommandId command_id, | 68 DevToolsCommandId command_id, |
| 69 scoped_ptr<base::DictionaryValue> params) { | 69 std::unique_ptr<base::DictionaryValue> params) { |
| 70 base::DictionaryValue response; | 70 base::DictionaryValue response; |
| 71 response.SetInteger(kIdParam, command_id.call_id); | 71 response.SetInteger(kIdParam, command_id.call_id); |
| 72 | 72 |
| 73 response.Set(kResultParam, | 73 response.Set(kResultParam, |
| 74 params ? params.release() : new base::DictionaryValue()); | 74 params ? params.release() : new base::DictionaryValue()); |
| 75 | 75 |
| 76 SendMessage(command_id.session_id, response); | 76 SendMessage(command_id.session_id, response); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool DevToolsProtocolClient::SendError(DevToolsCommandId command_id, | 79 bool DevToolsProtocolClient::SendError(DevToolsCommandId command_id, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 Response::Response(int status) | 136 Response::Response(int status) |
| 137 : status_(status) { | 137 : status_(status) { |
| 138 } | 138 } |
| 139 | 139 |
| 140 Response::Response(int status, const std::string& message) | 140 Response::Response(int status, const std::string& message) |
| 141 : status_(status), | 141 : status_(status), |
| 142 message_(message) { | 142 message_(message) { |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace content | 145 } // namespace content |
| OLD | NEW |