Chromium Code Reviews| 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 "modules/fetch/DataConsumerHandleTestUtil.h" | |
| 7 | |
| 8 #include "bindings/core/v8/DOMWrapperWorld.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 DataConsumerHandleTestUtil::Thread::Thread(const char* name, InitializationPolic y initializationPolicy) | |
| 13 : m_thread(WebThreadSupportingGC::create(name)) | |
| 14 , m_initializationPolicy(initializationPolicy) | |
| 15 , m_waitableEvent(adoptPtr(Platform::current()->createWaitableEvent())) | |
| 16 { | |
| 17 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&Thread::initialize, A llowCrossThreadAccess(this)))); | |
| 18 m_waitableEvent->wait(); | |
| 19 } | |
| 20 | |
| 21 DataConsumerHandleTestUtil::Thread::~Thread() | |
| 22 { | |
| 23 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&Thread::shutdown, All owCrossThreadAccess(this)))); | |
| 24 m_waitableEvent->wait(); | |
| 25 } | |
| 26 | |
| 27 void DataConsumerHandleTestUtil::Thread::initialize() | |
| 28 { | |
| 29 if (m_initializationPolicy >= ScriptExecution) { | |
| 30 m_isolateHolder = adoptPtr(new gin::IsolateHolder()); | |
| 31 isolate()->Enter(); | |
| 32 } | |
| 33 m_thread->initialize(); | |
| 34 if (m_initializationPolicy >= ScriptExecution) { | |
| 35 v8::HandleScope handleScope(isolate()); | |
| 36 m_scriptState = ScriptState::create(v8::Context::New(isolate()), DOMWrap perWorld::create(isolate())); | |
|
Nico
2015/08/26 03:54:51
It looks like this is leaked somehow, see e.g. htt
| |
| 37 } | |
| 38 if (m_initializationPolicy >= WithExecutionContext) { | |
| 39 m_executionContext = adoptRefWillBeNoop(new NullExecutionContext()); | |
| 40 } | |
| 41 m_waitableEvent->signal(); | |
| 42 } | |
| 43 | |
| 44 void DataConsumerHandleTestUtil::Thread::shutdown() | |
| 45 { | |
| 46 m_executionContext = nullptr; | |
| 47 m_scriptState = nullptr; | |
| 48 m_thread->shutdown(); | |
| 49 if (m_isolateHolder) { | |
| 50 isolate()->Exit(); | |
| 51 m_isolateHolder = nullptr; | |
| 52 } | |
| 53 m_waitableEvent->signal(); | |
| 54 } | |
| 55 | |
| 56 } // namespace blink | |
| OLD | NEW |