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 #include "bindings/core/v8/ScriptStreamerThread.h" | 5 #include "bindings/core/v8/ScriptStreamerThread.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptStreamer.h" | 7 #include "bindings/core/v8/ScriptStreamer.h" |
8 #include "core/inspector/InspectorTraceEvents.h" | 8 #include "core/inspector/InspectorTraceEvents.h" |
9 #include "platform/WebTaskRunner.h" | 9 #include "platform/WebTaskRunner.h" |
10 #include "platform/tracing/TraceEvent.h" | 10 #include "platform/tracing/TraceEvent.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 std::move(task)); | 61 std::move(task)); |
62 } | 62 } |
63 | 63 |
64 void ScriptStreamerThread::taskDone() { | 64 void ScriptStreamerThread::taskDone() { |
65 MutexLocker locker(m_mutex); | 65 MutexLocker locker(m_mutex); |
66 ASSERT(m_runningTask); | 66 ASSERT(m_runningTask); |
67 m_runningTask = false; | 67 m_runningTask = false; |
68 } | 68 } |
69 | 69 |
70 WebThread& ScriptStreamerThread::platformThread() { | 70 WebThread& ScriptStreamerThread::platformThread() { |
71 if (!isRunning()) | 71 if (!isRunning()) { |
72 m_thread = | 72 m_thread = WTF::wrapUnique( |
73 wrapUnique(Platform::current()->createThread("ScriptStreamerThread")); | 73 Platform::current()->createThread("ScriptStreamerThread")); |
| 74 } |
74 return *m_thread; | 75 return *m_thread; |
75 } | 76 } |
76 | 77 |
77 void ScriptStreamerThread::runScriptStreamingTask( | 78 void ScriptStreamerThread::runScriptStreamingTask( |
78 std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> task, | 79 std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> task, |
79 ScriptStreamer* streamer) { | 80 ScriptStreamer* streamer) { |
80 TRACE_EVENT1( | 81 TRACE_EVENT1( |
81 "v8,devtools.timeline", "v8.parseOnBackground", "data", | 82 "v8,devtools.timeline", "v8.parseOnBackground", "data", |
82 InspectorParseScriptEvent::data(streamer->scriptResourceIdentifier(), | 83 InspectorParseScriptEvent::data(streamer->scriptResourceIdentifier(), |
83 streamer->scriptURLString())); | 84 streamer->scriptURLString())); |
84 // Running the task can and will block: SourceStream::GetSomeData will get | 85 // Running the task can and will block: SourceStream::GetSomeData will get |
85 // called and it will block and wait for data from the network. | 86 // called and it will block and wait for data from the network. |
86 task->Run(); | 87 task->Run(); |
87 streamer->streamingCompleteOnBackgroundThread(); | 88 streamer->streamingCompleteOnBackgroundThread(); |
88 MutexLocker locker(*s_mutex); | 89 MutexLocker locker(*s_mutex); |
89 ScriptStreamerThread* thread = shared(); | 90 ScriptStreamerThread* thread = shared(); |
90 if (thread) | 91 if (thread) |
91 thread->taskDone(); | 92 thread->taskDone(); |
92 // If thread is 0, we're shutting down. | 93 // If thread is 0, we're shutting down. |
93 } | 94 } |
94 | 95 |
95 } // namespace blink | 96 } // namespace blink |
OLD | NEW |