| 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 "platform/TaskSynchronizer.h" | 8 #include "platform/TaskSynchronizer.h" |
| 9 #include "public/platform/WebThread.h" | 9 #include "public/platform/WebThread.h" |
| 10 #include "wtf/OwnPtr.h" | 10 #include "wtf/OwnPtr.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 ScriptStreamerThread() | 37 ScriptStreamerThread() |
| 38 : m_runningTask(false) { } | 38 : m_runningTask(false) { } |
| 39 | 39 |
| 40 bool isRunning() const | 40 bool isRunning() const |
| 41 { | 41 { |
| 42 return !!m_thread; | 42 return !!m_thread; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void markAsCompleted(TaskSynchronizer* taskSynchronizer) | |
| 46 { | |
| 47 taskSynchronizer->taskCompleted(); | |
| 48 } | |
| 49 | |
| 50 blink::WebThread& platformThread(); | 45 blink::WebThread& platformThread(); |
| 51 | 46 |
| 52 // At the moment, we only use one thread, so we can only stream one script | 47 // At the moment, we only use one thread, so we can only stream one script |
| 53 // at a time. FIXME: Use a thread pool and stream multiple scripts. | 48 // at a time. FIXME: Use a thread pool and stream multiple scripts. |
| 54 WTF::OwnPtr<blink::WebThread> m_thread; | 49 WTF::OwnPtr<blink::WebThread> m_thread; |
| 55 bool m_runningTask; | 50 bool m_runningTask; |
| 56 mutable Mutex m_mutex; // Guards m_runningTask. | 51 mutable Mutex m_mutex; // Guards m_runningTask. |
| 57 }; | 52 }; |
| 58 | 53 |
| 59 class ScriptStreamingTask : public WebThread::Task { | 54 class ScriptStreamingTask : public WebThread::Task { |
| 60 WTF_MAKE_NONCOPYABLE(ScriptStreamingTask); | 55 WTF_MAKE_NONCOPYABLE(ScriptStreamingTask); |
| 61 public: | 56 public: |
| 62 ScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::ScriptStreamingTask>
, ScriptStreamer*); | 57 ScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::ScriptStreamingTask>
, ScriptStreamer*); |
| 63 virtual void run() override; | 58 virtual void run() override; |
| 64 | 59 |
| 65 private: | 60 private: |
| 66 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task; | 61 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task; |
| 67 ScriptStreamer* m_streamer; | 62 ScriptStreamer* m_streamer; |
| 68 }; | 63 }; |
| 69 | 64 |
| 70 | 65 |
| 71 } // namespace blink | 66 } // namespace blink |
| 72 | 67 |
| 73 #endif // ScriptStreamerThread_h | 68 #endif // ScriptStreamerThread_h |
| OLD | NEW |