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

Side by Side Diff: Source/bindings/core/v8/V8Debugger.cpp

Issue 1161323002: DevTools: implement JavaScriptCallFrame binding based on v8 API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Moved V8JavaScriptCallFrame to bindings/core/v8/inspector/ Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "bindings/core/v8/V8Debugger.h" 32 #include "bindings/core/v8/V8Debugger.h"
33 33
34 #include "bindings/core/v8/ScriptValue.h" 34 #include "bindings/core/v8/ScriptValue.h"
35 #include "bindings/core/v8/V8JavaScriptCallFrame.h" 35 #include "bindings/core/v8/V8Binding.h"
36 #include "bindings/core/v8/V8ScriptRunner.h" 36 #include "bindings/core/v8/V8ScriptRunner.h"
37 #include "bindings/core/v8/inspector/V8JavaScriptCallFrame.h"
37 #include "core/inspector/JavaScriptCallFrame.h" 38 #include "core/inspector/JavaScriptCallFrame.h"
38 #include "core/inspector/ScriptDebugListener.h" 39 #include "core/inspector/ScriptDebugListener.h"
39 #include "platform/JSONValues.h" 40 #include "platform/JSONValues.h"
40 #include "wtf/Deque.h" 41 #include "wtf/Deque.h"
41 #include "wtf/StdLibExtras.h" 42 #include "wtf/StdLibExtras.h"
42 #include "wtf/ThreadingPrimitives.h" 43 #include "wtf/ThreadingPrimitives.h"
43 #include "wtf/Vector.h" 44 #include "wtf/Vector.h"
44 #include "wtf/dtoa/utils.h" 45 #include "wtf/dtoa/utils.h"
45 #include "wtf/text/CString.h" 46 #include "wtf/text/CString.h"
46 47
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 DEFINE_TRACE(V8Debugger) 97 DEFINE_TRACE(V8Debugger)
97 { 98 {
98 } 99 }
99 100
100 void V8Debugger::enable() 101 void V8Debugger::enable()
101 { 102 {
102 ASSERT(!enabled()); 103 ASSERT(!enabled());
103 v8::HandleScope scope(m_isolate); 104 v8::HandleScope scope(m_isolate);
104 v8::Debug::SetDebugEventListener(&V8Debugger::v8DebugEventCallback, v8::Exte rnal::New(m_isolate, this)); 105 v8::Debug::SetDebugEventListener(&V8Debugger::v8DebugEventCallback, v8::Exte rnal::New(m_isolate, this));
105 m_debuggerContext.Reset(m_isolate, v8::Debug::GetDebugContext()); 106 m_debuggerContext.Reset(m_isolate, v8::Debug::GetDebugContext());
107 m_callFrameWrapperTemplate.Reset(m_isolate, V8JavaScriptCallFrame::createWra pperTemplate(m_isolate));
106 compileDebuggerScript(); 108 compileDebuggerScript();
107 } 109 }
108 110
109 void V8Debugger::disable() 111 void V8Debugger::disable()
110 { 112 {
111 ASSERT(enabled()); 113 ASSERT(enabled());
112 clearBreakpoints(); 114 clearBreakpoints();
113 m_debuggerScript.Reset(); 115 m_debuggerScript.Reset();
114 m_debuggerContext.Reset(); 116 m_debuggerContext.Reset();
117 m_callFrameWrapperTemplate.Reset();
115 v8::Debug::SetDebugEventListener(nullptr); 118 v8::Debug::SetDebugEventListener(nullptr);
116 } 119 }
117 120
118 bool V8Debugger::enabled() const 121 bool V8Debugger::enabled() const
119 { 122 {
120 return !m_debuggerScript.IsEmpty(); 123 return !m_debuggerScript.IsEmpty();
121 } 124 }
122 125
123 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin g& contextDebugData) 126 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin g& contextDebugData)
124 { 127 {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 404
402 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> V8Debugger::toJavaScriptCallFrameUns afe(const ScriptValue& value) 405 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> V8Debugger::toJavaScriptCallFrameUns afe(const ScriptValue& value)
403 { 406 {
404 if (value.isEmpty()) 407 if (value.isEmpty())
405 return nullptr; 408 return nullptr;
406 ScriptState* scriptState = value.scriptState(); 409 ScriptState* scriptState = value.scriptState();
407 if (!scriptState || !scriptState->contextIsValid()) 410 if (!scriptState || !scriptState->contextIsValid())
408 return nullptr; 411 return nullptr;
409 ScriptState::Scope scope(scriptState); 412 ScriptState::Scope scope(scriptState);
410 ASSERT(value.isObject()); 413 ASSERT(value.isObject());
411 return V8JavaScriptCallFrame::toImpl(v8::Local<v8::Object>::Cast(value.v8Val ueUnsafe())); 414 return V8JavaScriptCallFrame::unwrap(v8::Local<v8::Object>::Cast(value.v8Val ueUnsafe()));
412 } 415 }
413 416
414 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> V8Debugger::wrapCallFrames(int maxim umLimit, ScopeInfoDetails scopeDetails) 417 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> V8Debugger::wrapCallFrames(int maxim umLimit, ScopeInfoDetails scopeDetails)
415 { 418 {
416 const int scopeBits = 2; 419 const int scopeBits = 2;
417 static_assert(NoScopes < (1 << scopeBits), "there must be enough bits to enc ode ScopeInfoDetails"); 420 static_assert(NoScopes < (1 << scopeBits), "there must be enough bits to enc ode ScopeInfoDetails");
418 421
419 ASSERT(maximumLimit >= 0); 422 ASSERT(maximumLimit >= 0);
420 int data = (maximumLimit << scopeBits) | scopeDetails; 423 int data = (maximumLimit << scopeBits) | scopeDetails;
421 v8::Local<v8::Value> currentCallFrameV8; 424 v8::Local<v8::Value> currentCallFrameV8;
(...skipping 18 matching lines...) Expand all
440 443
441 // Filter out stack traces entirely consisting of V8's internal scripts. 444 // Filter out stack traces entirely consisting of V8's internal scripts.
442 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(m_i solate, 1); 445 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(m_i solate, 1);
443 if (!stackTrace->GetFrameCount()) 446 if (!stackTrace->GetFrameCount())
444 return ScriptValue(); 447 return ScriptValue();
445 448
446 RefPtrWillBeRawPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(0, scopeDetails); 449 RefPtrWillBeRawPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(0, scopeDetails);
447 if (!currentCallFrame) 450 if (!currentCallFrame)
448 return ScriptValue(); 451 return ScriptValue();
449 452
453 v8::Local<v8::FunctionTemplate> wrapperTemplate = v8::Local<v8::FunctionTemp late>::New(m_isolate, m_callFrameWrapperTemplate);
450 ScriptState* scriptState = m_pausedScriptState ? m_pausedScriptState.get() : ScriptState::current(m_isolate); 454 ScriptState* scriptState = m_pausedScriptState ? m_pausedScriptState.get() : ScriptState::current(m_isolate);
451 ScriptState::Scope scope(scriptState); 455 ScriptState::Scope scope(scriptState);
452 return ScriptValue(scriptState, toV8(currentCallFrame.release(), scriptState ->context()->Global(), m_isolate)); 456 v8::Local<v8::Object> wrapper = V8JavaScriptCallFrame::wrap(wrapperTemplate, scriptState->context(), currentCallFrame.release());
457 return ScriptValue(scriptState, wrapper);
453 } 458 }
454 459
455 ScriptValue V8Debugger::currentCallFrames() 460 ScriptValue V8Debugger::currentCallFrames()
456 { 461 {
457 return currentCallFramesInner(AllScopes); 462 return currentCallFramesInner(AllScopes);
458 } 463 }
459 464
460 ScriptValue V8Debugger::currentCallFramesForAsyncStack() 465 ScriptValue V8Debugger::currentCallFramesForAsyncStack()
461 { 466 {
462 return currentCallFramesInner(FastAsyncScopes); 467 return currentCallFramesInner(FastAsyncScopes);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 return callDebuggerMethod("setFunctionVariableValue", 4, argv); 752 return callDebuggerMethod("setFunctionVariableValue", 4, argv);
748 } 753 }
749 754
750 755
751 bool V8Debugger::isPaused() 756 bool V8Debugger::isPaused()
752 { 757 {
753 return m_pausedScriptState; 758 return m_pausedScriptState;
754 } 759 }
755 760
756 } // namespace blink 761 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Debugger.h ('k') | Source/bindings/core/v8/custom/V8JavaScriptCallFrameCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698