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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/inspector/MainThreadDebugger.h" | 32 #include "core/inspector/MainThreadDebugger.h" |
33 | 33 |
34 #include "bindings/core/v8/DOMWrapperWorld.h" | 34 #include "bindings/core/v8/DOMWrapperWorld.h" |
35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 36 #include "core/inspector/DebuggerScript.h" |
36 #include "core/inspector/InspectorTaskRunner.h" | 37 #include "core/inspector/InspectorTaskRunner.h" |
| 38 #include "core/inspector/v8/V8Debugger.h" |
37 #include "platform/UserGestureIndicator.h" | 39 #include "platform/UserGestureIndicator.h" |
38 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
39 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
40 #include "wtf/ThreadingPrimitives.h" | 42 #include "wtf/ThreadingPrimitives.h" |
41 | 43 |
42 namespace blink { | 44 namespace blink { |
43 | 45 |
44 namespace { | 46 namespace { |
45 | 47 |
46 int frameId(LocalFrame* frame) | 48 int frameId(LocalFrame* frame) |
47 { | 49 { |
48 ASSERT(frame); | 50 ASSERT(frame); |
49 return WeakIdentifierMap<LocalFrame>::identifier(frame); | 51 return WeakIdentifierMap<LocalFrame>::identifier(frame); |
50 } | 52 } |
51 | 53 |
52 } | 54 } |
53 | 55 |
54 // TODO(Oilpan): avoid keeping a raw reference separate from the | 56 // TODO(Oilpan): avoid keeping a raw reference separate from the |
55 // owner one; does not enable heap-movable objects. | 57 // owner one; does not enable heap-movable objects. |
56 MainThreadDebugger* MainThreadDebugger::s_instance = nullptr; | 58 MainThreadDebugger* MainThreadDebugger::s_instance = nullptr; |
57 | 59 |
58 MainThreadDebugger::MainThreadDebugger(PassOwnPtr<ClientMessageLoop> clientMessa
geLoop, v8::Isolate* isolate) | 60 MainThreadDebugger::MainThreadDebugger(PassOwnPtr<ClientMessageLoop> clientMessa
geLoop, v8::Isolate* isolate) |
59 : ScriptDebuggerBase(isolate) | 61 : m_isolate(isolate) |
| 62 , m_debugger(V8Debugger::create(isolate, this)) |
60 , m_clientMessageLoop(clientMessageLoop) | 63 , m_clientMessageLoop(clientMessageLoop) |
61 , m_taskRunner(adoptPtr(new InspectorTaskRunner(isolate))) | 64 , m_taskRunner(adoptPtr(new InspectorTaskRunner(isolate))) |
62 { | 65 { |
63 MutexLocker locker(creationMutex()); | 66 MutexLocker locker(creationMutex()); |
64 ASSERT(!s_instance); | 67 ASSERT(!s_instance); |
65 s_instance = this; | 68 s_instance = this; |
66 } | 69 } |
67 | 70 |
68 MainThreadDebugger::~MainThreadDebugger() | 71 MainThreadDebugger::~MainThreadDebugger() |
69 { | 72 { |
(...skipping 26 matching lines...) Expand all Loading... |
96 return s_instance; | 99 return s_instance; |
97 } | 100 } |
98 | 101 |
99 void MainThreadDebugger::interruptMainThreadAndRun(PassOwnPtr<InspectorTaskRunne
r::Task> task) | 102 void MainThreadDebugger::interruptMainThreadAndRun(PassOwnPtr<InspectorTaskRunne
r::Task> task) |
100 { | 103 { |
101 MutexLocker locker(creationMutex()); | 104 MutexLocker locker(creationMutex()); |
102 if (s_instance) | 105 if (s_instance) |
103 s_instance->m_taskRunner->interruptAndRun(task); | 106 s_instance->m_taskRunner->interruptAndRun(task); |
104 } | 107 } |
105 | 108 |
| 109 v8::Local<v8::Object> MainThreadDebugger::compileDebuggerScript() |
| 110 { |
| 111 return blink::compileDebuggerScript(m_isolate); |
| 112 } |
| 113 |
106 void MainThreadDebugger::runMessageLoopOnPause(int contextGroupId) | 114 void MainThreadDebugger::runMessageLoopOnPause(int contextGroupId) |
107 { | 115 { |
108 LocalFrame* pausedFrame = WeakIdentifierMap<LocalFrame>::lookup(contextGroup
Id); | 116 LocalFrame* pausedFrame = WeakIdentifierMap<LocalFrame>::lookup(contextGroup
Id); |
109 // Do not pause in Context of detached frame. | 117 // Do not pause in Context of detached frame. |
110 if (!pausedFrame) | 118 if (!pausedFrame) |
111 return; | 119 return; |
112 ASSERT(pausedFrame == pausedFrame->localFrameRoot()); | 120 ASSERT(pausedFrame == pausedFrame->localFrameRoot()); |
113 | 121 |
114 if (UserGestureToken* token = UserGestureIndicator::currentToken()) | 122 if (UserGestureToken* token = UserGestureIndicator::currentToken()) |
115 token->setPauseInDebugger(); | 123 token->setPauseInDebugger(); |
116 // Wait for continue or step command. | 124 // Wait for continue or step command. |
117 m_clientMessageLoop->run(pausedFrame); | 125 m_clientMessageLoop->run(pausedFrame); |
118 } | 126 } |
119 | 127 |
120 void MainThreadDebugger::quitMessageLoopOnPause() | 128 void MainThreadDebugger::quitMessageLoopOnPause() |
121 { | 129 { |
122 m_clientMessageLoop->quitNow(); | 130 m_clientMessageLoop->quitNow(); |
123 } | 131 } |
124 | 132 |
125 } // namespace blink | 133 } // namespace blink |
OLD | NEW |