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

Side by Side Diff: src/api.cc

Issue 19753: Changed the debugger API to allow only one debug event listener to be registe... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8-debug.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2809 error = *result; 2809 error = *result;
2810 } 2810 }
2811 i::Handle<i::Object> result(error); 2811 i::Handle<i::Object> result(error);
2812 return Utils::ToLocal(result); 2812 return Utils::ToLocal(result);
2813 } 2813 }
2814 2814
2815 2815
2816 // --- D e b u g S u p p o r t --- 2816 // --- D e b u g S u p p o r t ---
2817 2817
2818 2818
2819 bool Debug::AddDebugEventListener(DebugEventCallback that, Handle<Value> data) { 2819 bool Debug::SetDebugEventListener(DebugEventCallback that, Handle<Value> data) {
2820 EnsureInitialized("v8::Debug::AddDebugEventListener()"); 2820 EnsureInitialized("v8::Debug::SetDebugEventListener()");
2821 ON_BAILOUT("v8::Debug::AddDebugEventListener()", return false); 2821 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false);
2822 HandleScope scope; 2822 HandleScope scope;
2823 NeanderArray listeners(i::Factory::debug_event_listeners()); 2823 i::Debugger::SetEventListener(i::Factory::NewProxy(FUNCTION_ADDR(that)),
2824 NeanderObject obj(2); 2824 Utils::OpenHandle(*data));
2825 obj.set(0, *i::Factory::NewProxy(FUNCTION_ADDR(that)));
2826 obj.set(1, data.IsEmpty() ?
2827 i::Heap::undefined_value() :
2828 *Utils::OpenHandle(*data));
2829 listeners.add(obj.value());
2830 i::Debugger::UpdateActiveDebugger();
2831 return true; 2825 return true;
2832 } 2826 }
2833 2827
2834 2828
2835 bool Debug::AddDebugEventListener(v8::Handle<v8::Function> that, 2829 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that,
2836 Handle<Value> data) { 2830 Handle<Value> data) {
2837 ON_BAILOUT("v8::Debug::AddDebugEventListener()", return false); 2831 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false);
2838 HandleScope scope; 2832 i::Debugger::SetEventListener(Utils::OpenHandle(*that),
2839 NeanderArray listeners(i::Factory::debug_event_listeners()); 2833 Utils::OpenHandle(*data));
2840 NeanderObject obj(2);
2841 obj.set(0, *Utils::OpenHandle(*that));
2842 obj.set(1, data.IsEmpty() ?
2843 i::Heap::undefined_value() :
2844 *Utils::OpenHandle(*data));
2845 listeners.add(obj.value());
2846 i::Debugger::UpdateActiveDebugger();
2847 return true; 2834 return true;
2848 } 2835 }
2849 2836
2850 2837
2851 void Debug::RemoveDebugEventListener(DebugEventCallback that) {
2852 EnsureInitialized("v8::Debug::RemoveDebugEventListener()");
2853 ON_BAILOUT("v8::Debug::RemoveDebugEventListener()", return);
2854 HandleScope scope;
2855 NeanderArray listeners(i::Factory::debug_event_listeners());
2856 for (int i = 0; i < listeners.length(); i++) {
2857 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
2858
2859 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
2860 // When removing a C debug event listener only consider proxy objects.
2861 if (listener.get(0)->IsProxy()) {
2862 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0)));
2863 if (callback_obj->proxy() == FUNCTION_ADDR(that)) {
2864 listeners.set(i, i::Heap::undefined_value());
2865 }
2866 }
2867 }
2868 i::Debugger::UpdateActiveDebugger();
2869 }
2870
2871
2872 void Debug::RemoveDebugEventListener(v8::Handle<v8::Function> that) {
2873 ON_BAILOUT("v8::Debug::RemoveDebugEventListener()", return);
2874 HandleScope scope;
2875 NeanderArray listeners(i::Factory::debug_event_listeners());
2876 for (int i = 0; i < listeners.length(); i++) {
2877 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
2878
2879 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
2880 // When removing a JavaScript debug event listener only consider JavaScript
2881 // function objects.
2882 if (listener.get(0)->IsJSFunction()) {
2883 i::JSFunction* callback = i::JSFunction::cast(listener.get(0));
2884 i::Handle<i::JSFunction> callback_fun(callback);
2885 if (callback_fun.is_identical_to(Utils::OpenHandle(*that))) {
2886 listeners.set(i, i::Heap::undefined_value());
2887 }
2888 }
2889 }
2890 i::Debugger::UpdateActiveDebugger();
2891 }
2892
2893
2894 void Debug::DebugBreak() { 2838 void Debug::DebugBreak() {
2895 if (!i::V8::HasBeenSetup()) return; 2839 if (!i::V8::HasBeenSetup()) return;
2896 i::StackGuard::DebugBreak(); 2840 i::StackGuard::DebugBreak();
2897 } 2841 }
2898 2842
2899 2843
2900 void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data) { 2844 void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data) {
2901 EnsureInitialized("v8::Debug::SetMessageHandler"); 2845 EnsureInitialized("v8::Debug::SetMessageHandler");
2902 i::Debugger::SetMessageHandler(handler, data); 2846 i::Debugger::SetMessageHandler(handler, data);
2903 } 2847 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3003 reinterpret_cast<HandleScopeImplementer*>(storage); 2947 reinterpret_cast<HandleScopeImplementer*>(storage);
3004 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 2948 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
3005 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 2949 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3006 &thread_local->handle_scope_data_; 2950 &thread_local->handle_scope_data_;
3007 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 2951 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
3008 2952
3009 return storage + ArchiveSpacePerThread(); 2953 return storage + ArchiveSpacePerThread();
3010 } 2954 }
3011 2955
3012 } } // namespace v8::internal 2956 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8-debug.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698