Chromium Code Reviews| 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 "bindings/core/v8/PageScriptDebugServer.h" | 32 #include "bindings/core/v8/PageScriptDebugServer.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/DOMWrapperWorld.h" | 34 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 35 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
| 36 #include "bindings/core/v8/ScriptPreprocessor.h" | |
| 36 #include "bindings/core/v8/ScriptSourceCode.h" | 37 #include "bindings/core/v8/ScriptSourceCode.h" |
| 37 #include "bindings/core/v8/V8Binding.h" | 38 #include "bindings/core/v8/V8Binding.h" |
| 38 #include "bindings/core/v8/V8ScriptRunner.h" | 39 #include "bindings/core/v8/V8ScriptRunner.h" |
| 39 #include "bindings/core/v8/V8Window.h" | 40 #include "bindings/core/v8/V8Window.h" |
| 40 #include "bindings/core/v8/WindowProxy.h" | 41 #include "bindings/core/v8/WindowProxy.h" |
| 41 #include "core/frame/FrameConsole.h" | 42 #include "core/frame/FrameConsole.h" |
| 42 #include "core/frame/FrameHost.h" | 43 #include "core/frame/FrameHost.h" |
| 43 #include "core/frame/LocalFrame.h" | 44 #include "core/frame/LocalFrame.h" |
| 44 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
| 45 #include "core/inspector/InspectorInstrumentation.h" | 46 #include "core/inspector/InspectorInstrumentation.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 70 v8::Handle<v8::Value> global = V8Window::findInstanceInPrototypeChain(contex t->Global(), context->GetIsolate()); | 71 v8::Handle<v8::Value> global = V8Window::findInstanceInPrototypeChain(contex t->Global(), context->GetIsolate()); |
| 71 if (global.IsEmpty()) | 72 if (global.IsEmpty()) |
| 72 return 0; | 73 return 0; |
| 73 | 74 |
| 74 return toFrameIfNotDetached(context); | 75 return toFrameIfNotDetached(context); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void PageScriptDebugServer::setPreprocessorSource(const String& preprocessorSour ce) | 78 void PageScriptDebugServer::setPreprocessorSource(const String& preprocessorSour ce) |
| 78 { | 79 { |
| 79 if (preprocessorSource.isEmpty()) | 80 if (preprocessorSource.isEmpty()) |
| 80 m_preprocessorSourceCode.clear(); | 81 m_preprocessorSourceCode = nullptr; |
| 81 else | 82 else |
| 82 m_preprocessorSourceCode = adoptPtr(new ScriptSourceCode(preprocessorSou rce)); | 83 m_preprocessorSourceCode = ScriptSourceCode(preprocessorSource); |
| 83 m_scriptPreprocessor.clear(); | 84 m_scriptPreprocessor.clear(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 PageScriptDebugServer& PageScriptDebugServer::shared() | 87 PageScriptDebugServer& PageScriptDebugServer::shared() |
| 87 { | 88 { |
| 88 DEFINE_STATIC_LOCAL(PageScriptDebugServer, server, ()); | 89 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<PageScriptDebugServer>, server, ( adoptPtrWillBeNoop(new PageScriptDebugServer()))); |
| 89 return server; | 90 return *server; |
| 90 } | 91 } |
| 91 | 92 |
| 92 v8::Isolate* PageScriptDebugServer::s_mainThreadIsolate = 0; | 93 v8::Isolate* PageScriptDebugServer::s_mainThreadIsolate = 0; |
| 93 | 94 |
| 94 void PageScriptDebugServer::setMainThreadIsolate(v8::Isolate* isolate) | 95 void PageScriptDebugServer::setMainThreadIsolate(v8::Isolate* isolate) |
| 95 { | 96 { |
| 96 s_mainThreadIsolate = isolate; | 97 s_mainThreadIsolate = isolate; |
| 97 } | 98 } |
| 98 | 99 |
| 99 PageScriptDebugServer::PageScriptDebugServer() | 100 PageScriptDebugServer::PageScriptDebugServer() |
| 100 : ScriptDebugServer(s_mainThreadIsolate) | 101 : ScriptDebugServer(s_mainThreadIsolate) |
| 101 , m_pausedPage(0) | 102 , m_pausedPage(nullptr) |
| 103 , m_preprocessorSourceCode() | |
| 102 { | 104 { |
| 103 } | 105 } |
| 104 | 106 |
| 105 PageScriptDebugServer::~PageScriptDebugServer() | 107 PageScriptDebugServer::~PageScriptDebugServer() |
| 106 { | 108 { |
| 107 } | 109 } |
| 108 | 110 |
| 111 void PageScriptDebugServer::trace(Visitor* visitor) | |
| 112 { | |
| 113 #if ENABLE(OILPAN) | |
| 114 visitor->trace(m_listenersMap); | |
| 115 visitor->trace(m_pausedPage); | |
| 116 visitor->trace(m_preprocessorSourceCode); | |
|
haraken
2015/01/22 08:45:11
Just want to confirm, but does visitor->trace(m_pr
sof
2015/01/22 09:16:45
I think it will statically resolve to the trace()
| |
| 117 #endif | |
| 118 ScriptDebugServer::trace(visitor); | |
| 119 } | |
| 120 | |
| 109 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag e) | 121 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag e) |
| 110 { | 122 { |
| 111 ScriptController& scriptController = page->deprecatedLocalMainFrame()->scrip t(); | 123 ScriptController& scriptController = page->deprecatedLocalMainFrame()->scrip t(); |
| 112 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript)) | 124 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript)) |
| 113 return; | 125 return; |
| 114 | 126 |
| 115 v8::HandleScope scope(m_isolate); | 127 v8::HandleScope scope(m_isolate); |
| 116 | 128 |
| 117 if (!m_listenersMap.size()) { | 129 if (!m_listenersMap.size()) { |
| 118 v8::Debug::SetDebugEventListener(&PageScriptDebugServer::v8DebugEventCal lback, v8::External::New(m_isolate, this)); | 130 v8::Debug::SetDebugEventListener(&PageScriptDebugServer::v8DebugEventCal lback, v8::External::New(m_isolate, this)); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 { | 282 { |
| 271 ASSERT(frame); | 283 ASSERT(frame); |
| 272 | 284 |
| 273 if (!m_preprocessorSourceCode || !frame->page() || isCreatingPreprocessor) | 285 if (!m_preprocessorSourceCode || !frame->page() || isCreatingPreprocessor) |
| 274 return false; | 286 return false; |
| 275 | 287 |
| 276 // We delay the creation of the preprocessor until just before the first JS from the | 288 // We delay the creation of the preprocessor until just before the first JS from the |
| 277 // Web page to ensure that the debugger's console initialization code has co mpleted. | 289 // Web page to ensure that the debugger's console initialization code has co mpleted. |
| 278 if (!m_scriptPreprocessor) { | 290 if (!m_scriptPreprocessor) { |
| 279 TemporaryChange<bool> isPreprocessing(isCreatingPreprocessor, true); | 291 TemporaryChange<bool> isPreprocessing(isCreatingPreprocessor, true); |
| 280 m_scriptPreprocessor = adoptPtr(new ScriptPreprocessor(m_isolate, *m_pre processorSourceCode.get(), frame)); | 292 m_scriptPreprocessor = adoptPtr(new ScriptPreprocessor(m_isolate, m_prep rocessorSourceCode.get(), frame)); |
| 281 } | 293 } |
| 282 | 294 |
| 283 if (m_scriptPreprocessor->isValid()) | 295 if (m_scriptPreprocessor->isValid()) |
| 284 return true; | 296 return true; |
| 285 | 297 |
| 286 m_scriptPreprocessor.clear(); | 298 m_scriptPreprocessor.clear(); |
| 287 // Don't retry the compile if we fail one time. | 299 // Don't retry the compile if we fail one time. |
| 288 m_preprocessorSourceCode.clear(); | 300 m_preprocessorSourceCode = nullptr; |
| 289 return false; | 301 return false; |
| 290 } | 302 } |
| 291 | 303 |
| 292 // Source to Source processing iff debugger enabled and it has loaded a preproce ssor. | 304 // Source to Source processing iff debugger enabled and it has loaded a preproce ssor. |
| 293 PassOwnPtr<ScriptSourceCode> PageScriptDebugServer::preprocess(LocalFrame* frame , const ScriptSourceCode& sourceCode) | 305 Nullable<ScriptSourceCode> PageScriptDebugServer::preprocess(LocalFrame* frame, const ScriptSourceCode& sourceCode) |
| 294 { | 306 { |
| 295 if (!canPreprocess(frame)) | 307 if (!canPreprocess(frame)) |
| 296 return PassOwnPtr<ScriptSourceCode>(); | 308 return nullptr; |
| 297 | 309 |
| 298 String preprocessedSource = m_scriptPreprocessor->preprocessSourceCode(sourc eCode.source(), sourceCode.url()); | 310 String preprocessedSource = m_scriptPreprocessor->preprocessSourceCode(sourc eCode.source(), sourceCode.url()); |
| 299 return adoptPtr(new ScriptSourceCode(preprocessedSource, sourceCode.url())); | 311 return ScriptSourceCode(preprocessedSource, sourceCode.url()); |
| 300 } | 312 } |
| 301 | 313 |
| 302 String PageScriptDebugServer::preprocessEventListener(LocalFrame* frame, const S tring& source, const String& url, const String& functionName) | 314 String PageScriptDebugServer::preprocessEventListener(LocalFrame* frame, const S tring& source, const String& url, const String& functionName) |
| 303 { | 315 { |
| 304 if (!canPreprocess(frame)) | 316 if (!canPreprocess(frame)) |
| 305 return source; | 317 return source; |
| 306 | 318 |
| 307 return m_scriptPreprocessor->preprocessSourceCode(source, url, functionName) ; | 319 return m_scriptPreprocessor->preprocessSourceCode(source, url, functionName) ; |
| 308 } | 320 } |
| 309 | 321 |
| 310 void PageScriptDebugServer::clearPreprocessor() | 322 void PageScriptDebugServer::clearPreprocessor() |
| 311 { | 323 { |
| 312 m_scriptPreprocessor.clear(); | 324 m_scriptPreprocessor.clear(); |
| 313 } | 325 } |
| 314 | 326 |
| 315 void PageScriptDebugServer::muteWarningsAndDeprecations() | 327 void PageScriptDebugServer::muteWarningsAndDeprecations() |
| 316 { | 328 { |
| 317 FrameConsole::mute(); | 329 FrameConsole::mute(); |
| 318 UseCounter::muteForInspector(); | 330 UseCounter::muteForInspector(); |
| 319 } | 331 } |
| 320 | 332 |
| 321 void PageScriptDebugServer::unmuteWarningsAndDeprecations() | 333 void PageScriptDebugServer::unmuteWarningsAndDeprecations() |
| 322 { | 334 { |
| 323 FrameConsole::unmute(); | 335 FrameConsole::unmute(); |
| 324 UseCounter::unmuteForInspector(); | 336 UseCounter::unmuteForInspector(); |
| 325 } | 337 } |
| 326 | 338 |
| 327 } // namespace blink | 339 } // namespace blink |
| OLD | NEW |