| Index: content/browser/devtools/devtools_protocol.cc
|
| diff --git a/content/browser/devtools/devtools_protocol.cc b/content/browser/devtools/devtools_protocol.cc
|
| index 98277023f7a67a3446b8a8c7c2d681462dad89fd..28d6fe806da3ece6e5f469d2f81a544fb5fc5cf2 100644
|
| --- a/content/browser/devtools/devtools_protocol.cc
|
| +++ b/content/browser/devtools/devtools_protocol.cc
|
| @@ -109,15 +109,36 @@ std::string DevToolsProtocol::Notification::Serialize() {
|
| DictionaryValue response;
|
|
|
| base::DictionaryValue notification;
|
| - notification.SetString("method", method_);
|
| + notification.SetString(kMethodParam, method_);
|
| if (params_.get())
|
| - notification.Set("params", params_->DeepCopy());
|
| + notification.Set(kParamsParam, params_->DeepCopy());
|
|
|
| std::string json_notification;
|
| base::JSONWriter::Write(¬ification, &json_notification);
|
| return json_notification;
|
| }
|
|
|
| +DevToolsProtocol::Event::~Event() {
|
| +}
|
| +
|
| +std::string DevToolsProtocol::Event::Serialize() {
|
| + DictionaryValue dictionary;
|
| +
|
| + dictionary.SetString(kMethodParam, method_);
|
| + if (params_)
|
| + dictionary.Set(kParamsParam, params_->DeepCopy());
|
| +
|
| + std::string result;
|
| + base::JSONWriter::Write(&dictionary, &result);
|
| + return result;
|
| +}
|
| +
|
| +DevToolsProtocol::Event::Event(const std::string& method,
|
| + DictionaryValue* params)
|
| + : method_(method),
|
| + params_(params) {
|
| +}
|
| +
|
| DevToolsProtocol::Handler::~Handler() {
|
| }
|
|
|
| @@ -173,9 +194,9 @@ DevToolsProtocol::Command* DevToolsProtocol::ParseCommand(
|
| int id;
|
| std::string method;
|
| bool ok = true;
|
| - ok &= command_dict->GetInteger("id", &id);
|
| + ok &= command_dict->GetInteger(kIdParam, &id);
|
| ok &= id >= 0;
|
| - ok &= command_dict->GetString("method", &method);
|
| + ok &= command_dict->GetString(kMethodParam, &method);
|
| if (!ok) {
|
| Response response(kNoId, kErrorInvalidRequest, "Invalid request");
|
| *error_response = response.Serialize();
|
| @@ -192,8 +213,15 @@ DevToolsProtocol::Command* DevToolsProtocol::ParseCommand(
|
| std::string domain = method.substr(0, pos);
|
|
|
| base::DictionaryValue* params = NULL;
|
| - command_dict->GetDictionary("params", ¶ms);
|
| + command_dict->GetDictionary(kParamsParam, ¶ms);
|
| return new Command(id, domain, method, params ? params->DeepCopy() : NULL);
|
| }
|
|
|
| +//static
|
| +DevToolsProtocol::Event* DevToolsProtocol::CreateEvent(
|
| + const std::string& method,
|
| + base::DictionaryValue* params) {
|
| + return new Event(method, params);
|
| +}
|
| +
|
| } // namespace content
|
|
|