| 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 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 "bindings/v8/PageScriptDebugServer.h" | 32 #include "bindings/v8/PageScriptDebugServer.h" |
| 33 | 33 |
| 34 | 34 |
| 35 #include "V8DOMWindow.h" | 35 #include "V8Window.h" |
| 36 #include "bindings/v8/ScriptController.h" | 36 #include "bindings/v8/ScriptController.h" |
| 37 #include "bindings/v8/V8Binding.h" | 37 #include "bindings/v8/V8Binding.h" |
| 38 #include "bindings/v8/V8DOMWindowShell.h" | |
| 39 #include "bindings/v8/V8ScriptRunner.h" | 38 #include "bindings/v8/V8ScriptRunner.h" |
| 39 #include "bindings/v8/V8WindowShell.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" | 40 #include "core/inspector/InspectorInstrumentation.h" |
| 41 #include "core/inspector/ScriptDebugListener.h" | 41 #include "core/inspector/ScriptDebugListener.h" |
| 42 #include "core/page/Frame.h" | 42 #include "core/page/Frame.h" |
| 43 #include "core/page/Page.h" | 43 #include "core/page/Page.h" |
| 44 #include "wtf/OwnPtr.h" | 44 #include "wtf/OwnPtr.h" |
| 45 #include "wtf/PassOwnPtr.h" | 45 #include "wtf/PassOwnPtr.h" |
| 46 #include "wtf/StdLibExtras.h" | 46 #include "wtf/StdLibExtras.h" |
| 47 | 47 |
| 48 namespace WebCore { | 48 namespace WebCore { |
| 49 | 49 |
| 50 static Frame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context
) | 50 static Frame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context
) |
| 51 { | 51 { |
| 52 if (context.IsEmpty()) | 52 if (context.IsEmpty()) |
| 53 return 0; | 53 return 0; |
| 54 | 54 |
| 55 // Test that context has associated global dom window object. | 55 // Test that context has associated global dom window object. |
| 56 v8::Handle<v8::Object> global = context->Global(); | 56 v8::Handle<v8::Object> global = context->Global(); |
| 57 if (global.IsEmpty()) | 57 if (global.IsEmpty()) |
| 58 return 0; | 58 return 0; |
| 59 | 59 |
| 60 global = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(conte
xt->GetIsolate(), worldTypeInMainThread(context->GetIsolate()))); | 60 global = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context-
>GetIsolate(), worldTypeInMainThread(context->GetIsolate()))); |
| 61 if (global.IsEmpty()) | 61 if (global.IsEmpty()) |
| 62 return 0; | 62 return 0; |
| 63 | 63 |
| 64 return toFrameIfNotDetached(context); | 64 return toFrameIfNotDetached(context); |
| 65 } | 65 } |
| 66 | 66 |
| 67 PageScriptDebugServer& PageScriptDebugServer::shared() | 67 PageScriptDebugServer& PageScriptDebugServer::shared() |
| 68 { | 68 { |
| 69 DEFINE_STATIC_LOCAL(PageScriptDebugServer, server, ()); | 69 DEFINE_STATIC_LOCAL(PageScriptDebugServer, server, ()); |
| 70 return server; | 70 return server; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 86 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 86 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| 87 v8::Context::Scope contextScope(debuggerContext); | 87 v8::Context::Scope contextScope(debuggerContext); |
| 88 | 88 |
| 89 if (!m_listenersMap.size()) { | 89 if (!m_listenersMap.size()) { |
| 90 ensureDebuggerScriptCompiled(); | 90 ensureDebuggerScriptCompiled(); |
| 91 ASSERT(!m_debuggerScript.get()->IsUndefined()); | 91 ASSERT(!m_debuggerScript.get()->IsUndefined()); |
| 92 v8::Debug::SetDebugEventListener2(&PageScriptDebugServer::v8DebugEventCa
llback, v8::External::New(this)); | 92 v8::Debug::SetDebugEventListener2(&PageScriptDebugServer::v8DebugEventCa
llback, v8::External::New(this)); |
| 93 } | 93 } |
| 94 m_listenersMap.set(page, listener); | 94 m_listenersMap.set(page, listener); |
| 95 | 95 |
| 96 V8DOMWindowShell* shell = scriptController->existingWindowShell(mainThreadNo
rmalWorld()); | 96 V8WindowShell* shell = scriptController->existingWindowShell(mainThreadNorma
lWorld()); |
| 97 if (!shell || !shell->isContextInitialized()) | 97 if (!shell || !shell->isContextInitialized()) |
| 98 return; | 98 return; |
| 99 v8::Local<v8::Context> context = shell->context(); | 99 v8::Local<v8::Context> context = shell->context(); |
| 100 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(
m_debuggerScript.get()->Get(v8::String::NewSymbol("getScripts"))); | 100 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(
m_debuggerScript.get()->Get(v8::String::NewSymbol("getScripts"))); |
| 101 v8::Handle<v8::Value> argv[] = { context->GetEmbedderData(0) }; | 101 v8::Handle<v8::Value> argv[] = { context->GetEmbedderData(0) }; |
| 102 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScript
sFunction, m_debuggerScript.get(), WTF_ARRAY_LENGTH(argv), argv, m_isolate); | 102 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScript
sFunction, m_debuggerScript.get(), WTF_ARRAY_LENGTH(argv), argv, m_isolate); |
| 103 if (value.IsEmpty()) | 103 if (value.IsEmpty()) |
| 104 return; | 104 return; |
| 105 ASSERT(!value->IsUndefined() && value->IsArray()); | 105 ASSERT(!value->IsUndefined() && value->IsArray()); |
| 106 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value); | 106 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 m_pausedPage = 0; | 185 m_pausedPage = 0; |
| 186 } | 186 } |
| 187 | 187 |
| 188 void PageScriptDebugServer::quitMessageLoopOnPause() | 188 void PageScriptDebugServer::quitMessageLoopOnPause() |
| 189 { | 189 { |
| 190 m_clientMessageLoop->quitNow(); | 190 m_clientMessageLoop->quitNow(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace WebCore | 193 } // namespace WebCore |
| OLD | NEW |