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