| 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 namespace blink { |
| 9 |
| 10 DataConsumerHandleTestUtil::TestingThread::TestingThread(const char* name, Initi
alizationPolicy initializationPolicy) |
| 11 : m_thread(WebThreadSupportingGC::create(name)) |
| 12 , m_initializationPolicy(initializationPolicy) |
| 13 , m_waitableEvent(adoptPtr(Platform::current()->createWaitableEvent())) |
| 14 , m_isolate(nullptr) |
| 15 { |
| 16 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&TestingThread::initia
lize, AllowCrossThreadAccess(this)))); |
| 17 m_waitableEvent->wait(); |
| 18 } |
| 19 |
| 20 DataConsumerHandleTestUtil::TestingThread::~TestingThread() |
| 21 { |
| 22 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&TestingThread::shutdo
wn, AllowCrossThreadAccess(this)))); |
| 23 m_waitableEvent->wait(); |
| 24 } |
| 25 |
| 26 void DataConsumerHandleTestUtil::TestingThread::initialize() |
| 27 { |
| 28 if (m_initializationPolicy >= ScriptExecution) { |
| 29 m_isolate = v8::Isolate::New(v8::Isolate::CreateParams()); |
| 30 m_isolate->Enter(); |
| 31 } |
| 32 m_thread->initialize(); |
| 33 if (m_initializationPolicy >= WithExecutionContext) { |
| 34 m_executionContext = adoptRefWillBeNoop(new NullExecutionContext()); |
| 35 } |
| 36 m_waitableEvent->signal(); |
| 37 } |
| 38 |
| 39 void DataConsumerHandleTestUtil::TestingThread::shutdown() |
| 40 { |
| 41 m_executionContext = nullptr; |
| 42 m_thread->shutdown(); |
| 43 if (m_isolate) { |
| 44 m_isolate->Exit(); |
| 45 m_isolate->Dispose(); |
| 46 m_isolate = nullptr; |
| 47 } |
| 48 m_waitableEvent->signal(); |
| 49 } |
| 50 |
| 51 } // namespace blink |
| OLD | NEW |