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_INSPECTEDCONTEXT_H_
6 : #define V8_INSPECTOR_INSPECTEDCONTEXT_H_
7 :
8 : #include <unordered_map>
9 : #include <unordered_set>
10 :
11 : #include "src/base/macros.h"
12 : #include "src/inspector/string-16.h"
13 :
14 : #include "include/v8.h"
15 :
16 : namespace v8_inspector {
17 :
18 : class InjectedScript;
19 : class InjectedScriptHost;
20 : class V8ContextInfo;
21 : class V8InspectorImpl;
22 :
23 : class InspectedContext {
24 : public:
25 : ~InspectedContext();
26 :
27 : static int contextId(v8::Local<v8::Context>);
28 :
29 : v8::Local<v8::Context> context() const;
30 : int contextId() const { return m_contextId; }
31 : int contextGroupId() const { return m_contextGroupId; }
32 655 : String16 origin() const { return m_origin; }
33 615 : String16 humanReadableName() const { return m_humanReadableName; }
34 26580 : String16 auxData() const { return m_auxData; }
35 :
36 : bool isReported(int sessionId) const;
37 : void setReported(int sessionId, bool reported);
38 :
39 : v8::Isolate* isolate() const;
40 : V8InspectorImpl* inspector() const { return m_inspector; }
41 :
42 : InjectedScript* getInjectedScript(int sessionId);
43 : bool createInjectedScript(int sessionId);
44 : void discardInjectedScript(int sessionId);
45 :
46 : private:
47 : friend class V8InspectorImpl;
48 : InspectedContext(V8InspectorImpl*, const V8ContextInfo&, int contextId);
49 :
50 : class WeakCallbackData;
51 :
52 : V8InspectorImpl* m_inspector;
53 : v8::Global<v8::Context> m_context;
54 : int m_contextId;
55 : int m_contextGroupId;
56 : const String16 m_origin;
57 : const String16 m_humanReadableName;
58 : const String16 m_auxData;
59 : std::unordered_set<int> m_reportedSessionIds;
60 : std::unordered_map<int, std::unique_ptr<InjectedScript>> m_injectedScripts;
61 : WeakCallbackData* m_weakCallbackData;
62 :
63 : DISALLOW_COPY_AND_ASSIGN(InspectedContext);
64 : };
65 :
66 : } // namespace v8_inspector
67 :
68 : #endif // V8_INSPECTOR_INSPECTEDCONTEXT_H_
|