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

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: . 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 {
jochen (gone - plz use gerrit) 2014/09/11 12:45:08 wtf make noncopyable
marja 2014/09/15 17:45:26 Done.
20 public:
21 static void init();
22 static void shutdown();
23 static ScriptStreamerThread* shared();
24
25 void postTask(WebThread::Task*);
26
27 bool isRunningTask() const
28 {
29 return m_runningTask;
30 }
31
32 static void taskDone(void*)
33 {
34 ASSERT(shared()->m_runningTask);
35 shared()->m_runningTask = false;
36 }
37
38 private:
39 ScriptStreamerThread()
40 : m_runningTask(false) { }
41
42 bool isRunning()
43 {
44 return !!m_thread;
45 }
46
47 void markAsCompleted(TaskSynchronizer* taskSynchronizer)
48 {
49 taskSynchronizer->taskCompleted();
50 }
51
52 blink::WebThread& platformThread();
53
54 // At the moment, we only use one thread, so we can only stream one script
55 // at a time. FIXME: Use a thread pool and stream multiple scripts.
56 WTF::OwnPtr<blink::WebThread> m_thread;
57 bool m_runningTask;
58 };
59
60 class ScriptStreamingTask : public WebThread::Task {
jochen (gone - plz use gerrit) 2014/09/11 12:45:08 noncopyable
marja 2014/09/15 17:45:27 Done.
61 public:
62 ScriptStreamingTask(v8::ScriptCompiler::ScriptStreamingTask*, ScriptStreamer *);
63 virtual void run() OVERRIDE;
64
65 private:
66 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task;
67 ScriptStreamer* m_streamer;
68 };
69
70
71 } // namespace blink
72
73 #endif // ScriptStreamerThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698