| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2010, 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 V8_INSPECTOR_V8INSPECTORIMPL_H_ | |
| 32 #define V8_INSPECTOR_V8INSPECTORIMPL_H_ | |
| 33 | |
| 34 #include "src/base/macros.h" | |
| 35 #include "src/inspector/protocol/Protocol.h" | |
| 36 | |
| 37 #include "include/v8-debug.h" | |
| 38 #include "include/v8-inspector.h" | |
| 39 | |
| 40 #include <vector> | |
| 41 | |
| 42 namespace v8_inspector { | |
| 43 | |
| 44 class InspectedContext; | |
| 45 class V8ConsoleMessageStorage; | |
| 46 class V8Debugger; | |
| 47 class V8DebuggerAgentImpl; | |
| 48 class V8InspectorSessionImpl; | |
| 49 class V8ProfilerAgentImpl; | |
| 50 class V8RuntimeAgentImpl; | |
| 51 class V8StackTraceImpl; | |
| 52 | |
| 53 class V8InspectorImpl : public V8Inspector { | |
| 54 DISALLOW_COPY_AND_ASSIGN(V8InspectorImpl); | |
| 55 | |
| 56 public: | |
| 57 V8InspectorImpl(v8::Isolate*, V8InspectorClient*); | |
| 58 ~V8InspectorImpl() override; | |
| 59 | |
| 60 v8::Isolate* isolate() const { return m_isolate; } | |
| 61 V8InspectorClient* client() { return m_client; } | |
| 62 V8Debugger* debugger() { return m_debugger.get(); } | |
| 63 | |
| 64 v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, | |
| 65 v8::Local<v8::Script>); | |
| 66 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, | |
| 67 v8::Local<v8::Context>, | |
| 68 v8::Local<v8::Value> receiver, | |
| 69 int argc, v8::Local<v8::Value> info[]); | |
| 70 v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context>, | |
| 71 v8::Local<v8::String>); | |
| 72 v8::Local<v8::Script> compileScript(v8::Local<v8::Context>, | |
| 73 v8::Local<v8::String>, | |
| 74 const String16& fileName, | |
| 75 bool markAsInternal); | |
| 76 v8::Local<v8::Context> regexContext(); | |
| 77 | |
| 78 // V8Inspector implementation. | |
| 79 std::unique_ptr<V8InspectorSession> connect(int contextGroupId, | |
| 80 V8Inspector::Channel*, | |
| 81 const StringView& state) override; | |
| 82 void contextCreated(const V8ContextInfo&) override; | |
| 83 void contextDestroyed(v8::Local<v8::Context>) override; | |
| 84 void resetContextGroup(int contextGroupId) override; | |
| 85 void willExecuteScript(v8::Local<v8::Context>, int scriptId) override; | |
| 86 void didExecuteScript(v8::Local<v8::Context>) override; | |
| 87 void idleStarted() override; | |
| 88 void idleFinished() override; | |
| 89 unsigned exceptionThrown(v8::Local<v8::Context>, const StringView& message, | |
| 90 v8::Local<v8::Value> exception, | |
| 91 const StringView& detailedMessage, | |
| 92 const StringView& url, unsigned lineNumber, | |
| 93 unsigned columnNumber, std::unique_ptr<V8StackTrace>, | |
| 94 int scriptId) override; | |
| 95 void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId, | |
| 96 const StringView& message) override; | |
| 97 std::unique_ptr<V8StackTrace> createStackTrace( | |
| 98 v8::Local<v8::StackTrace>) override; | |
| 99 std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) override; | |
| 100 void asyncTaskScheduled(const StringView& taskName, void* task, | |
| 101 bool recurring) override; | |
| 102 void asyncTaskCanceled(void* task) override; | |
| 103 void asyncTaskStarted(void* task) override; | |
| 104 void asyncTaskFinished(void* task) override; | |
| 105 void allAsyncTasksCanceled() override; | |
| 106 | |
| 107 unsigned nextExceptionId() { return ++m_lastExceptionId; } | |
| 108 void enableStackCapturingIfNeeded(); | |
| 109 void disableStackCapturingIfNeeded(); | |
| 110 void muteExceptions(int contextGroupId); | |
| 111 void unmuteExceptions(int contextGroupId); | |
| 112 V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId); | |
| 113 bool hasConsoleMessageStorage(int contextGroupId); | |
| 114 using ContextByIdMap = | |
| 115 protocol::HashMap<int, std::unique_ptr<InspectedContext>>; | |
| 116 void discardInspectedContext(int contextGroupId, int contextId); | |
| 117 const ContextByIdMap* contextGroup(int contextGroupId); | |
| 118 void disconnect(V8InspectorSessionImpl*); | |
| 119 V8InspectorSessionImpl* sessionForContextGroup(int contextGroupId); | |
| 120 InspectedContext* getContext(int groupId, int contextId) const; | |
| 121 V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId); | |
| 122 V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId); | |
| 123 V8ProfilerAgentImpl* enabledProfilerAgentForGroup(int contextGroupId); | |
| 124 | |
| 125 private: | |
| 126 v8::Isolate* m_isolate; | |
| 127 V8InspectorClient* m_client; | |
| 128 std::unique_ptr<V8Debugger> m_debugger; | |
| 129 v8::Global<v8::Context> m_regexContext; | |
| 130 int m_capturingStackTracesCount; | |
| 131 unsigned m_lastExceptionId; | |
| 132 | |
| 133 using MuteExceptionsMap = protocol::HashMap<int, int>; | |
| 134 MuteExceptionsMap m_muteExceptionsMap; | |
| 135 | |
| 136 using ContextsByGroupMap = | |
| 137 protocol::HashMap<int, std::unique_ptr<ContextByIdMap>>; | |
| 138 ContextsByGroupMap m_contexts; | |
| 139 | |
| 140 using SessionMap = protocol::HashMap<int, V8InspectorSessionImpl*>; | |
| 141 SessionMap m_sessions; | |
| 142 | |
| 143 using ConsoleStorageMap = | |
| 144 protocol::HashMap<int, std::unique_ptr<V8ConsoleMessageStorage>>; | |
| 145 ConsoleStorageMap m_consoleStorageMap; | |
| 146 }; | |
| 147 | |
| 148 } // namespace v8_inspector | |
| 149 | |
| 150 #endif // V8_INSPECTOR_V8INSPECTORIMPL_H_ | |
| OLD | NEW |