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