Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
|
haraken
2014/08/17 16:05:27
Nit: Use the 3-line copyright.
marja
2014/08/20 11:45:56
Done.
| |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef V8ScriptStreamerThread_h | |
| 27 #define V8ScriptStreamerThread_h | |
| 28 | |
| 29 #include "platform/TaskSynchronizer.h" | |
| 30 #include "public/platform/WebThread.h" | |
| 31 #include "wtf/OwnPtr.h" | |
| 32 | |
| 33 #include <v8.h> | |
| 34 | |
| 35 namespace blink { | |
| 36 | |
| 37 class V8ScriptStreamer; | |
| 38 | |
| 39 // A singleton thread for running background tasks for script streaming. | |
| 40 class V8ScriptStreamerThread { | |
|
haraken
2014/08/17 16:05:27
V8ScriptStreamerThread => ScriptStreamerThread
We
marja
2014/08/20 11:45:56
Done.
| |
| 41 public: | |
| 42 static void init(); | |
| 43 static void shutdown(); | |
| 44 static V8ScriptStreamerThread* shared(); | |
| 45 | |
| 46 void postTask(WebThread::Task*); | |
| 47 | |
| 48 bool isRunningTask() const | |
| 49 { | |
| 50 return m_runningTask; | |
| 51 } | |
| 52 | |
| 53 static void taskDone(void*) | |
| 54 { | |
| 55 shared()->m_runningTask = false; | |
| 56 } | |
| 57 | |
| 58 private: | |
| 59 V8ScriptStreamerThread() | |
| 60 : m_runningTask(false) { } | |
| 61 | |
| 62 bool isRunning() | |
| 63 { | |
| 64 return !!m_thread; | |
| 65 } | |
| 66 | |
| 67 void markAsCompleted(TaskSynchronizer* taskSynchronizer) | |
| 68 { | |
| 69 taskSynchronizer->taskCompleted(); | |
| 70 } | |
| 71 | |
| 72 blink::WebThread& platformThread(); | |
| 73 | |
| 74 // At the moment, we only use one thread, so we can only stream one script | |
| 75 // at a time. TODO(marja): Use a thread pool and stream multiple scripts. | |
|
haraken
2014/08/17 16:05:27
Nit: TODO(marja) => FIXME.
marja
2014/08/20 11:45:56
Done.
| |
| 76 WTF::OwnPtr<blink::WebThread> m_thread; | |
| 77 bool m_runningTask; | |
| 78 }; | |
| 79 | |
| 80 class ScriptStreamingTask : public WebThread::Task { | |
| 81 public: | |
| 82 ScriptStreamingTask(v8::ScriptCompiler::ScriptStreamingTask*, V8ScriptStream er*); | |
| 83 virtual void run() OVERRIDE; | |
| 84 | |
| 85 private: | |
| 86 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_v8Task; | |
| 87 V8ScriptStreamer* m_streamer; | |
| 88 }; | |
| 89 | |
| 90 | |
| 91 } // namespace blink | |
| 92 | |
| 93 #endif // V8ScriptStreamerThread_h | |
| OLD | NEW |