OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gin/test/v8_test.h" | 5 #include "gin/test/v8_test.h" |
6 | 6 |
| 7 #include "base/threading/thread_task_runner_handle.h" |
7 #include "gin/array_buffer.h" | 8 #include "gin/array_buffer.h" |
8 #include "gin/public/isolate_holder.h" | 9 #include "gin/public/isolate_holder.h" |
9 #include "gin/v8_initializer.h" | 10 #include "gin/v8_initializer.h" |
10 | 11 |
11 using v8::Context; | 12 using v8::Context; |
12 using v8::Local; | 13 using v8::Local; |
13 using v8::HandleScope; | 14 using v8::HandleScope; |
14 | 15 |
15 namespace gin { | 16 namespace gin { |
16 | 17 |
17 V8Test::V8Test() { | 18 V8Test::V8Test() { |
18 } | 19 } |
19 | 20 |
20 V8Test::~V8Test() { | 21 V8Test::~V8Test() { |
21 } | 22 } |
22 | 23 |
23 void V8Test::SetUp() { | 24 void V8Test::SetUp() { |
24 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 25 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
25 gin::V8Initializer::LoadV8Snapshot(); | 26 gin::V8Initializer::LoadV8Snapshot(); |
26 gin::V8Initializer::LoadV8Natives(); | 27 gin::V8Initializer::LoadV8Natives(); |
27 #endif | 28 #endif |
28 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | 29 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, |
29 gin::IsolateHolder::kStableV8Extras, | 30 gin::IsolateHolder::kStableV8Extras, |
30 gin::ArrayBufferAllocator::SharedInstance()); | 31 gin::ArrayBufferAllocator::SharedInstance()); |
31 | 32 |
32 instance_.reset(new gin::IsolateHolder); | 33 instance_.reset(new gin::IsolateHolder(base::ThreadTaskRunnerHandle::Get())); |
33 instance_->isolate()->Enter(); | 34 instance_->isolate()->Enter(); |
34 HandleScope handle_scope(instance_->isolate()); | 35 HandleScope handle_scope(instance_->isolate()); |
35 context_.Reset(instance_->isolate(), Context::New(instance_->isolate())); | 36 context_.Reset(instance_->isolate(), Context::New(instance_->isolate())); |
36 Local<Context>::New(instance_->isolate(), context_)->Enter(); | 37 Local<Context>::New(instance_->isolate(), context_)->Enter(); |
37 } | 38 } |
38 | 39 |
39 void V8Test::TearDown() { | 40 void V8Test::TearDown() { |
40 { | 41 { |
41 HandleScope handle_scope(instance_->isolate()); | 42 HandleScope handle_scope(instance_->isolate()); |
42 Local<Context>::New(instance_->isolate(), context_)->Exit(); | 43 Local<Context>::New(instance_->isolate(), context_)->Exit(); |
43 context_.Reset(); | 44 context_.Reset(); |
44 } | 45 } |
45 instance_->isolate()->Exit(); | 46 instance_->isolate()->Exit(); |
46 instance_.reset(); | 47 instance_.reset(); |
47 } | 48 } |
48 | 49 |
49 } // namespace gin | 50 } // namespace gin |
OLD | NEW |