Index: Source/core/workers/WorkerV8Isolate.cpp |
diff --git a/Source/core/workers/WorkerV8Isolate.cpp b/Source/core/workers/WorkerV8Isolate.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fdcaf4a2bbbc954c56b47b967c93f96c66e3f107 |
--- /dev/null |
+++ b/Source/core/workers/WorkerV8Isolate.cpp |
@@ -0,0 +1,60 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/workers/WorkerV8Isolate.h" |
+ |
+#include "bindings/core/v8/V8Binding.h" |
+#include "bindings/core/v8/V8GCController.h" |
+#include "bindings/core/v8/V8Initializer.h" |
+#include "bindings/core/v8/V8PerIsolateData.h" |
+ |
+namespace blink { |
+ |
+namespace { |
+ |
+class WorkerV8IsolateDefault final : public WorkerV8Isolate { |
+ WTF_MAKE_NONCOPYABLE(WorkerV8IsolateDefault); |
+public: |
+ WorkerV8IsolateDefault() |
+ : m_isolate(V8PerIsolateData::initialize()) |
+ { |
+ V8Initializer::initializeWorker(m_isolate); |
+ |
+ m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); |
+ ThreadState::current()->addInterruptor(m_interruptor.get()); |
+ ThreadState::current()->registerTraceDOMWrappers(m_isolate, V8GCController::traceDOMWrappers); |
+ } |
+ |
+ ~WorkerV8IsolateDefault() override |
+ { |
+ V8PerIsolateData::destroy(m_isolate); |
+ } |
+ |
+ v8::Isolate* isolate() const override { return m_isolate; } |
+ void willDestroy() override |
+ { |
+ ASSERT(m_isolate); |
+ V8PerIsolateData::willBeDestroyed(m_isolate); |
+ ThreadState::current()->removeInterruptor(m_interruptor.get()); |
+ } |
+ |
+ void terminateExecution() override |
+ { |
+ v8::V8::TerminateExecution(m_isolate); |
+ } |
+ |
+private: |
+ v8::Isolate* m_isolate; |
+ OwnPtr<V8IsolateInterruptor> m_interruptor; |
+}; |
+ |
+} // namespace |
+ |
+PassOwnPtr<WorkerV8Isolate> WorkerV8Isolate::createDefault() |
+{ |
+ return adoptPtr(new WorkerV8IsolateDefault()); |
+} |
+ |
+} // namespace blink |