| Index: Source/modules/fetch/DataConsumerHandleTestUtil.cpp
|
| diff --git a/Source/modules/fetch/DataConsumerHandleTestUtil.cpp b/Source/modules/fetch/DataConsumerHandleTestUtil.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..40138c86078c0a8ccdcdf8103de2c3d14e768285
|
| --- /dev/null
|
| +++ b/Source/modules/fetch/DataConsumerHandleTestUtil.cpp
|
| @@ -0,0 +1,51 @@
|
| +// 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 "modules/fetch/DataConsumerHandleTestUtil.h"
|
| +
|
| +namespace blink {
|
| +
|
| +DataConsumerHandleTestUtil::TestingThread::TestingThread(const char* name, InitializationPolicy initializationPolicy)
|
| + : m_thread(WebThreadSupportingGC::create(name))
|
| + , m_initializationPolicy(initializationPolicy)
|
| + , m_waitableEvent(adoptPtr(Platform::current()->createWaitableEvent()))
|
| + , m_isolate(nullptr)
|
| +{
|
| + m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&TestingThread::initialize, AllowCrossThreadAccess(this))));
|
| + m_waitableEvent->wait();
|
| +}
|
| +
|
| +DataConsumerHandleTestUtil::TestingThread::~TestingThread()
|
| +{
|
| + m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&TestingThread::shutdown, AllowCrossThreadAccess(this))));
|
| + m_waitableEvent->wait();
|
| +}
|
| +
|
| +void DataConsumerHandleTestUtil::TestingThread::initialize()
|
| +{
|
| + if (m_initializationPolicy >= ScriptExecution) {
|
| + m_isolate = v8::Isolate::New(v8::Isolate::CreateParams());
|
| + m_isolate->Enter();
|
| + }
|
| + m_thread->initialize();
|
| + if (m_initializationPolicy >= WithExecutionContext) {
|
| + m_executionContext = adoptRefWillBeNoop(new NullExecutionContext());
|
| + }
|
| + m_waitableEvent->signal();
|
| +}
|
| +
|
| +void DataConsumerHandleTestUtil::TestingThread::shutdown()
|
| +{
|
| + m_executionContext = nullptr;
|
| + m_thread->shutdown();
|
| + if (m_isolate) {
|
| + m_isolate->Exit();
|
| + m_isolate->Dispose();
|
| + m_isolate = nullptr;
|
| + }
|
| + m_waitableEvent->signal();
|
| +}
|
| +
|
| +} // namespace blink
|
|
|