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

Unified Diff: src/debug-agent.cc

Issue 6113004: Version 3.0.7 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 9 years, 11 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
« no previous file with comments | « src/debug.cc ('k') | src/debug-debugger.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug-agent.cc
diff --git a/src/debug-agent.cc b/src/debug-agent.cc
index e2d9304338738d0a606fee1c87424d7cb8072f7e..6901079b9b060d6d85af83b8faff8fbb2c31c0c1 100644
--- a/src/debug-agent.cc
+++ b/src/debug-agent.cc
@@ -27,9 +27,11 @@
#include "v8.h"
+#include "debug.h"
#include "debug-agent.h"
#ifdef ENABLE_DEBUGGER_SUPPORT
+
namespace v8 {
namespace internal {
@@ -167,22 +169,33 @@ void DebuggerAgentSession::Run() {
while (true) {
// Read data from the debugger front end.
SmartPointer<char> message = DebuggerAgentUtil::ReceiveMessage(client_);
- if (*message == NULL) {
- // Session is closed.
- agent_->OnSessionClosed(this);
- return;
+
+ const char* msg = *message;
+ bool is_closing_session = (msg == NULL);
+
+ if (msg == NULL) {
+ // If we lost the connection, then simulate a disconnect msg:
+ msg = "{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}";
+
+ } else {
+ // Check if we're getting a disconnect request:
+ const char* disconnectRequestStr =
+ "\"type\":\"request\",\"command\":\"disconnect\"}";
+ const char* result = strstr(msg, disconnectRequestStr);
+ if (result != NULL) {
+ is_closing_session = true;
+ }
}
// Convert UTF-8 to UTF-16.
- unibrow::Utf8InputBuffer<> buf(*message,
- StrLength(*message));
+ unibrow::Utf8InputBuffer<> buf(msg, StrLength(msg));
int len = 0;
while (buf.has_more()) {
buf.GetNext();
len++;
}
ScopedVector<int16_t> temp(len + 1);
- buf.Reset(*message, StrLength(*message));
+ buf.Reset(msg, StrLength(msg));
for (int i = 0; i < len; i++) {
temp[i] = buf.GetNext();
}
@@ -190,6 +203,12 @@ void DebuggerAgentSession::Run() {
// Send the request received to the debugger.
v8::Debug::SendCommand(reinterpret_cast<const uint16_t *>(temp.start()),
len);
+
+ if (is_closing_session) {
+ // Session is closed.
+ agent_->OnSessionClosed(this);
+ return;
+ }
}
}
« no previous file with comments | « src/debug.cc ('k') | src/debug-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698