| Index: chrome/browser/devtools/devtools_protocol.cc
|
| diff --git a/chrome/browser/devtools/devtools_protocol.cc b/chrome/browser/devtools/devtools_protocol.cc
|
| index eed5940b627c915ecdd48543f1965dcb695a9574..922f9e913e0c068e2ec2eb855e88b6ed8495aeed 100644
|
| --- a/chrome/browser/devtools/devtools_protocol.cc
|
| +++ b/chrome/browser/devtools/devtools_protocol.cc
|
| @@ -11,6 +11,8 @@ namespace {
|
| const char kIdParam[] = "id";
|
| const char kMethodParam[] = "method";
|
| const char kParamsParam[] = "params";
|
| +const char kErrorParam[] = "error";
|
| +const char kErrorCodeParam[] = "code";
|
| } // namespace
|
|
|
| DevToolsProtocol::Message::~Message() {
|
| @@ -52,6 +54,14 @@ DevToolsProtocol::Notification::Notification(const std::string& method,
|
| : Message(method, params) {
|
| }
|
|
|
| +DevToolsProtocol::Response::~Response() {
|
| +}
|
| +
|
| +DevToolsProtocol::Response::Response(int id, int error_code)
|
| + : id_(id),
|
| + error_code_(error_code) {
|
| +}
|
| +
|
| // static
|
| DevToolsProtocol::Notification* DevToolsProtocol::ParseNotification(
|
| const std::string& json) {
|
| @@ -70,3 +80,23 @@ DevToolsProtocol::Notification* DevToolsProtocol::ParseNotification(
|
| dict->GetDictionary(kParamsParam, ¶ms);
|
| return new Notification(method, params);
|
| }
|
| +
|
| +DevToolsProtocol::Response* DevToolsProtocol::ParseResponse(
|
| + const std::string& json) {
|
| + scoped_ptr<base::Value> value(base::JSONReader::Read(json));
|
| + if (!value || !value->IsType(Value::TYPE_DICTIONARY))
|
| + return NULL;
|
| +
|
| + scoped_ptr<base::DictionaryValue> dict(
|
| + static_cast<base::DictionaryValue*>(value.release()));
|
| +
|
| + int id;
|
| + if (!dict->GetInteger(kIdParam, &id))
|
| + return NULL;
|
| +
|
| + int error_code = 0;
|
| + base::DictionaryValue* error_dict = NULL;
|
| + if (dict->GetDictionary(kErrorParam, &error_dict))
|
| + error_dict->GetInteger(kErrorCodeParam, &error_code);
|
| + return new Response(id, error_code);
|
| +}
|
|
|