inspected-context.h 1.86 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/inspector/string-16.h"
13

14
#include "include/v8.h"
15 16 17 18 19 20 21 22 23 24 25 26

namespace v8_inspector {

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

class InspectedContext {
 public:
  ~InspectedContext();

27 28
  static int contextId(v8::Local<v8::Context>);

29 30 31 32 33 34 35
  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; }

36 37
  bool isReported(int sessionId) const;
  void setReported(int sessionId, bool reported);
38 39 40 41

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

42 43 44
  InjectedScript* getInjectedScript(int sessionId);
  bool createInjectedScript(int sessionId);
  void discardInjectedScript(int sessionId);
45 46 47 48 49

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

50 51
  class WeakCallbackData;

52 53 54 55 56 57 58
  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;
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 67
};

}  // namespace v8_inspector

68
#endif  // V8_INSPECTOR_INSPECTED_CONTEXT_H_