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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 #ifndef ScriptStreamerThread_h
6 #define ScriptStreamerThread_h
7
8 #include "platform/TaskSynchronizer.h"
9 #include "public/platform/WebThread.h"
10 #include "wtf/OwnPtr.h"
11
12 #include <v8.h>
13
14 namespace blink {
15
16 class ScriptStreamer;
17
18 // A singleton thread for running background tasks for script streaming.
19 class ScriptStreamerThread {
20 WTF_MAKE_NONCOPYABLE(ScriptStreamerThread);
21 public:
22 static void init();
23 static void shutdown();
24 static ScriptStreamerThread* shared();
25
26 void postTask(WebThread::Task*);
27
28 bool isRunningTask() const
29 {
30 return m_runningTask;
31 }
32
33 static void taskDone(void*)
34 {
35 ASSERT(shared()->m_runningTask);
36 shared()->m_runningTask = false;
37 }
38
39 private:
40 ScriptStreamerThread()
41 : m_runningTask(false) { }
42
43 bool isRunning()
44 {
45 return !!m_thread;
46 }
47
48 void markAsCompleted(TaskSynchronizer* taskSynchronizer)
49 {
50 taskSynchronizer->taskCompleted();
51 }
52
53 blink::WebThread& platformThread();
54
55 // At the moment, we only use one thread, so we can only stream one script
56 // at a time. FIXME: Use a thread pool and stream multiple scripts.
57 WTF::OwnPtr<blink::WebThread> m_thread;
58 bool m_runningTask;
59 };
60
61 class ScriptStreamingTask : public WebThread::Task {
62 WTF_MAKE_NONCOPYABLE(ScriptStreamingTask);
63 public:
64 ScriptStreamingTask(v8::ScriptCompiler::ScriptStreamingTask*, ScriptStreamer *);
65 virtual void run() OVERRIDE;
66
67 private:
68 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task;
69 ScriptStreamer* m_streamer;
70 };
71
72
73 } // namespace blink
74
75 #endif // ScriptStreamerThread_h
OLDNEW
« 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