| Index: content/browser/devtools/protocol/devtools_protocol_client.cc
|
| diff --git a/content/browser/devtools/protocol/devtools_protocol_client.cc b/content/browser/devtools/protocol/devtools_protocol_client.cc
|
| index 9ca03f9d1ab78ada98a01371675f42e979925748..4b7c25d6fe33a76ef730ea34e7e8b2313c93e11f 100644
|
| --- a/content/browser/devtools/protocol/devtools_protocol_client.cc
|
| +++ b/content/browser/devtools/protocol/devtools_protocol_client.cc
|
| @@ -6,7 +6,6 @@
|
|
|
| #include "base/json/json_writer.h"
|
| #include "base/strings/stringprintf.h"
|
| -#include "content/browser/devtools/protocol/devtools_protocol_delegate.h"
|
|
|
| namespace content {
|
|
|
| @@ -31,24 +30,24 @@
|
| } // namespace
|
|
|
| // static
|
| -const int DevToolsCommandId::kNoId = -1;
|
| +const DevToolsCommandId DevToolsProtocolClient::kNoId = -1;
|
|
|
| DevToolsProtocolClient::DevToolsProtocolClient(
|
| - DevToolsProtocolDelegate* notifier)
|
| - : notifier_(notifier) {}
|
| + const RawMessageCallback& raw_message_callback)
|
| + : raw_message_callback_(raw_message_callback) {
|
| +}
|
|
|
| DevToolsProtocolClient::~DevToolsProtocolClient() {
|
| }
|
|
|
| -void DevToolsProtocolClient::SendRawNotification(const std::string& message) {
|
| - notifier_->SendProtocolNotification(message);
|
| +void DevToolsProtocolClient::SendRawMessage(const std::string& message) {
|
| + raw_message_callback_.Run(message);
|
| }
|
|
|
| -void DevToolsProtocolClient::SendMessage(int session_id,
|
| - const base::DictionaryValue& message) {
|
| +void DevToolsProtocolClient::SendMessage(const base::DictionaryValue& message) {
|
| std::string json_message;
|
| base::JSONWriter::Write(message, &json_message);
|
| - notifier_->SendProtocolResponse(session_id, json_message);
|
| + SendRawMessage(json_message);
|
| }
|
|
|
| void DevToolsProtocolClient::SendNotification(
|
| @@ -59,21 +58,19 @@
|
| if (params)
|
| notification.Set(kParamsParam, params.release());
|
|
|
| - std::string json_message;
|
| - base::JSONWriter::Write(notification, &json_message);
|
| - SendRawNotification(json_message);
|
| + SendMessage(notification);
|
| }
|
|
|
| void DevToolsProtocolClient::SendSuccess(
|
| DevToolsCommandId command_id,
|
| scoped_ptr<base::DictionaryValue> params) {
|
| base::DictionaryValue response;
|
| - response.SetInteger(kIdParam, command_id.call_id);
|
| + response.SetInteger(kIdParam, command_id);
|
|
|
| response.Set(kResultParam,
|
| params ? params.release() : new base::DictionaryValue());
|
|
|
| - SendMessage(command_id.session_id, response);
|
| + SendMessage(response);
|
| }
|
|
|
| bool DevToolsProtocolClient::SendError(DevToolsCommandId command_id,
|
| @@ -83,10 +80,10 @@
|
| return false;
|
| }
|
| base::DictionaryValue dict;
|
| - if (command_id.call_id == DevToolsCommandId::kNoId)
|
| + if (command_id == kNoId)
|
| dict.Set(kIdParam, base::Value::CreateNullValue());
|
| else
|
| - dict.SetInteger(kIdParam, command_id.call_id);
|
| + dict.SetInteger(kIdParam, command_id);
|
|
|
| base::DictionaryValue* error_object = new base::DictionaryValue();
|
| error_object->SetInteger(kErrorCodeParam, response.status());
|
| @@ -94,7 +91,7 @@
|
| error_object->SetString(kErrorMessageParam, response.message());
|
|
|
| dict.Set(kErrorParam, error_object);
|
| - SendMessage(command_id.session_id, dict);
|
| + SendMessage(dict);
|
| return true;
|
| }
|
|
|
|
|