| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 Google Inc. All rights reserved. | 2 * Copyright (c) 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef MainThreadDebugger_h | 31 #ifndef MainThreadDebugger_h |
| 32 #define MainThreadDebugger_h | 32 #define MainThreadDebugger_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScriptState.h" | 34 #include "bindings/core/v8/ScriptState.h" |
| 35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
| 36 #include "core/inspector/InspectorTaskRunner.h" | 36 #include "core/inspector/InspectorTaskRunner.h" |
| 37 #include "core/inspector/ThreadDebugger.h" | 37 #include "core/inspector/ThreadDebugger.h" |
| 38 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
| 39 #include <memory> |
| 39 #include <v8.h> | 40 #include <v8.h> |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 class LocalFrame; | 44 class LocalFrame; |
| 44 class V8Debugger; | 45 class V8Debugger; |
| 45 class SecurityOrigin; | 46 class SecurityOrigin; |
| 46 | 47 |
| 47 class CORE_EXPORT MainThreadDebugger final : public ThreadDebugger { | 48 class CORE_EXPORT MainThreadDebugger final : public ThreadDebugger { |
| 48 WTF_MAKE_NONCOPYABLE(MainThreadDebugger); | 49 WTF_MAKE_NONCOPYABLE(MainThreadDebugger); |
| 49 public: | 50 public: |
| 50 class ClientMessageLoop { | 51 class ClientMessageLoop { |
| 51 USING_FAST_MALLOC(ClientMessageLoop); | 52 USING_FAST_MALLOC(ClientMessageLoop); |
| 52 public: | 53 public: |
| 53 virtual ~ClientMessageLoop() { } | 54 virtual ~ClientMessageLoop() { } |
| 54 virtual void run(LocalFrame*) = 0; | 55 virtual void run(LocalFrame*) = 0; |
| 55 virtual void quitNow() = 0; | 56 virtual void quitNow() = 0; |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 explicit MainThreadDebugger(v8::Isolate*); | 59 explicit MainThreadDebugger(v8::Isolate*); |
| 59 ~MainThreadDebugger() override; | 60 ~MainThreadDebugger() override; |
| 60 | 61 |
| 61 static MainThreadDebugger* instance(); | 62 static MainThreadDebugger* instance(); |
| 62 static void interruptMainThreadAndRun(std::unique_ptr<InspectorTaskRunner::T
ask>); | 63 static void interruptMainThreadAndRun(std::unique_ptr<InspectorTaskRunner::T
ask>); |
| 63 | 64 |
| 64 InspectorTaskRunner* taskRunner() const { return m_taskRunner.get(); } | 65 InspectorTaskRunner* taskRunner() const { return m_taskRunner.get(); } |
| 65 bool isWorker() override { return false; } | 66 bool isWorker() override { return false; } |
| 66 void setClientMessageLoop(PassOwnPtr<ClientMessageLoop>); | 67 void setClientMessageLoop(std::unique_ptr<ClientMessageLoop>); |
| 67 int contextGroupId(LocalFrame*); | 68 int contextGroupId(LocalFrame*); |
| 68 void contextCreated(ScriptState*, LocalFrame*, SecurityOrigin*); | 69 void contextCreated(ScriptState*, LocalFrame*, SecurityOrigin*); |
| 69 void contextWillBeDestroyed(ScriptState*); | 70 void contextWillBeDestroyed(ScriptState*); |
| 70 | 71 |
| 71 static bool isCommandLineAPIMethod(const String& name); | 72 static bool isCommandLineAPIMethod(const String& name); |
| 72 void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::O
bject>) override; | 73 void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::O
bject>) override; |
| 73 | 74 |
| 74 v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) o
verride; | 75 v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) o
verride; |
| 75 protected: | 76 protected: |
| 76 void reportMessageToConsole(v8::Local<v8::Context>, ConsoleMessage*) overrid
e; | 77 void reportMessageToConsole(v8::Local<v8::Context>, ConsoleMessage*) overrid
e; |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 // V8DebuggerClient implementation. | 80 // V8DebuggerClient implementation. |
| 80 void runMessageLoopOnPause(int contextGroupId) override; | 81 void runMessageLoopOnPause(int contextGroupId) override; |
| 81 void quitMessageLoopOnPause() override; | 82 void quitMessageLoopOnPause() override; |
| 82 void muteWarningsAndDeprecations() override; | 83 void muteWarningsAndDeprecations() override; |
| 83 void unmuteWarningsAndDeprecations() override; | 84 void unmuteWarningsAndDeprecations() override; |
| 84 void muteConsole() override; | 85 void muteConsole() override; |
| 85 void unmuteConsole() override; | 86 void unmuteConsole() override; |
| 86 bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Loca
l<v8::Context> target) override; | 87 bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Loca
l<v8::Context> target) override; |
| 87 int ensureDefaultContextInGroup(int contextGroupId) override; | 88 int ensureDefaultContextInGroup(int contextGroupId) override; |
| 88 | 89 |
| 89 OwnPtr<ClientMessageLoop> m_clientMessageLoop; | 90 std::unique_ptr<ClientMessageLoop> m_clientMessageLoop; |
| 90 OwnPtr<InspectorTaskRunner> m_taskRunner; | 91 std::unique_ptr<InspectorTaskRunner> m_taskRunner; |
| 91 | 92 |
| 92 static MainThreadDebugger* s_instance; | 93 static MainThreadDebugger* s_instance; |
| 93 | 94 |
| 94 static void querySelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); | 95 static void querySelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); |
| 95 static void querySelectorAllCallback(const v8::FunctionCallbackInfo<v8::Valu
e>&); | 96 static void querySelectorAllCallback(const v8::FunctionCallbackInfo<v8::Valu
e>&); |
| 96 static void xpathSelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); | 97 static void xpathSelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 } // namespace blink | 100 } // namespace blink |
| 100 | 101 |
| 101 | 102 |
| 102 #endif // MainThreadDebugger_h | 103 #endif // MainThreadDebugger_h |
| OLD | NEW |