OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium 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 #include "config.h" | |
6 #include "core/workers/WorkerIsolateWrapper.h" | |
7 | |
8 #include "bindings/core/v8/V8Binding.h" | |
9 #include "bindings/core/v8/V8GCController.h" | |
10 #include "bindings/core/v8/V8Initializer.h" | |
11 #include "bindings/core/v8/V8PerIsolateData.h" | |
12 | |
13 namespace blink { | |
14 | |
15 namespace { | |
haraken
2015/06/02 02:14:49
Nit: I'd drop this namespace.
sadrul
2015/06/02 02:48:28
Done.
| |
16 | |
17 class WorkerIsolateWrapperDefault final : public WorkerIsolateWrapper { | |
18 WTF_MAKE_NONCOPYABLE(WorkerIsolateWrapperDefault); | |
19 public: | |
20 WorkerIsolateWrapperDefault() | |
21 : m_isolate(V8PerIsolateData::initialize()) | |
22 { | |
23 V8Initializer::initializeWorker(m_isolate); | |
24 | |
25 m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); | |
26 ThreadState::current()->addInterruptor(m_interruptor.get()); | |
27 ThreadState::current()->registerTraceDOMWrappers(m_isolate, V8GCControll er::traceDOMWrappers); | |
28 } | |
29 | |
30 ~WorkerIsolateWrapperDefault() override | |
31 { | |
32 V8PerIsolateData::destroy(m_isolate); | |
33 } | |
34 | |
35 v8::Isolate* isolate() const override { return m_isolate; } | |
36 void willDestroy() override | |
37 { | |
38 ASSERT(m_isolate); | |
39 V8PerIsolateData::willBeDestroyed(m_isolate); | |
40 ThreadState::current()->removeInterruptor(m_interruptor.get()); | |
41 } | |
42 | |
43 void terminateExecution() override | |
44 { | |
45 v8::V8::TerminateExecution(m_isolate); | |
46 } | |
47 | |
48 private: | |
49 v8::Isolate* m_isolate; | |
50 OwnPtr<V8IsolateInterruptor> m_interruptor; | |
51 }; | |
52 | |
53 } // namespace | |
54 | |
55 PassOwnPtr<WorkerIsolateWrapper> WorkerIsolateWrapper::createDefault() | |
56 { | |
57 return adoptPtr(new WorkerIsolateWrapperDefault()); | |
58 } | |
59 | |
60 } // namespace blink | |
OLD | NEW |