Line data Source code
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_INSPECTED_CONTEXT_H_
6 : #define V8_INSPECTOR_INSPECTED_CONTEXT_H_
7 :
8 : #include <unordered_map>
9 : #include <unordered_set>
10 :
11 : #include "src/base/macros.h"
12 : #include "src/debug/debug-interface.h"
13 : #include "src/inspector/string-16.h"
14 :
15 : #include "include/v8.h"
16 :
17 : namespace v8_inspector {
18 :
19 : class InjectedScript;
20 : class InjectedScriptHost;
21 : class V8ContextInfo;
22 : class V8InspectorImpl;
23 :
24 : enum class V8InternalValueType { kNone, kEntry, kScope, kScopeList };
25 :
26 : class InspectedContext {
27 : public:
28 : ~InspectedContext();
29 :
30 : static int contextId(v8::Local<v8::Context>);
31 :
32 : v8::Local<v8::Context> context() const;
33 : int contextId() const { return m_contextId; }
34 : int contextGroupId() const { return m_contextGroupId; }
35 765 : String16 origin() const { return m_origin; }
36 715 : String16 humanReadableName() const { return m_humanReadableName; }
37 61138 : String16 auxData() const { return m_auxData; }
38 :
39 : bool isReported(int sessionId) const;
40 : void setReported(int sessionId, bool reported);
41 :
42 : v8::Isolate* isolate() const;
43 : V8InspectorImpl* inspector() const { return m_inspector; }
44 :
45 : InjectedScript* getInjectedScript(int sessionId);
46 : InjectedScript* createInjectedScript(int sessionId);
47 : void discardInjectedScript(int sessionId);
48 :
49 : bool addInternalObject(v8::Local<v8::Object> object,
50 : V8InternalValueType type);
51 : V8InternalValueType getInternalType(v8::Local<v8::Object> object);
52 :
53 : private:
54 : friend class V8InspectorImpl;
55 : InspectedContext(V8InspectorImpl*, const V8ContextInfo&, int contextId);
56 :
57 : class WeakCallbackData;
58 :
59 : V8InspectorImpl* m_inspector;
60 : v8::Global<v8::Context> m_context;
61 : int m_contextId;
62 : int m_contextGroupId;
63 : const String16 m_origin;
64 : const String16 m_humanReadableName;
65 : const String16 m_auxData;
66 : std::unordered_set<int> m_reportedSessionIds;
67 : std::unordered_map<int, std::unique_ptr<InjectedScript>> m_injectedScripts;
68 : WeakCallbackData* m_weakCallbackData;
69 : v8::Global<v8::debug::WeakMap> m_internalObjects;
70 :
71 : DISALLOW_COPY_AND_ASSIGN(InspectedContext);
72 : };
73 :
74 : } // namespace v8_inspector
75 :
76 : #endif // V8_INSPECTOR_INSPECTED_CONTEXT_H_
|