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

Unified Diff: Source/bindings/core/v8/ScriptStreamerThread.h

Issue 368283002: Stream scripts to V8 as they load - Blink side. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: removed untrue assert Created 6 years, 3 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/bindings/core/v8/ScriptStreamerTest.cpp ('k') | Source/bindings/core/v8/ScriptStreamerThread.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/ScriptStreamerThread.h
diff --git a/Source/bindings/core/v8/ScriptStreamerThread.h b/Source/bindings/core/v8/ScriptStreamerThread.h
new file mode 100644
index 0000000000000000000000000000000000000000..b9a76aab5e6772985c431879772ce20a00492770
--- /dev/null
+++ b/Source/bindings/core/v8/ScriptStreamerThread.h
@@ -0,0 +1,75 @@
+// Copyright 2014 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.
+
+#ifndef ScriptStreamerThread_h
+#define ScriptStreamerThread_h
+
+#include "platform/TaskSynchronizer.h"
+#include "public/platform/WebThread.h"
+#include "wtf/OwnPtr.h"
+
+#include <v8.h>
+
+namespace blink {
+
+class ScriptStreamer;
+
+// A singleton thread for running background tasks for script streaming.
+class ScriptStreamerThread {
+ WTF_MAKE_NONCOPYABLE(ScriptStreamerThread);
+public:
+ static void init();
+ static void shutdown();
+ static ScriptStreamerThread* shared();
+
+ void postTask(WebThread::Task*);
+
+ bool isRunningTask() const
+ {
+ return m_runningTask;
+ }
+
+ static void taskDone(void*)
+ {
+ ASSERT(shared()->m_runningTask);
+ shared()->m_runningTask = false;
+ }
+
+private:
+ ScriptStreamerThread()
+ : m_runningTask(false) { }
+
+ bool isRunning()
+ {
+ return !!m_thread;
+ }
+
+ void markAsCompleted(TaskSynchronizer* taskSynchronizer)
+ {
+ taskSynchronizer->taskCompleted();
+ }
+
+ blink::WebThread& platformThread();
+
+ // At the moment, we only use one thread, so we can only stream one script
+ // at a time. FIXME: Use a thread pool and stream multiple scripts.
+ WTF::OwnPtr<blink::WebThread> m_thread;
+ bool m_runningTask;
+};
+
+class ScriptStreamingTask : public WebThread::Task {
+ WTF_MAKE_NONCOPYABLE(ScriptStreamingTask);
+public:
+ ScriptStreamingTask(v8::ScriptCompiler::ScriptStreamingTask*, ScriptStreamer*);
+ virtual void run() OVERRIDE;
+
+private:
+ WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task;
+ ScriptStreamer* m_streamer;
+};
+
+
+} // namespace blink
+
+#endif // ScriptStreamerThread_h
« no previous file with comments | « Source/bindings/core/v8/ScriptStreamerTest.cpp ('k') | Source/bindings/core/v8/ScriptStreamerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698