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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.h

Issue 1848443008: Simplify ScriptStreamer lifetime handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ScriptStreamerThread_h 5 #ifndef ScriptStreamerThread_h
6 #define ScriptStreamerThread_h 6 #define ScriptStreamerThread_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "platform/TaskSynchronizer.h" 9 #include "platform/TaskSynchronizer.h"
10 #include "public/platform/WebThread.h" 10 #include "public/platform/WebThread.h"
11 #include "wtf/Functional.h" 11 #include "wtf/Functional.h"
12 #include "wtf/OwnPtr.h" 12 #include "wtf/OwnPtr.h"
13 #include "wtf/PassOwnPtr.h" 13 #include "wtf/PassOwnPtr.h"
14 14
15 #include <v8.h> 15 #include <v8.h>
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class ScriptStreamer; 19 class ScriptStreamer;
20 20
21 // A singleton thread for running background tasks for script streaming. 21 // A singleton thread for running background tasks for script streaming.
22 class CORE_EXPORT ScriptStreamerThread { 22 class CORE_EXPORT ScriptStreamerThread {
23 USING_FAST_MALLOC(ScriptStreamerThread); 23 USING_FAST_MALLOC(ScriptStreamerThread);
24 WTF_MAKE_NONCOPYABLE(ScriptStreamerThread); 24 WTF_MAKE_NONCOPYABLE(ScriptStreamerThread);
25 public: 25 public:
26 static void init(); 26 static void init();
27 static void shutdown(); 27 static void shutdown();
28 static ScriptStreamerThread* shared(); 28 static ScriptStreamerThread* shared();
29 29
30 void postTask(WTF::PassOwnPtr<WTF::CrossThreadClosure>); 30 void postTask(PassOwnPtr<CrossThreadClosure>);
31 31
32 bool isRunningTask() const 32 bool isRunningTask() const
33 { 33 {
34 MutexLocker locker(m_mutex); 34 MutexLocker locker(m_mutex);
35 return m_runningTask; 35 return m_runningTask;
36 } 36 }
37 37
38 void taskDone(); 38 void taskDone();
39 39
40 static void runScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::Scrip tStreamingTask>, ScriptStreamer*); 40 static void runScriptStreamingTask(PassOwnPtr<v8::ScriptCompiler::ScriptStre amingTask>, ScriptStreamer*);
41 41
42 private: 42 private:
43 ScriptStreamerThread() 43 ScriptStreamerThread()
44 : m_runningTask(false) { } 44 : m_runningTask(false) { }
45 45
46 bool isRunning() const 46 bool isRunning() const
47 { 47 {
48 return !!m_thread; 48 return !!m_thread;
49 } 49 }
50 50
51 WebThread& platformThread(); 51 WebThread& platformThread();
52 52
53 // At the moment, we only use one thread, so we can only stream one script 53 // At the moment, we only use one thread, so we can only stream one script
54 // at a time. FIXME: Use a thread pool and stream multiple scripts. 54 // at a time. FIXME: Use a thread pool and stream multiple scripts.
55 WTF::OwnPtr<WebThread> m_thread; 55 OwnPtr<WebThread> m_thread;
56 bool m_runningTask; 56 bool m_runningTask;
57 mutable Mutex m_mutex; // Guards m_runningTask. 57 mutable Mutex m_mutex; // Guards m_runningTask.
58 }; 58 };
59 59
60 } // namespace blink 60 } // namespace blink
61 61
62 #endif // ScriptStreamerThread_h 62 #endif // ScriptStreamerThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698