| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #ifndef PageScriptDebugServer_h | |
| 32 #define PageScriptDebugServer_h | |
| 33 | |
| 34 #include "sky/engine/bindings/core/v8/ScriptDebugServer.h" | |
| 35 #include "sky/engine/bindings/core/v8/ScriptPreprocessor.h" | |
| 36 #include "sky/engine/wtf/Forward.h" | |
| 37 #include "sky/engine/wtf/RefCounted.h" | |
| 38 #include "v8/include/v8.h" | |
| 39 | |
| 40 // This whole file will move to namespace inspector. | |
| 41 namespace inspector { | |
| 42 class InspectorHost; | |
| 43 } | |
| 44 | |
| 45 namespace blink { | |
| 46 | |
| 47 class ScriptController; | |
| 48 class ScriptPreprocessor; | |
| 49 class ScriptSourceCode; | |
| 50 | |
| 51 class PageScriptDebugServer final : public ScriptDebugServer { | |
| 52 WTF_MAKE_NONCOPYABLE(PageScriptDebugServer); | |
| 53 public: | |
| 54 static PageScriptDebugServer& shared(); | |
| 55 | |
| 56 static void setMainThreadIsolate(v8::Isolate*); | |
| 57 | |
| 58 void addListener(ScriptDebugListener*, inspector::InspectorHost*); | |
| 59 void removeListener(ScriptDebugListener*, inspector::InspectorHost*); | |
| 60 | |
| 61 static void interruptAndRun(PassOwnPtr<Task>); | |
| 62 | |
| 63 class ClientMessageLoop { | |
| 64 public: | |
| 65 virtual ~ClientMessageLoop() { } | |
| 66 virtual void run(inspector::InspectorHost*) = 0; | |
| 67 virtual void quitNow() = 0; | |
| 68 }; | |
| 69 void setClientMessageLoop(PassOwnPtr<ClientMessageLoop>); | |
| 70 | |
| 71 virtual void compileScript(ScriptState*, const String& expression, const Str
ing& sourceURL, String* scriptId, String* exceptionDetailsText, int* lineNumber,
int* columnNumber, RefPtr<ScriptCallStack>* stackTrace) override; | |
| 72 virtual void clearCompiledScripts() override; | |
| 73 virtual void runScript(ScriptState*, const String& scriptId, ScriptValue* re
sult, bool* wasThrown, String* exceptionDetailsText, int* lineNumber, int* colum
nNumber, RefPtr<ScriptCallStack>* stackTrace) override; | |
| 74 virtual void setPreprocessorSource(const String&) override; | |
| 75 virtual void preprocessBeforeCompile(const v8::Debug::EventDetails&) overrid
e; | |
| 76 virtual PassOwnPtr<ScriptSourceCode> preprocess(LocalFrame*, const ScriptSou
rceCode&) override; | |
| 77 virtual String preprocessEventListener(LocalFrame*, const String& source, co
nst String& url, const String& functionName) override; | |
| 78 virtual void clearPreprocessor() override; | |
| 79 | |
| 80 virtual void muteWarningsAndDeprecations() override; | |
| 81 virtual void unmuteWarningsAndDeprecations() override; | |
| 82 | |
| 83 private: | |
| 84 PageScriptDebugServer(); | |
| 85 virtual ~PageScriptDebugServer(); | |
| 86 | |
| 87 virtual ScriptDebugListener* getDebugListenerForContext(v8::Handle<v8::Conte
xt>) override; | |
| 88 virtual void runMessageLoopOnPause(v8::Handle<v8::Context>) override; | |
| 89 virtual void quitMessageLoopOnPause() override; | |
| 90 | |
| 91 typedef HashMap<inspector::InspectorHost*, ScriptDebugListener*> ListenersMa
p; | |
| 92 ListenersMap m_listenersMap; | |
| 93 OwnPtr<ClientMessageLoop> m_clientMessageLoop; | |
| 94 inspector::InspectorHost* m_pausedHost; | |
| 95 HashMap<String, String> m_compiledScriptURLs; | |
| 96 | |
| 97 OwnPtr<ScriptSourceCode> m_preprocessorSourceCode; | |
| 98 OwnPtr<ScriptPreprocessor> m_scriptPreprocessor; | |
| 99 bool canPreprocess(LocalFrame*); | |
| 100 static v8::Isolate* s_mainThreadIsolate; | |
| 101 }; | |
| 102 | |
| 103 } // namespace blink | |
| 104 | |
| 105 | |
| 106 #endif // PageScriptDebugServer_h | |
| OLD | NEW |