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/WorkerV8Isolate.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 { |
| 16 |
| 17 class WorkerV8IsolateDefault final : public WorkerV8Isolate { |
| 18 WTF_MAKE_NONCOPYABLE(WorkerV8IsolateDefault); |
| 19 public: |
| 20 WorkerV8IsolateDefault() |
| 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 ~WorkerV8IsolateDefault() 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<WorkerV8Isolate> WorkerV8Isolate::createDefault() |
| 56 { |
| 57 return adoptPtr(new WorkerV8IsolateDefault()); |
| 58 } |
| 59 |
| 60 } // namespace blink |
OLD | NEW |