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

Unified Diff: src/debug.cc

Issue 115709: Unload debugger when message handler is cleared (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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
« no previous file with comments | « src/debug.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug.cc
===================================================================
--- src/debug.cc (revision 2034)
+++ src/debug.cc (working copy)
@@ -1589,7 +1589,7 @@
bool Debugger::is_loading_debugger_ = false;
bool Debugger::never_unload_debugger_ = false;
v8::Debug::MessageHandler2 Debugger::message_handler_ = NULL;
-bool Debugger::message_handler_cleared_ = false;
+bool Debugger::debugger_unload_pending_ = false;
v8::Debug::HostDispatchHandler Debugger::host_dispatch_handler_ = NULL;
int Debugger::host_dispatch_micros_ = 100 * 1000;
DebuggerAgent* Debugger::agent_ = NULL;
@@ -1981,8 +1981,8 @@
Debug::Unload();
}
- // Clear the flag indicating that the message handler was recently cleared.
- message_handler_cleared_ = false;
+ // Clear the flag indicating that the debugger should be unloaded.
+ debugger_unload_pending_ = false;
}
@@ -2169,17 +2169,7 @@
event_listener_data_ = Handle<Object>::cast(GlobalHandles::Create(*data));
}
- // Unload the debugger if event listener cleared.
- if (callback->IsUndefined()) {
- UnloadDebugger();
- }
-
- // Disable the compilation cache when the debugger is active.
- if (IsDebuggerActive()) {
- CompilationCache::Disable();
- } else {
- CompilationCache::Enable();
- }
+ ListenersChanged();
}
@@ -2187,22 +2177,32 @@
ScopedLock with(debugger_access_);
message_handler_ = handler;
+ ListenersChanged();
if (handler == NULL) {
- // Indicate that the message handler was recently cleared.
- message_handler_cleared_ = true;
-
// Send an empty command to the debugger if in a break to make JavaScript
// run again if the debugger is closed.
if (Debug::InDebugger()) {
ProcessCommand(Vector<const uint16_t>::empty());
}
}
+}
- // Disable the compilation cache when the debugger is active.
+
+void Debugger::ListenersChanged() {
if (IsDebuggerActive()) {
+ // Disable the compilation cache when the debugger is active.
CompilationCache::Disable();
} else {
CompilationCache::Enable();
+
+ // Unload the debugger if event listener and message handler cleared.
+ if (Debug::InDebugger()) {
+ // If we are in debugger set the flag to unload the debugger when last
+ // EnterDebugger on the current stack is destroyed.
+ debugger_unload_pending_ = true;
+ } else {
+ UnloadDebugger();
+ }
}
}
« no previous file with comments | « src/debug.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698