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

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

Issue 368283002: Stream scripts to V8 as they load - Blink side. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: renaming Created 6 years, 4 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
Index: Source/bindings/core/v8/V8ScriptStreamerThread.h
diff --git a/Source/bindings/core/v8/V8ScriptStreamerThread.h b/Source/bindings/core/v8/V8ScriptStreamerThread.h
new file mode 100644
index 0000000000000000000000000000000000000000..508871cad003596964df559d8eb9b4ff86505468
--- /dev/null
+++ b/Source/bindings/core/v8/V8ScriptStreamerThread.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2014 Google Inc. All rights reserved.
haraken 2014/08/17 16:05:27 Nit: Use the 3-line copyright.
marja 2014/08/20 11:45:56 Done.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8ScriptStreamerThread_h
+#define V8ScriptStreamerThread_h
+
+#include "platform/TaskSynchronizer.h"
+#include "public/platform/WebThread.h"
+#include "wtf/OwnPtr.h"
+
+#include <v8.h>
+
+namespace blink {
+
+class V8ScriptStreamer;
+
+// A singleton thread for running background tasks for script streaming.
+class V8ScriptStreamerThread {
haraken 2014/08/17 16:05:27 V8ScriptStreamerThread => ScriptStreamerThread We
marja 2014/08/20 11:45:56 Done.
+public:
+ static void init();
+ static void shutdown();
+ static V8ScriptStreamerThread* shared();
+
+ void postTask(WebThread::Task*);
+
+ bool isRunningTask() const
+ {
+ return m_runningTask;
+ }
+
+ static void taskDone(void*)
+ {
+ shared()->m_runningTask = false;
+ }
+
+private:
+ V8ScriptStreamerThread()
+ : 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. TODO(marja): Use a thread pool and stream multiple scripts.
haraken 2014/08/17 16:05:27 Nit: TODO(marja) => FIXME.
marja 2014/08/20 11:45:56 Done.
+ WTF::OwnPtr<blink::WebThread> m_thread;
+ bool m_runningTask;
+};
+
+class ScriptStreamingTask : public WebThread::Task {
+public:
+ ScriptStreamingTask(v8::ScriptCompiler::ScriptStreamingTask*, V8ScriptStreamer*);
+ virtual void run() OVERRIDE;
+
+private:
+ WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task;
+ V8ScriptStreamer* m_streamer;
+};
+
+
+} // namespace blink
+
+#endif // V8ScriptStreamerThread_h

Powered by Google App Engine
This is Rietveld 408576698