| 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/WebTaskRunner.h" | |
| 11 #include "public/platform/WebThread.h" | 10 #include "public/platform/WebThread.h" |
| 11 #include "wtf/Functional.h" |
| 12 #include "wtf/OwnPtr.h" | 12 #include "wtf/OwnPtr.h" |
| 13 #include "wtf/PassOwnPtr.h" |
| 13 | 14 |
| 14 #include <v8.h> | 15 #include <v8.h> |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 class ScriptStreamer; | 19 class ScriptStreamer; |
| 19 | 20 |
| 20 // A singleton thread for running background tasks for script streaming. | 21 // A singleton thread for running background tasks for script streaming. |
| 21 class CORE_EXPORT ScriptStreamerThread { | 22 class CORE_EXPORT ScriptStreamerThread { |
| 22 USING_FAST_MALLOC(ScriptStreamerThread); | 23 USING_FAST_MALLOC(ScriptStreamerThread); |
| 23 WTF_MAKE_NONCOPYABLE(ScriptStreamerThread); | 24 WTF_MAKE_NONCOPYABLE(ScriptStreamerThread); |
| 24 public: | 25 public: |
| 25 static void init(); | 26 static void init(); |
| 26 static void shutdown(); | 27 static void shutdown(); |
| 27 static ScriptStreamerThread* shared(); | 28 static ScriptStreamerThread* shared(); |
| 28 | 29 |
| 29 void postTask(WebTaskRunner::Task*); | 30 void postTask(WTF::PassOwnPtr<WTF::Closure>); |
| 30 | 31 |
| 31 bool isRunningTask() const | 32 bool isRunningTask() const |
| 32 { | 33 { |
| 33 MutexLocker locker(m_mutex); | 34 MutexLocker locker(m_mutex); |
| 34 return m_runningTask; | 35 return m_runningTask; |
| 35 } | 36 } |
| 36 | 37 |
| 37 void taskDone(); | 38 void taskDone(); |
| 38 | 39 |
| 39 static void runScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::Scrip
tStreamingTask>, ScriptStreamer*); | 40 static void runScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::Scrip
tStreamingTask>, ScriptStreamer*); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 // 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 |
| 53 // 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. |
| 54 WTF::OwnPtr<WebThread> m_thread; | 55 WTF::OwnPtr<WebThread> m_thread; |
| 55 bool m_runningTask; | 56 bool m_runningTask; |
| 56 mutable Mutex m_mutex; // Guards m_runningTask. | 57 mutable Mutex m_mutex; // Guards m_runningTask. |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 } // namespace blink | 60 } // namespace blink |
| 60 | 61 |
| 61 #endif // ScriptStreamerThread_h | 62 #endif // ScriptStreamerThread_h |
| OLD | NEW |