Index: Source/core/workers/WorkerIsolateWrapper.cpp |
diff --git a/Source/core/workers/WorkerIsolateWrapper.cpp b/Source/core/workers/WorkerIsolateWrapper.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..455f4c49b13269c4e772b5fed358e21e11e05b00 |
--- /dev/null |
+++ b/Source/core/workers/WorkerIsolateWrapper.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/WorkerIsolateWrapper.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 { |
haraken
2015/06/02 02:14:49
Nit: I'd drop this namespace.
sadrul
2015/06/02 02:48:28
Done.
|
+ |
+class WorkerIsolateWrapperDefault final : public WorkerIsolateWrapper { |
+ WTF_MAKE_NONCOPYABLE(WorkerIsolateWrapperDefault); |
+public: |
+ WorkerIsolateWrapperDefault() |
+ : 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); |
+ } |
+ |
+ ~WorkerIsolateWrapperDefault() 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<WorkerIsolateWrapper> WorkerIsolateWrapper::createDefault() |
+{ |
+ return adoptPtr(new WorkerIsolateWrapperDefault()); |
+} |
+ |
+} // namespace blink |