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

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

Issue 12906011: Detect debugging target crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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 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(&notification, &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", &params);
+ command_dict->GetDictionary(kParamsParam, &params);
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
« no previous file with comments | « content/browser/devtools/devtools_protocol.h ('k') | content/browser/devtools/devtools_protocol_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698