OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/inspector/ScriptDebuggerBase.h" | 6 #include "core/inspector/ScriptDebuggerBase.h" |
7 | 7 |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "bindings/core/v8/V8ScriptRunner.h" | 9 #include "bindings/core/v8/V8ScriptRunner.h" |
| 10 #include "core/inspector/ScriptDebugListener.h" |
10 #include "public/platform/Platform.h" | 11 #include "public/platform/Platform.h" |
11 #include "public/platform/WebData.h" | 12 #include "public/platform/WebData.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 ScriptDebuggerBase::ScriptDebuggerBase(v8::Isolate* isolate, PassOwnPtrWillBeRaw
Ptr<V8Debugger> debugger) | 16 ScriptDebuggerBase::ScriptDebuggerBase(v8::Isolate* isolate) |
16 : m_isolate(isolate) | 17 : m_isolate(isolate) |
17 , m_debugger(debugger) | 18 , m_debugger(V8Debugger::create(isolate, this)) |
18 { | 19 { |
19 } | 20 } |
20 | 21 |
21 ScriptDebuggerBase::~ScriptDebuggerBase() | 22 ScriptDebuggerBase::~ScriptDebuggerBase() |
22 { | 23 { |
23 } | 24 } |
24 | 25 |
25 DEFINE_TRACE(ScriptDebuggerBase) | 26 DEFINE_TRACE(ScriptDebuggerBase) |
26 { | 27 { |
27 visitor->trace(m_debugger); | 28 visitor->trace(m_debugger); |
28 V8Debugger::Client::trace(visitor); | 29 V8Debugger::Client::trace(visitor); |
29 } | 30 } |
30 | 31 |
31 v8::Local<v8::Object> ScriptDebuggerBase::compileDebuggerScript() | 32 v8::Local<v8::Object> ScriptDebuggerBase::compileDebuggerScript() |
32 { | 33 { |
33 const WebData& debuggerScriptSourceResource = Platform::current()->loadResou
rce("DebuggerScriptSource.js"); | 34 const WebData& debuggerScriptSourceResource = Platform::current()->loadResou
rce("DebuggerScriptSource.js"); |
34 v8::Local<v8::String> source = v8String(m_isolate, String(debuggerScriptSour
ceResource.data(), debuggerScriptSourceResource.size())); | 35 v8::Local<v8::String> source = v8String(m_isolate, String(debuggerScriptSour
ceResource.data(), debuggerScriptSourceResource.size())); |
35 v8::Local<v8::Value> value; | 36 v8::Local<v8::Value> value; |
36 if (!V8ScriptRunner::compileAndRunInternalScript(source, m_isolate).ToLocal(
&value)) | 37 if (!V8ScriptRunner::compileAndRunInternalScript(source, m_isolate).ToLocal(
&value)) |
37 return v8::Local<v8::Object>(); | 38 return v8::Local<v8::Object>(); |
38 ASSERT(value->IsObject()); | 39 ASSERT(value->IsObject()); |
39 return value.As<v8::Object>(); | 40 return value.As<v8::Object>(); |
40 } | 41 } |
41 | 42 |
| 43 void ScriptDebuggerBase::didParseSource(v8::Local<v8::Context> context, const V8
Debugger::ParsedScript& parsedScript) |
| 44 { |
| 45 if (ScriptDebugListener* listener = getDebugListenerForContext(context)) |
| 46 listener->didParseSource(parsedScript); |
42 } | 47 } |
| 48 |
| 49 V8Debugger::SkipPauseRequest ScriptDebuggerBase::didPause(ScriptState* scriptSta
te, const ScriptValue& callFrames, const ScriptValue& exception, const Vector<St
ring>& hitBreakpoints, bool isPromiseRejection) |
| 50 { |
| 51 if (ScriptDebugListener* listener = getDebugListenerForContext(scriptState->
context())) |
| 52 return listener->didPause(scriptState, callFrames, exception, hitBreakpo
ints, isPromiseRejection); |
| 53 return V8Debugger::Continue; |
| 54 } |
| 55 |
| 56 bool ScriptDebuggerBase::v8AsyncTaskEventsEnabled(ScriptState* scriptState) |
| 57 { |
| 58 if (ScriptDebugListener* listener = getDebugListenerForContext(scriptState->
context())) |
| 59 return listener->v8AsyncTaskEventsEnabled(); |
| 60 return false; |
| 61 } |
| 62 |
| 63 void ScriptDebuggerBase::didReceiveV8AsyncTaskEvent(ScriptState* scriptState, co
nst String& eventType, const String& eventName, int id) |
| 64 { |
| 65 if (ScriptDebugListener* listener = getDebugListenerForContext(scriptState->
context())) |
| 66 listener->didReceiveV8AsyncTaskEvent(scriptState, eventType, eventName,
id); |
| 67 } |
| 68 |
| 69 bool ScriptDebuggerBase::v8PromiseEventsEnabled(ScriptState* scriptState) |
| 70 { |
| 71 if (ScriptDebugListener* listener = getDebugListenerForContext(scriptState->
context())) |
| 72 return listener->v8PromiseEventsEnabled(); |
| 73 return false; |
| 74 } |
| 75 |
| 76 void ScriptDebuggerBase::didReceiveV8PromiseEvent(ScriptState* scriptState, v8::
Local<v8::Object> promise, v8::Local<v8::Value> parentPromise, int status) |
| 77 { |
| 78 if (ScriptDebugListener* listener = getDebugListenerForContext(scriptState->
context())) |
| 79 listener->didReceiveV8PromiseEvent(scriptState, promise, parentPromise,
status); |
| 80 } |
| 81 |
| 82 } |
OLD | NEW |