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