| 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/v8_inspector/public/V8Debugger.h" | 11 #include "platform/v8_inspector/public/V8Debugger.h" |
| 11 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 12 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
| 12 #include "wtf/Forward.h" | 13 #include "wtf/Forward.h" |
| 13 #include "wtf/HashMap.h" | 14 #include "wtf/HashMap.h" |
| 14 | 15 |
| 15 #include <v8.h> | 16 #include <v8.h> |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 class ConsoleMessage; | 20 class ConsoleMessage; |
| 20 class WorkerThread; | 21 class WorkerThread; |
| 21 | 22 |
| 22 class CORE_EXPORT ThreadDebugger : public V8DebuggerClient { | 23 class CORE_EXPORT ThreadDebugger : public V8DebuggerClient { |
| 23 WTF_MAKE_NONCOPYABLE(ThreadDebugger); | 24 WTF_MAKE_NONCOPYABLE(ThreadDebugger); |
| 24 public: | 25 public: |
| 25 explicit ThreadDebugger(v8::Isolate*); | 26 explicit ThreadDebugger(v8::Isolate*); |
| 26 ~ThreadDebugger() override; | 27 ~ThreadDebugger() override; |
| 27 | 28 |
| 28 static void willExecuteScript(v8::Isolate*, int scriptId); | 29 static void willExecuteScript(v8::Isolate*, int scriptId); |
| 29 static void didExecuteScript(v8::Isolate*); | 30 static void didExecuteScript(v8::Isolate*); |
| 30 static void idleStarted(v8::Isolate*); | 31 static void idleStarted(v8::Isolate*); |
| 31 static void idleFinished(v8::Isolate*); | 32 static void idleFinished(v8::Isolate*); |
| 32 | 33 |
| 33 // V8DebuggerClient implementation. | 34 // V8DebuggerClient implementation. |
| 35 void beginUserGesture() override; |
| 36 void endUserGesture() override; |
| 34 void eventListeners(v8::Local<v8::Value>, V8EventListenerInfoList&) override
; | 37 void eventListeners(v8::Local<v8::Value>, V8EventListenerInfoList&) override
; |
| 35 String16 valueSubtype(v8::Local<v8::Value>) override; | 38 String16 valueSubtype(v8::Local<v8::Value>) override; |
| 36 bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; | 39 bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; |
| 37 bool isExecutionAllowed() override; | 40 bool isExecutionAllowed() override; |
| 38 double currentTimeMS() override; | 41 double currentTimeMS() override; |
| 39 bool isInspectableHeapObject(v8::Local<v8::Object>) override; | 42 bool isInspectableHeapObject(v8::Local<v8::Object>) override; |
| 40 void reportMessageToConsole(v8::Local<v8::Context>, MessageType, MessageLeve
l, const String16& message, const v8::FunctionCallbackInfo<v8::Value>* arguments
, unsigned skipArgumentCount, int maxStackSize) final; | 43 void reportMessageToConsole(v8::Local<v8::Context>, MessageType, MessageLeve
l, const String16& message, const v8::FunctionCallbackInfo<v8::Value>* arguments
, unsigned skipArgumentCount, int maxStackSize) final; |
| 41 void consoleTime(const String16& title) override; | 44 void consoleTime(const String16& title) override; |
| 42 void consoleTimeEnd(const String16& title) override; | 45 void consoleTimeEnd(const String16& title) override; |
| 43 void consoleTimeStamp(const String16& title) override; | 46 void consoleTimeStamp(const String16& title) override; |
| 44 int startRepeatingTimer(double, PassOwnPtr<V8DebuggerClient::TimerCallback>)
override; | 47 int startRepeatingTimer(double, PassOwnPtr<V8DebuggerClient::TimerCallback>)
override; |
| 45 void cancelTimer(int) override; | 48 void cancelTimer(int) override; |
| 46 | 49 |
| 47 V8Debugger* debugger() const { return m_debugger.get(); } | 50 V8Debugger* debugger() const { return m_debugger.get(); } |
| 48 virtual bool isWorker() { return true; } | 51 virtual bool isWorker() { return true; } |
| 49 protected: | 52 protected: |
| 50 virtual void reportMessageToConsole(v8::Local<v8::Context>, ConsoleMessage*)
= 0; | 53 virtual void reportMessageToConsole(v8::Local<v8::Context>, ConsoleMessage*)
= 0; |
| 51 void onTimer(Timer<ThreadDebugger>*); | 54 void onTimer(Timer<ThreadDebugger>*); |
| 52 | 55 |
| 53 v8::Isolate* m_isolate; | 56 v8::Isolate* m_isolate; |
| 54 OwnPtr<V8Debugger> m_debugger; | 57 OwnPtr<V8Debugger> m_debugger; |
| 55 HashMap<int, OwnPtr<Timer<ThreadDebugger>>> m_timers; | 58 HashMap<int, OwnPtr<Timer<ThreadDebugger>>> m_timers; |
| 56 HashMap<Timer<ThreadDebugger>*, OwnPtr<V8DebuggerClient::TimerCallback>> m_t
imerCallbacks; | 59 HashMap<Timer<ThreadDebugger>*, OwnPtr<V8DebuggerClient::TimerCallback>> m_t
imerCallbacks; |
| 57 int m_lastTimerId; | 60 int m_lastTimerId; |
| 61 OwnPtr<UserGestureIndicator> m_userGestureIndicator; |
| 58 }; | 62 }; |
| 59 | 63 |
| 60 } // namespace blink | 64 } // namespace blink |
| 61 | 65 |
| 62 #endif // ThreadDebugger_h | 66 #endif // ThreadDebugger_h |
| OLD | NEW |