blob: 2bb16ca7bacd4ac1d79bada0ba856ba2b60de7f0 [file] [log] [blame]
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -07001// Copyright 2016 PDFium 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// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef FXJS_CFXJSE_ISOLATETRACKER_H_
8#define FXJS_CFXJSE_ISOLATETRACKER_H_
9
10#include <map>
11#include <memory>
12#include <vector>
13
14#include "v8/include/v8.h"
15
16#include "fxjs/cfxjse_runtimedata.h"
17
18class CFXJSE_ScopeUtil_IsolateHandle {
19 public:
20 explicit CFXJSE_ScopeUtil_IsolateHandle(v8::Isolate* pIsolate)
21 : m_isolate(pIsolate), m_iscope(pIsolate), m_hscope(pIsolate) {}
22 v8::Isolate* GetIsolate() { return m_isolate; }
23
24 private:
25 CFXJSE_ScopeUtil_IsolateHandle(const CFXJSE_ScopeUtil_IsolateHandle&) =
26 delete;
27 void operator=(const CFXJSE_ScopeUtil_IsolateHandle&) = delete;
28 void* operator new(size_t size) = delete;
29 void operator delete(void*, size_t) = delete;
30
31 v8::Isolate* m_isolate;
32 v8::Isolate::Scope m_iscope;
33 v8::HandleScope m_hscope;
34};
35
36class CFXJSE_ScopeUtil_IsolateHandleRootContext {
37 public:
38 explicit CFXJSE_ScopeUtil_IsolateHandleRootContext(v8::Isolate* pIsolate)
39 : m_parent(pIsolate),
40 m_cscope(v8::Local<v8::Context>::New(
41 pIsolate,
42 CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext)) {}
43
44 private:
45 CFXJSE_ScopeUtil_IsolateHandleRootContext(
46 const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete;
47 void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete;
48 void* operator new(size_t size) = delete;
49 void operator delete(void*, size_t) = delete;
50
51 CFXJSE_ScopeUtil_IsolateHandle m_parent;
52 v8::Context::Scope m_cscope;
53};
54
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070055#endif // FXJS_CFXJSE_ISOLATETRACKER_H_