OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/renderer/api_binding_test.h" | 5 #include "extensions/renderer/api_binding_test.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" |
8 #include "gin/array_buffer.h" | 9 #include "gin/array_buffer.h" |
9 #include "gin/public/context_holder.h" | 10 #include "gin/public/context_holder.h" |
10 #include "gin/public/isolate_holder.h" | 11 #include "gin/public/isolate_holder.h" |
11 #include "gin/v8_initializer.h" | 12 #include "gin/v8_initializer.h" |
12 | 13 |
13 namespace extensions { | 14 namespace extensions { |
14 | 15 |
15 APIBindingTest::APIBindingTest() {} | 16 APIBindingTest::APIBindingTest() {} |
16 APIBindingTest::~APIBindingTest() {} | 17 APIBindingTest::~APIBindingTest() {} |
17 | 18 |
18 void APIBindingTest::SetUp() { | 19 void APIBindingTest::SetUp() { |
19 // Much of this initialization is stolen from the somewhat-similar | 20 // Much of this initialization is stolen from the somewhat-similar |
20 // gin::V8Test. | 21 // gin::V8Test. |
21 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 22 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
22 gin::V8Initializer::LoadV8Snapshot(); | 23 gin::V8Initializer::LoadV8Snapshot(); |
23 gin::V8Initializer::LoadV8Natives(); | 24 gin::V8Initializer::LoadV8Natives(); |
24 #endif | 25 #endif |
25 | 26 |
26 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | 27 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, |
27 gin::IsolateHolder::kStableV8Extras, | 28 gin::IsolateHolder::kStableV8Extras, |
28 gin::ArrayBufferAllocator::SharedInstance()); | 29 gin::ArrayBufferAllocator::SharedInstance()); |
29 | 30 |
30 isolate_holder_ = base::MakeUnique<gin::IsolateHolder>(); | 31 isolate_holder_ = |
| 32 base::MakeUnique<gin::IsolateHolder>(base::ThreadTaskRunnerHandle::Get()); |
31 isolate()->Enter(); | 33 isolate()->Enter(); |
32 | 34 |
33 v8::HandleScope handle_scope(isolate()); | 35 v8::HandleScope handle_scope(isolate()); |
34 v8::Local<v8::Context> context = v8::Context::New(isolate()); | 36 v8::Local<v8::Context> context = v8::Context::New(isolate()); |
35 context->Enter(); | 37 context->Enter(); |
36 context_holder_ = base::MakeUnique<gin::ContextHolder>(isolate()); | 38 context_holder_ = base::MakeUnique<gin::ContextHolder>(isolate()); |
37 context_holder_->SetContext(context); | 39 context_holder_->SetContext(context); |
38 } | 40 } |
39 | 41 |
40 void APIBindingTest::TearDown() { | 42 void APIBindingTest::TearDown() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 84 |
83 void APIBindingTest::DisposeContext() { | 85 void APIBindingTest::DisposeContext() { |
84 context_holder_.reset(); | 86 context_holder_.reset(); |
85 } | 87 } |
86 | 88 |
87 v8::Isolate* APIBindingTest::isolate() { | 89 v8::Isolate* APIBindingTest::isolate() { |
88 return isolate_holder_->isolate(); | 90 return isolate_holder_->isolate(); |
89 } | 91 } |
90 | 92 |
91 } // namespace extensions | 93 } // namespace extensions |
OLD | NEW |