OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef ThreadDebugger_h | 5 #ifndef ThreadDebugger_h |
6 #define ThreadDebugger_h | 6 #define ThreadDebugger_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/inspector/ConsoleTypes.h" | 9 #include "core/inspector/ConsoleTypes.h" |
10 #include "platform/Timer.h" | 10 #include "platform/Timer.h" |
11 #include "platform/UserGestureIndicator.h" | 11 #include "platform/UserGestureIndicator.h" |
12 #include "platform/v8_inspector/public/V8Debugger.h" | 12 #include "platform/v8_inspector/public/V8Inspector.h" |
13 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 13 #include "platform/v8_inspector/public/V8InspectorClient.h" |
14 #include "wtf/Forward.h" | 14 #include "wtf/Forward.h" |
15 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
16 #include <memory> | 16 #include <memory> |
17 #include <v8.h> | 17 #include <v8.h> |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | 20 |
21 class ConsoleMessage; | 21 class ConsoleMessage; |
22 class ExecutionContext; | 22 class ExecutionContext; |
23 class SourceLocation; | 23 class SourceLocation; |
24 | 24 |
25 class CORE_EXPORT ThreadDebugger : public V8DebuggerClient { | 25 // TODO(dgozman): rename this to ThreadInspector (and subclasses). |
| 26 class CORE_EXPORT ThreadDebugger : public V8InspectorClient { |
26 WTF_MAKE_NONCOPYABLE(ThreadDebugger); | 27 WTF_MAKE_NONCOPYABLE(ThreadDebugger); |
27 public: | 28 public: |
28 explicit ThreadDebugger(v8::Isolate*); | 29 explicit ThreadDebugger(v8::Isolate*); |
29 ~ThreadDebugger() override; | 30 ~ThreadDebugger() override; |
30 static ThreadDebugger* from(v8::Isolate*); | 31 static ThreadDebugger* from(v8::Isolate*); |
31 | 32 |
32 static void willExecuteScript(v8::Isolate*, int scriptId); | 33 static void willExecuteScript(v8::Isolate*, int scriptId); |
33 static void didExecuteScript(v8::Isolate*); | 34 static void didExecuteScript(v8::Isolate*); |
34 static void idleStarted(v8::Isolate*); | 35 static void idleStarted(v8::Isolate*); |
35 static void idleFinished(v8::Isolate*); | 36 static void idleFinished(v8::Isolate*); |
36 | 37 |
37 void asyncTaskScheduled(const String& taskName, void* task, bool recurring); | 38 void asyncTaskScheduled(const String& taskName, void* task, bool recurring); |
38 void asyncTaskCanceled(void* task); | 39 void asyncTaskCanceled(void* task); |
39 void allAsyncTasksCanceled(); | 40 void allAsyncTasksCanceled(); |
40 void asyncTaskStarted(void* task); | 41 void asyncTaskStarted(void* task); |
41 void asyncTaskFinished(void* task); | 42 void asyncTaskFinished(void* task); |
42 unsigned promiseRejected(v8::Local<v8::Context>, const String16& errorMessag
e, v8::Local<v8::Value> exception, std::unique_ptr<SourceLocation>); | 43 unsigned promiseRejected(v8::Local<v8::Context>, const String16& errorMessag
e, v8::Local<v8::Value> exception, std::unique_ptr<SourceLocation>); |
43 void promiseRejectionRevoked(v8::Local<v8::Context>, unsigned promiseRejecti
onId); | 44 void promiseRejectionRevoked(v8::Local<v8::Context>, unsigned promiseRejecti
onId); |
44 | 45 |
45 // V8DebuggerClient implementation. | 46 // V8InspectorClient implementation. |
46 void beginUserGesture() override; | 47 void beginUserGesture() override; |
47 void endUserGesture() override; | 48 void endUserGesture() override; |
48 String16 valueSubtype(v8::Local<v8::Value>) override; | 49 String16 valueSubtype(v8::Local<v8::Value>) override; |
49 bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; | 50 bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; |
50 bool isExecutionAllowed() override; | 51 bool isExecutionAllowed() override; |
51 double currentTimeMS() override; | 52 double currentTimeMS() override; |
52 bool isInspectableHeapObject(v8::Local<v8::Object>) override; | 53 bool isInspectableHeapObject(v8::Local<v8::Object>) override; |
53 void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::O
bject>) override; | 54 void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::O
bject>) override; |
54 void consoleTime(const String16& title) override; | 55 void consoleTime(const String16& title) override; |
55 void consoleTimeEnd(const String16& title) override; | 56 void consoleTimeEnd(const String16& title) override; |
56 void consoleTimeStamp(const String16& title) override; | 57 void consoleTimeStamp(const String16& title) override; |
57 void startRepeatingTimer(double, V8DebuggerClient::TimerCallback, void* data
) override; | 58 void startRepeatingTimer(double, V8InspectorClient::TimerCallback, void* dat
a) override; |
58 void cancelTimer(void* data) override; | 59 void cancelTimer(void* data) override; |
59 | 60 |
60 V8Debugger* debugger() const { return m_debugger.get(); } | 61 V8Inspector* v8Inspector() const { return m_v8Inspector.get(); } |
61 virtual bool isWorker() { return true; } | 62 virtual bool isWorker() { return true; } |
62 virtual void reportConsoleMessage(ExecutionContext*, ConsoleMessage*) = 0; | 63 virtual void reportConsoleMessage(ExecutionContext*, ConsoleMessage*) = 0; |
63 virtual int contextGroupId(ExecutionContext*) = 0; | 64 virtual int contextGroupId(ExecutionContext*) = 0; |
64 | 65 |
65 protected: | 66 protected: |
66 void createFunctionProperty(v8::Local<v8::Context>, v8::Local<v8::Object>, c
onst char* name, v8::FunctionCallback, const char* description); | 67 void createFunctionProperty(v8::Local<v8::Context>, v8::Local<v8::Object>, c
onst char* name, v8::FunctionCallback, const char* description); |
67 void onTimer(TimerBase*); | 68 void onTimer(TimerBase*); |
68 static MessageLevel consoleAPITypeToMessageLevel(V8ConsoleAPIType); | 69 static MessageLevel consoleAPITypeToMessageLevel(V8ConsoleAPIType); |
69 | 70 |
70 v8::Isolate* m_isolate; | 71 v8::Isolate* m_isolate; |
71 std::unique_ptr<V8Debugger> m_debugger; | |
72 | 72 |
73 private: | 73 private: |
74 static void setMonitorEventsCallback(const v8::FunctionCallbackInfo<v8::Valu
e>&, bool enabled); | 74 static void setMonitorEventsCallback(const v8::FunctionCallbackInfo<v8::Valu
e>&, bool enabled); |
75 static void monitorEventsCallback(const v8::FunctionCallbackInfo<v8::Value>&
); | 75 static void monitorEventsCallback(const v8::FunctionCallbackInfo<v8::Value>&
); |
76 static void unmonitorEventsCallback(const v8::FunctionCallbackInfo<v8::Value
>&); | 76 static void unmonitorEventsCallback(const v8::FunctionCallbackInfo<v8::Value
>&); |
77 | 77 |
78 static void getEventListenersCallback(const v8::FunctionCallbackInfo<v8::Val
ue>&); | 78 static void getEventListenersCallback(const v8::FunctionCallbackInfo<v8::Val
ue>&); |
79 | 79 |
| 80 std::unique_ptr<V8Inspector> m_v8Inspector; |
80 Vector<std::unique_ptr<Timer<ThreadDebugger>>> m_timers; | 81 Vector<std::unique_ptr<Timer<ThreadDebugger>>> m_timers; |
81 Vector<V8DebuggerClient::TimerCallback> m_timerCallbacks; | 82 Vector<V8InspectorClient::TimerCallback> m_timerCallbacks; |
82 Vector<void*> m_timerData; | 83 Vector<void*> m_timerData; |
83 std::unique_ptr<UserGestureIndicator> m_userGestureIndicator; | 84 std::unique_ptr<UserGestureIndicator> m_userGestureIndicator; |
84 }; | 85 }; |
85 | 86 |
86 } // namespace blink | 87 } // namespace blink |
87 | 88 |
88 #endif // ThreadDebugger_h | 89 #endif // ThreadDebugger_h |
OLD | NEW |