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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ScriptStreamerThread.h" | 6 #include "bindings/core/v8/ScriptStreamerThread.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptStreamer.h" | 8 #include "bindings/core/v8/ScriptStreamer.h" |
9 #include "platform/Task.h" | 9 #include "platform/Task.h" |
10 #include "platform/TraceEvent.h" | 10 #include "platform/TraceEvent.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 platformThread().postTask(FROM_HERE, task); | 63 platformThread().postTask(FROM_HERE, task); |
64 } | 64 } |
65 | 65 |
66 void ScriptStreamerThread::taskDone() | 66 void ScriptStreamerThread::taskDone() |
67 { | 67 { |
68 MutexLocker locker(m_mutex); | 68 MutexLocker locker(m_mutex); |
69 ASSERT(m_runningTask); | 69 ASSERT(m_runningTask); |
70 m_runningTask = false; | 70 m_runningTask = false; |
71 } | 71 } |
72 | 72 |
73 blink::WebThread& ScriptStreamerThread::platformThread() | 73 WebThread& ScriptStreamerThread::platformThread() |
74 { | 74 { |
75 if (!isRunning()) | 75 if (!isRunning()) |
76 m_thread = adoptPtr(blink::Platform::current()->createThread("ScriptStre
amerThread")); | 76 m_thread = adoptPtr(Platform::current()->createThread("ScriptStreamerThr
ead")); |
77 return *m_thread; | 77 return *m_thread; |
78 } | 78 } |
79 | 79 |
80 ScriptStreamingTask::ScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::Scr
iptStreamingTask> task, ScriptStreamer* streamer) | 80 ScriptStreamingTask::ScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::Scr
iptStreamingTask> task, ScriptStreamer* streamer) |
81 : m_v8Task(task), m_streamer(streamer) { } | 81 : m_v8Task(task), m_streamer(streamer) { } |
82 | 82 |
83 void ScriptStreamingTask::run() | 83 void ScriptStreamingTask::run() |
84 { | 84 { |
85 TRACE_EVENT0("v8", "v8.parseOnBackground"); | 85 TRACE_EVENT0("v8", "v8.parseOnBackground"); |
86 // Running the task can and will block: SourceStream::GetSomeData will get | 86 // Running the task can and will block: SourceStream::GetSomeData will get |
87 // called and it will block and wait for data from the network. | 87 // called and it will block and wait for data from the network. |
88 m_v8Task->Run(); | 88 m_v8Task->Run(); |
89 m_streamer->streamingCompleteOnBackgroundThread(); | 89 m_streamer->streamingCompleteOnBackgroundThread(); |
90 MutexLocker locker(*s_mutex); | 90 MutexLocker locker(*s_mutex); |
91 ScriptStreamerThread* thread = ScriptStreamerThread::shared(); | 91 ScriptStreamerThread* thread = ScriptStreamerThread::shared(); |
92 if (thread) | 92 if (thread) |
93 thread->taskDone(); | 93 thread->taskDone(); |
94 // If thread is 0, we're shutting down. | 94 // If thread is 0, we're shutting down. |
95 } | 95 } |
96 | 96 |
97 } // namespace blink | 97 } // namespace blink |
OLD | NEW |