inspected-context.h 2.2 KB
Newer Older
1 2 3 4
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef V8_INSPECTOR_INSPECTED_CONTEXT_H_
#define V8_INSPECTOR_INSPECTED_CONTEXT_H_
7

8
#include <unordered_map>
9 10
#include <unordered_set>

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 18 19 20 21 22 23

namespace v8_inspector {

class InjectedScript;
class InjectedScriptHost;
class V8ContextInfo;
class V8InspectorImpl;

24 25
enum class V8InternalValueType { kNone, kEntry, kScope, kScopeList };

26 27 28 29
class InspectedContext {
 public:
  ~InspectedContext();

30 31
  static int contextId(v8::Local<v8::Context>);

32 33 34 35 36 37 38
  v8::Local<v8::Context> context() const;
  int contextId() const { return m_contextId; }
  int contextGroupId() const { return m_contextGroupId; }
  String16 origin() const { return m_origin; }
  String16 humanReadableName() const { return m_humanReadableName; }
  String16 auxData() const { return m_auxData; }

39 40
  bool isReported(int sessionId) const;
  void setReported(int sessionId, bool reported);
41 42 43 44

  v8::Isolate* isolate() const;
  V8InspectorImpl* inspector() const { return m_inspector; }

45
  InjectedScript* getInjectedScript(int sessionId);
46
  InjectedScript* createInjectedScript(int sessionId);
47
  void discardInjectedScript(int sessionId);
48

49 50 51 52
  bool addInternalObject(v8::Local<v8::Object> object,
                         V8InternalValueType type);
  V8InternalValueType getInternalType(v8::Local<v8::Object> object);

53 54 55 56
 private:
  friend class V8InspectorImpl;
  InspectedContext(V8InspectorImpl*, const V8ContextInfo&, int contextId);

57 58
  class WeakCallbackData;

59 60 61 62 63 64 65
  V8InspectorImpl* m_inspector;
  v8::Global<v8::Context> m_context;
  int m_contextId;
  int m_contextGroupId;
  const String16 m_origin;
  const String16 m_humanReadableName;
  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 75
};

}  // namespace v8_inspector

76
#endif  // V8_INSPECTOR_INSPECTED_CONTEXT_H_