| 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 25 matching lines...) Expand all Loading... |
| 36 #include "bindings/core/v8/ScriptSourceCode.h" | 36 #include "bindings/core/v8/ScriptSourceCode.h" |
| 37 #include "bindings/core/v8/V8Binding.h" | 37 #include "bindings/core/v8/V8Binding.h" |
| 38 #include "bindings/core/v8/V8ScriptRunner.h" | 38 #include "bindings/core/v8/V8ScriptRunner.h" |
| 39 #include "bindings/core/v8/WindowProxy.h" | 39 #include "bindings/core/v8/WindowProxy.h" |
| 40 #include "core/frame/FrameConsole.h" | 40 #include "core/frame/FrameConsole.h" |
| 41 #include "core/frame/FrameHost.h" | 41 #include "core/frame/FrameHost.h" |
| 42 #include "core/frame/LocalFrame.h" | 42 #include "core/frame/LocalFrame.h" |
| 43 #include "core/frame/UseCounter.h" | 43 #include "core/frame/UseCounter.h" |
| 44 #include "core/inspector/InspectorInstrumentation.h" | 44 #include "core/inspector/InspectorInstrumentation.h" |
| 45 #include "core/inspector/InspectorTraceEvents.h" | 45 #include "core/inspector/InspectorTraceEvents.h" |
| 46 #include "core/inspector/PerIsolateDebuggerClient.h" | |
| 47 #include "core/inspector/ScriptDebugListener.h" | 46 #include "core/inspector/ScriptDebugListener.h" |
| 48 #include "core/page/Page.h" | 47 #include "core/page/Page.h" |
| 49 #include "wtf/OwnPtr.h" | 48 #include "wtf/OwnPtr.h" |
| 50 #include "wtf/PassOwnPtr.h" | 49 #include "wtf/PassOwnPtr.h" |
| 51 #include "wtf/StdLibExtras.h" | 50 #include "wtf/StdLibExtras.h" |
| 52 #include "wtf/TemporaryChange.h" | 51 #include "wtf/TemporaryChange.h" |
| 53 #include "wtf/ThreadingPrimitives.h" | 52 #include "wtf/ThreadingPrimitives.h" |
| 54 #include "wtf/text/StringBuilder.h" | 53 #include "wtf/text/StringBuilder.h" |
| 55 | 54 |
| 56 namespace blink { | 55 namespace blink { |
| 57 | 56 |
| 58 static LocalFrame* retrieveFrameWithGlobalObjectCheck(v8::Local<v8::Context> con
text) | 57 static LocalFrame* retrieveFrameWithGlobalObjectCheck(v8::Local<v8::Context> con
text) |
| 59 { | 58 { |
| 60 return toLocalFrame(toFrameIfNotDetached(context)); | 59 return toLocalFrame(toFrameIfNotDetached(context)); |
| 61 } | 60 } |
| 62 | 61 |
| 63 PageScriptDebugServer* PageScriptDebugServer::s_instance = nullptr; | 62 PageScriptDebugServer* PageScriptDebugServer::s_instance = nullptr; |
| 64 | 63 |
| 65 PageScriptDebugServer::PageScriptDebugServer(PassOwnPtr<ClientMessageLoop> clien
tMessageLoop, v8::Isolate* isolate) | 64 PageScriptDebugServer::PageScriptDebugServer(PassOwnPtr<ClientMessageLoop> clien
tMessageLoop, v8::Isolate* isolate) |
| 66 : ScriptDebugServer(isolate, adoptPtr(new PerIsolateDebuggerClient(isolate))
) | 65 : PerIsolateDebuggerClient(isolate, adoptPtr(new ScriptDebugServer(isolate,
this))) |
| 67 , m_clientMessageLoop(clientMessageLoop) | 66 , m_clientMessageLoop(clientMessageLoop) |
| 68 , m_pausedFrame(nullptr) | 67 , m_pausedFrame(nullptr) |
| 69 { | 68 { |
| 70 MutexLocker locker(creationMutex()); | 69 MutexLocker locker(creationMutex()); |
| 71 ASSERT(!s_instance); | 70 ASSERT(!s_instance); |
| 72 s_instance = this; | 71 s_instance = this; |
| 73 } | 72 } |
| 74 | 73 |
| 75 PageScriptDebugServer::~PageScriptDebugServer() | 74 PageScriptDebugServer::~PageScriptDebugServer() |
| 76 { | 75 { |
| 77 MutexLocker locker(creationMutex()); | 76 MutexLocker locker(creationMutex()); |
| 78 ASSERT(s_instance == this); | 77 ASSERT(s_instance == this); |
| 79 s_instance = nullptr; | 78 s_instance = nullptr; |
| 80 } | 79 } |
| 81 | 80 |
| 82 Mutex& PageScriptDebugServer::creationMutex() | 81 Mutex& PageScriptDebugServer::creationMutex() |
| 83 { | 82 { |
| 84 AtomicallyInitializedStaticReference(Mutex, mutex, (new Mutex)); | 83 AtomicallyInitializedStaticReference(Mutex, mutex, (new Mutex)); |
| 85 return mutex; | 84 return mutex; |
| 86 } | 85 } |
| 87 | 86 |
| 88 DEFINE_TRACE(PageScriptDebugServer) | |
| 89 { | |
| 90 #if ENABLE(OILPAN) | |
| 91 visitor->trace(m_listenersMap); | |
| 92 visitor->trace(m_pausedFrame); | |
| 93 #endif | |
| 94 ScriptDebugServer::trace(visitor); | |
| 95 } | |
| 96 | |
| 97 void PageScriptDebugServer::setContextDebugData(v8::Local<v8::Context> context,
const String& type, int contextDebugId) | 87 void PageScriptDebugServer::setContextDebugData(v8::Local<v8::Context> context,
const String& type, int contextDebugId) |
| 98 { | 88 { |
| 99 String debugData = "[" + type + "," + String::number(contextDebugId) + "]"; | 89 String debugData = "[" + type + "," + String::number(contextDebugId) + "]"; |
| 100 ScriptDebugServer::setContextDebugData(context, debugData); | 90 ScriptDebugServer::setContextDebugData(context, debugData); |
| 101 } | 91 } |
| 102 | 92 |
| 103 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, LocalFram
e* localFrameRoot, int contextDebugId) | 93 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, LocalFram
e* localFrameRoot, int contextDebugId) |
| 104 { | 94 { |
| 105 ASSERT(localFrameRoot == localFrameRoot->localFrameRoot()); | 95 ASSERT(localFrameRoot == localFrameRoot->localFrameRoot()); |
| 106 | 96 |
| 107 ScriptController& scriptController = localFrameRoot->script(); | 97 ScriptController& scriptController = localFrameRoot->script(); |
| 108 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript)) | 98 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript)) |
| 109 return; | 99 return; |
| 110 | 100 |
| 111 if (m_listenersMap.isEmpty()) | 101 if (m_listenersMap.isEmpty()) |
| 112 enable(); | 102 scriptDebugServer()->enable(); |
| 113 m_listenersMap.set(localFrameRoot, listener); | 103 m_listenersMap.set(localFrameRoot, listener); |
| 114 String contextDataSubstring = "," + String::number(contextDebugId) + "]"; | 104 String contextDataSubstring = "," + String::number(contextDebugId) + "]"; |
| 115 reportCompiledScripts(contextDataSubstring, listener); | 105 scriptDebugServer()->reportCompiledScripts(contextDataSubstring, listener); |
| 116 } | 106 } |
| 117 | 107 |
| 118 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, LocalF
rame* localFrame) | 108 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, LocalF
rame* localFrame) |
| 119 { | 109 { |
| 120 if (!m_listenersMap.contains(localFrame)) | 110 if (!m_listenersMap.contains(localFrame)) |
| 121 return; | 111 return; |
| 122 | 112 |
| 123 if (m_pausedFrame == localFrame) | 113 if (m_pausedFrame == localFrame) |
| 124 continueProgram(); | 114 scriptDebugServer()->continueProgram(); |
| 125 | 115 |
| 126 m_listenersMap.remove(localFrame); | 116 m_listenersMap.remove(localFrame); |
| 127 | 117 |
| 128 if (m_listenersMap.isEmpty()) | 118 if (m_listenersMap.isEmpty()) |
| 129 disable(); | 119 scriptDebugServer()->disable(); |
| 130 } | 120 } |
| 131 | 121 |
| 132 PageScriptDebugServer* PageScriptDebugServer::instance() | 122 PageScriptDebugServer* PageScriptDebugServer::instance() |
| 133 { | 123 { |
| 134 ASSERT(isMainThread()); | 124 ASSERT(isMainThread()); |
| 135 return s_instance; | 125 return s_instance; |
| 136 } | 126 } |
| 137 | 127 |
| 138 void PageScriptDebugServer::interruptMainThreadAndRun(PassOwnPtr<Task> task) | 128 void PageScriptDebugServer::interruptMainThreadAndRun(PassOwnPtr<ScriptDebugServ
er::Task> task) |
| 139 { | 129 { |
| 140 MutexLocker locker(creationMutex()); | 130 MutexLocker locker(creationMutex()); |
| 141 if (s_instance) | 131 if (s_instance) |
| 142 s_instance->interruptAndRun(task); | 132 s_instance->scriptDebugServer()->interruptAndRun(task); |
| 143 } | 133 } |
| 144 | 134 |
| 145 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Local
<v8::Context> context) | 135 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Local
<v8::Context> context) |
| 146 { | 136 { |
| 147 v8::HandleScope scope(context->GetIsolate()); | 137 v8::HandleScope scope(context->GetIsolate()); |
| 148 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); | 138 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); |
| 149 if (!frame) | 139 if (!frame) |
| 150 return 0; | 140 return 0; |
| 151 return m_listenersMap.get(frame->localFrameRoot()); | 141 return m_listenersMap.get(frame->localFrameRoot()); |
| 152 } | 142 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 166 | 156 |
| 167 m_pausedFrame = 0; | 157 m_pausedFrame = 0; |
| 168 } | 158 } |
| 169 | 159 |
| 170 void PageScriptDebugServer::quitMessageLoopOnPause() | 160 void PageScriptDebugServer::quitMessageLoopOnPause() |
| 171 { | 161 { |
| 172 m_clientMessageLoop->quitNow(); | 162 m_clientMessageLoop->quitNow(); |
| 173 } | 163 } |
| 174 | 164 |
| 175 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |