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 23 matching lines...) Expand all Loading... |
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 <memory> |
40 #include <v8.h> | 40 #include <v8.h> |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
| 44 class ConsoleMessage; |
44 class LocalFrame; | 45 class LocalFrame; |
45 class SecurityOrigin; | 46 class SecurityOrigin; |
46 class SourceLocation; | 47 class SourceLocation; |
47 | 48 |
48 class CORE_EXPORT MainThreadDebugger final : public ThreadDebugger { | 49 class CORE_EXPORT MainThreadDebugger final : public ThreadDebugger { |
49 WTF_MAKE_NONCOPYABLE(MainThreadDebugger); | 50 WTF_MAKE_NONCOPYABLE(MainThreadDebugger); |
50 public: | 51 public: |
51 class ClientMessageLoop { | 52 class ClientMessageLoop { |
52 USING_FAST_MALLOC(ClientMessageLoop); | 53 USING_FAST_MALLOC(ClientMessageLoop); |
53 public: | 54 public: |
54 virtual ~ClientMessageLoop() { } | 55 virtual ~ClientMessageLoop() { } |
55 virtual void run(LocalFrame*) = 0; | 56 virtual void run(LocalFrame*) = 0; |
56 virtual void quitNow() = 0; | 57 virtual void quitNow() = 0; |
57 }; | 58 }; |
58 | 59 |
59 explicit MainThreadDebugger(v8::Isolate*); | 60 explicit MainThreadDebugger(v8::Isolate*); |
60 ~MainThreadDebugger() override; | 61 ~MainThreadDebugger() override; |
61 | 62 |
62 static MainThreadDebugger* instance(); | 63 static MainThreadDebugger* instance(); |
63 static void interruptMainThreadAndRun(std::unique_ptr<InspectorTaskRunner::T
ask>); | 64 static void interruptMainThreadAndRun(std::unique_ptr<InspectorTaskRunner::T
ask>); |
64 | 65 |
65 InspectorTaskRunner* taskRunner() const { return m_taskRunner.get(); } | 66 InspectorTaskRunner* taskRunner() const { return m_taskRunner.get(); } |
66 bool isWorker() override { return false; } | 67 bool isWorker() override { return false; } |
| 68 bool isPaused() const { return m_paused; } |
67 void setClientMessageLoop(std::unique_ptr<ClientMessageLoop>); | 69 void setClientMessageLoop(std::unique_ptr<ClientMessageLoop>); |
68 // TODO(dgozman): by making this method virtual, we can move many methods to
ThreadDebugger and avoid some duplication. Should be careful about performance. | 70 // TODO(dgozman): by making this method virtual, we can move many methods to
ThreadDebugger and avoid some duplication. Should be careful about performance. |
69 int contextGroupId(LocalFrame*); | 71 int contextGroupId(LocalFrame*); |
70 void didClearContextsForFrame(LocalFrame*); | 72 void didClearContextsForFrame(LocalFrame*); |
71 void contextCreated(ScriptState*, LocalFrame*, SecurityOrigin*); | 73 void contextCreated(ScriptState*, LocalFrame*, SecurityOrigin*); |
72 void contextWillBeDestroyed(ScriptState*); | 74 void contextWillBeDestroyed(ScriptState*); |
73 void exceptionThrown(LocalFrame*, const String& errorMessage, std::unique_pt
r<SourceLocation>); | 75 void exceptionThrown(LocalFrame*, const String& errorMessage, std::unique_pt
r<SourceLocation>); |
| 76 bool addConsoleMessage(LocalFrame*, ConsoleMessage*); |
74 | 77 |
75 void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::O
bject>) override; | 78 void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::O
bject>) override; |
76 | 79 |
77 v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) o
verride; | 80 v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) o
verride; |
78 void messageAddedToConsole(int contextGroupId, MessageSource, MessageLevel,
const String16& message, const String16& url, unsigned lineNumber, unsigned colu
mnNumber, V8StackTrace*) override; | 81 void messageAddedToConsole(int contextGroupId, MessageSource, MessageLevel,
const String16& message, const String16& url, unsigned lineNumber, unsigned colu
mnNumber, V8StackTrace*) override; |
79 | 82 |
80 private: | 83 private: |
81 // V8DebuggerClient implementation. | 84 // V8DebuggerClient implementation. |
82 void runMessageLoopOnPause(int contextGroupId) override; | 85 void runMessageLoopOnPause(int contextGroupId) override; |
83 void quitMessageLoopOnPause() override; | 86 void quitMessageLoopOnPause() override; |
84 void muteWarningsAndDeprecations() override; | 87 void muteWarningsAndDeprecations() override; |
85 void unmuteWarningsAndDeprecations() override; | 88 void unmuteWarningsAndDeprecations() override; |
86 bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Loca
l<v8::Context> target) override; | 89 bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Loca
l<v8::Context> target) override; |
87 v8::Local<v8::Context> ensureDefaultContextInGroup(int contextGroupId) overr
ide; | 90 v8::Local<v8::Context> ensureDefaultContextInGroup(int contextGroupId) overr
ide; |
88 | 91 |
89 std::unique_ptr<ClientMessageLoop> m_clientMessageLoop; | 92 std::unique_ptr<ClientMessageLoop> m_clientMessageLoop; |
90 std::unique_ptr<InspectorTaskRunner> m_taskRunner; | 93 std::unique_ptr<InspectorTaskRunner> m_taskRunner; |
| 94 bool m_paused; |
| 95 int m_muteConsoleCount; |
91 | 96 |
92 static MainThreadDebugger* s_instance; | 97 static MainThreadDebugger* s_instance; |
93 | 98 |
94 static void querySelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); | 99 static void querySelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); |
95 static void querySelectorAllCallback(const v8::FunctionCallbackInfo<v8::Valu
e>&); | 100 static void querySelectorAllCallback(const v8::FunctionCallbackInfo<v8::Valu
e>&); |
96 static void xpathSelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); | 101 static void xpathSelectorCallback(const v8::FunctionCallbackInfo<v8::Value>&
); |
97 }; | 102 }; |
98 | 103 |
99 } // namespace blink | 104 } // namespace blink |
100 | 105 |
101 | 106 |
102 #endif // MainThreadDebugger_h | 107 #endif // MainThreadDebugger_h |
OLD | NEW |