OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_INSPECTOR_V8INSPECTORSESSIONIMPL_H_ |
| 6 #define V8_INSPECTOR_V8INSPECTORSESSIONIMPL_H_ |
| 7 |
| 8 #include "src/inspector/Allocator.h" |
| 9 #include "src/inspector/protocol/Forward.h" |
| 10 #include "src/inspector/protocol/Runtime.h" |
| 11 #include "src/inspector/protocol/Schema.h" |
| 12 #include "src/inspector/public/V8Inspector.h" |
| 13 #include "src/inspector/public/V8InspectorSession.h" |
| 14 |
| 15 #include <v8.h> |
| 16 #include <vector> |
| 17 |
| 18 namespace v8_inspector { |
| 19 |
| 20 class InjectedScript; |
| 21 class RemoteObjectIdBase; |
| 22 class V8ConsoleAgentImpl; |
| 23 class V8DebuggerAgentImpl; |
| 24 class V8InspectorImpl; |
| 25 class V8HeapProfilerAgentImpl; |
| 26 class V8ProfilerAgentImpl; |
| 27 class V8RuntimeAgentImpl; |
| 28 class V8SchemaAgentImpl; |
| 29 |
| 30 using protocol::ErrorString; |
| 31 |
| 32 class V8InspectorSessionImpl : public V8InspectorSession, |
| 33 public protocol::FrontendChannel { |
| 34 V8_INSPECTOR_DISALLOW_COPY(V8InspectorSessionImpl); |
| 35 |
| 36 public: |
| 37 static std::unique_ptr<V8InspectorSessionImpl> create( |
| 38 V8InspectorImpl*, int contextGroupId, V8Inspector::Channel*, |
| 39 const StringView& state); |
| 40 ~V8InspectorSessionImpl(); |
| 41 |
| 42 V8InspectorImpl* inspector() const { return m_inspector; } |
| 43 V8ConsoleAgentImpl* consoleAgent() { return m_consoleAgent.get(); } |
| 44 V8DebuggerAgentImpl* debuggerAgent() { return m_debuggerAgent.get(); } |
| 45 V8SchemaAgentImpl* schemaAgent() { return m_schemaAgent.get(); } |
| 46 V8ProfilerAgentImpl* profilerAgent() { return m_profilerAgent.get(); } |
| 47 V8RuntimeAgentImpl* runtimeAgent() { return m_runtimeAgent.get(); } |
| 48 int contextGroupId() const { return m_contextGroupId; } |
| 49 |
| 50 InjectedScript* findInjectedScript(ErrorString*, int contextId); |
| 51 InjectedScript* findInjectedScript(ErrorString*, RemoteObjectIdBase*); |
| 52 void reset(); |
| 53 void discardInjectedScripts(); |
| 54 void reportAllContexts(V8RuntimeAgentImpl*); |
| 55 void setCustomObjectFormatterEnabled(bool); |
| 56 std::unique_ptr<protocol::Runtime::RemoteObject> wrapObject( |
| 57 v8::Local<v8::Context>, v8::Local<v8::Value>, const String16& groupName, |
| 58 bool generatePreview); |
| 59 std::unique_ptr<protocol::Runtime::RemoteObject> wrapTable( |
| 60 v8::Local<v8::Context>, v8::Local<v8::Value> table, |
| 61 v8::Local<v8::Value> columns); |
| 62 std::vector<std::unique_ptr<protocol::Schema::Domain>> supportedDomainsImpl(); |
| 63 bool unwrapObject(ErrorString*, const String16& objectId, |
| 64 v8::Local<v8::Value>*, v8::Local<v8::Context>*, |
| 65 String16* objectGroup); |
| 66 void releaseObjectGroup(const String16& objectGroup); |
| 67 |
| 68 // V8InspectorSession implementation. |
| 69 void dispatchProtocolMessage(const StringView& message) override; |
| 70 std::unique_ptr<StringBuffer> stateJSON() override; |
| 71 std::vector<std::unique_ptr<protocol::Schema::API::Domain>> supportedDomains() |
| 72 override; |
| 73 void addInspectedObject( |
| 74 std::unique_ptr<V8InspectorSession::Inspectable>) override; |
| 75 void schedulePauseOnNextStatement(const StringView& breakReason, |
| 76 const StringView& breakDetails) override; |
| 77 void cancelPauseOnNextStatement() override; |
| 78 void breakProgram(const StringView& breakReason, |
| 79 const StringView& breakDetails) override; |
| 80 void setSkipAllPauses(bool) override; |
| 81 void resume() override; |
| 82 void stepOver() override; |
| 83 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> |
| 84 searchInTextByLines(const StringView& text, const StringView& query, |
| 85 bool caseSensitive, bool isRegex) override; |
| 86 void releaseObjectGroup(const StringView& objectGroup) override; |
| 87 bool unwrapObject(std::unique_ptr<StringBuffer>*, const StringView& objectId, |
| 88 v8::Local<v8::Value>*, v8::Local<v8::Context>*, |
| 89 std::unique_ptr<StringBuffer>* objectGroup) override; |
| 90 std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject( |
| 91 v8::Local<v8::Context>, v8::Local<v8::Value>, |
| 92 const StringView& groupName) override; |
| 93 |
| 94 V8InspectorSession::Inspectable* inspectedObject(unsigned num); |
| 95 static const unsigned kInspectedObjectBufferSize = 5; |
| 96 |
| 97 private: |
| 98 V8InspectorSessionImpl(V8InspectorImpl*, int contextGroupId, |
| 99 V8Inspector::Channel*, const StringView& state); |
| 100 protocol::DictionaryValue* agentState(const String16& name); |
| 101 |
| 102 // protocol::FrontendChannel implementation. |
| 103 void sendProtocolResponse(int callId, const String16& message) override; |
| 104 void sendProtocolNotification(const String16& message) override; |
| 105 void flushProtocolNotifications() override; |
| 106 |
| 107 int m_contextGroupId; |
| 108 V8InspectorImpl* m_inspector; |
| 109 V8Inspector::Channel* m_channel; |
| 110 bool m_customObjectFormatterEnabled; |
| 111 |
| 112 protocol::UberDispatcher m_dispatcher; |
| 113 std::unique_ptr<protocol::DictionaryValue> m_state; |
| 114 |
| 115 std::unique_ptr<V8RuntimeAgentImpl> m_runtimeAgent; |
| 116 std::unique_ptr<V8DebuggerAgentImpl> m_debuggerAgent; |
| 117 std::unique_ptr<V8HeapProfilerAgentImpl> m_heapProfilerAgent; |
| 118 std::unique_ptr<V8ProfilerAgentImpl> m_profilerAgent; |
| 119 std::unique_ptr<V8ConsoleAgentImpl> m_consoleAgent; |
| 120 std::unique_ptr<V8SchemaAgentImpl> m_schemaAgent; |
| 121 std::vector<std::unique_ptr<V8InspectorSession::Inspectable>> |
| 122 m_inspectedObjects; |
| 123 }; |
| 124 |
| 125 } // namespace v8_inspector |
| 126 |
| 127 #endif // V8_INSPECTOR_V8INSPECTORSESSIONIMPL_H_ |
OLD | NEW |