Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3792)

Unified Diff: Source/modules/fetch/DataConsumerHandleTestUtil.cpp

Issue 1171913003: **** [WIP] Blink-side: Implement FetchBlobDataConsumerHandle **** (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean up. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/fetch/DataConsumerHandleTestUtil.h ('k') | Source/modules/fetch/DataConsumerHandleUtil.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/modules/fetch/DataConsumerHandleTestUtil.h ('k') | Source/modules/fetch/DataConsumerHandleUtil.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698