Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1111)

Unified Diff: content/browser/devtools/devtools_protocol.cc

Issue 290873002: DevTools: allow embedder handling remote debugger commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary include Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/devtools/devtools_protocol.cc
diff --git a/content/browser/devtools/devtools_protocol.cc b/content/browser/devtools/devtools_protocol.cc
index f3c393d2c0e92627651cb0959be86d555c09f384..e6800e702c8f776225ce8c7e83cccc1d00187197 100644
--- a/content/browser/devtools/devtools_protocol.cc
+++ b/content/browser/devtools/devtools_protocol.cc
@@ -216,13 +216,20 @@ scoped_refptr<DevToolsProtocol::Command> DevToolsProtocol::ParseCommand(
std::string* error_response) {
scoped_ptr<base::DictionaryValue> command_dict(
ParseMessage(json, error_response));
+ return ParseCommand(command_dict.get(), error_response);
+}
+
+// static
+scoped_refptr<DevToolsProtocol::Command> DevToolsProtocol::ParseCommand(
+ base::DictionaryValue* command_dict,
+ std::string* error_response) {
if (!command_dict)
return NULL;
int id;
std::string method;
bool ok = command_dict->GetInteger(kIdParam, &id) && id >= 0;
- ok = ok && ParseMethod(command_dict.get(), &method);
+ ok = ok && ParseMethod(command_dict, &method);
if (!ok) {
scoped_refptr<Response> response =
new Response(kNoId, kErrorInvalidRequest, "No such method");
@@ -244,6 +251,29 @@ DevToolsProtocol::CreateCommand(
return new Command(id, method, params);
}
+//static
+scoped_refptr<DevToolsProtocol::Response>
+DevToolsProtocol::ParseResponse(
+ base::DictionaryValue* response_dict) {
+ int id;
+ if (!response_dict->GetInteger(kIdParam, &id))
+ id = kNoId;
+
+ int error_code;
+ if (!response_dict->GetInteger(kErrorCodeParam, &error_code))
+ return new Response(id, kErrorInternalError, "Invalid response");
+
+ if (error_code) {
+ std::string error_message;
+ response_dict->GetString(kErrorMessageParam, &error_message);
+ return new Response(id, error_code, error_message);
+ }
+
+ const base::DictionaryValue* result = NULL;
+ response_dict->GetDictionary(kResultParam, &result);
+ return new Response(id, result ? result->DeepCopy() : NULL);
+}
+
// static
scoped_refptr<DevToolsProtocol::Notification>
DevToolsProtocol::ParseNotification(const std::string& json) {
« no previous file with comments | « content/browser/devtools/devtools_protocol.h ('k') | content/browser/devtools/render_view_devtools_agent_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698