| OLD | NEW |
| 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 void postTask(WebThread::Task*); | 27 void postTask(WebThread::Task*); |
| 28 | 28 |
| 29 bool isRunningTask() const | 29 bool isRunningTask() const |
| 30 { | 30 { |
| 31 MutexLocker locker(m_mutex); | 31 MutexLocker locker(m_mutex); |
| 32 return m_runningTask; | 32 return m_runningTask; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void taskDone(); | 35 void taskDone(); |
| 36 | 36 |
| 37 static void runScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::Scrip
tStreamingTask>, ScriptStreamer*); |
| 38 |
| 37 private: | 39 private: |
| 38 ScriptStreamerThread() | 40 ScriptStreamerThread() |
| 39 : m_runningTask(false) { } | 41 : m_runningTask(false) { } |
| 40 | 42 |
| 41 bool isRunning() const | 43 bool isRunning() const |
| 42 { | 44 { |
| 43 return !!m_thread; | 45 return !!m_thread; |
| 44 } | 46 } |
| 45 | 47 |
| 46 WebThread& platformThread(); | 48 WebThread& platformThread(); |
| 47 | 49 |
| 48 // At the moment, we only use one thread, so we can only stream one script | 50 // At the moment, we only use one thread, so we can only stream one script |
| 49 // at a time. FIXME: Use a thread pool and stream multiple scripts. | 51 // at a time. FIXME: Use a thread pool and stream multiple scripts. |
| 50 WTF::OwnPtr<WebThread> m_thread; | 52 WTF::OwnPtr<WebThread> m_thread; |
| 51 bool m_runningTask; | 53 bool m_runningTask; |
| 52 mutable Mutex m_mutex; // Guards m_runningTask. | 54 mutable Mutex m_mutex; // Guards m_runningTask. |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 class ScriptStreamingTask : public WebThread::Task { | |
| 56 WTF_MAKE_NONCOPYABLE(ScriptStreamingTask); | |
| 57 public: | |
| 58 ScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::ScriptStreamingTask>
, ScriptStreamer*); | |
| 59 virtual void run() override; | |
| 60 | |
| 61 private: | |
| 62 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task; | |
| 63 ScriptStreamer* m_streamer; | |
| 64 }; | |
| 65 | |
| 66 | |
| 67 } // namespace blink | 57 } // namespace blink |
| 68 | 58 |
| 69 #endif // ScriptStreamerThread_h | 59 #endif // ScriptStreamerThread_h |
| OLD | NEW |