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/ScriptStreamer.h" | 6 #include "bindings/core/v8/ScriptStreamer.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptStreamerThread.h" | 8 #include "bindings/core/v8/ScriptStreamerThread.h" |
9 #include "bindings/core/v8/V8ScriptRunner.h" | 9 #include "bindings/core/v8/V8ScriptRunner.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 { | 209 { |
210 ASSERT(!isMainThread()); | 210 ASSERT(!isMainThread()); |
211 { | 211 { |
212 MutexLocker locker(m_mutex); | 212 MutexLocker locker(m_mutex); |
213 m_queueLeadPosition = m_bookmarkPosition; | 213 m_queueLeadPosition = m_bookmarkPosition; |
214 m_queueTailPosition = m_bookmarkPosition; | 214 m_queueTailPosition = m_bookmarkPosition; |
215 m_dataQueue.clear(); | 215 m_dataQueue.clear(); |
216 } | 216 } |
217 | 217 |
218 // Inform main thread to re-queue the data. | 218 // Inform main thread to re-queue the data. |
219 Platform::current()->mainThread()->postTask( | 219 Platform::current()->mainThread()->taskRunner()->postTask( |
220 FROM_HERE, bind(&SourceStream::fetchDataFromResourceBuffer, this, 0)
); | 220 FROM_HERE, bind(&SourceStream::fetchDataFromResourceBuffer, this, 0)
); |
221 } | 221 } |
222 | 222 |
223 void didFinishLoading() | 223 void didFinishLoading() |
224 { | 224 { |
225 ASSERT(isMainThread()); | 225 ASSERT(isMainThread()); |
226 | 226 |
227 // ResetToBookmark may reset the data queue's 'finished' status, | 227 // ResetToBookmark may reset the data queue's 'finished' status, |
228 // so we may need to re-finish after a ResetToBookmark happened. | 228 // so we may need to re-finish after a ResetToBookmark happened. |
229 // We do this by remembering m_finished, and always checking for it | 229 // We do this by remembering m_finished, and always checking for it |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 void ScriptStreamer::streamingCompleteOnBackgroundThread() | 390 void ScriptStreamer::streamingCompleteOnBackgroundThread() |
391 { | 391 { |
392 ASSERT(!isMainThread()); | 392 ASSERT(!isMainThread()); |
393 { | 393 { |
394 MutexLocker locker(m_mutex); | 394 MutexLocker locker(m_mutex); |
395 m_parsingFinished = true; | 395 m_parsingFinished = true; |
396 } | 396 } |
397 | 397 |
398 // notifyFinished might already be called, or it might be called in the | 398 // notifyFinished might already be called, or it might be called in the |
399 // future (if the parsing finishes earlier because of a parse error). | 399 // future (if the parsing finishes earlier because of a parse error). |
400 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&Scrip
tStreamer::streamingComplete, AllowCrossThreadAccess(this))); | 400 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, threadS
afeBind(&ScriptStreamer::streamingComplete, AllowCrossThreadAccess(this))); |
401 | 401 |
402 // The task might delete ScriptStreamer, so it's not safe to do anything | 402 // The task might delete ScriptStreamer, so it's not safe to do anything |
403 // after posting it. Note that there's no way to guarantee that this | 403 // after posting it. Note that there's no way to guarantee that this |
404 // function has returned before the task is ran - however, we should not | 404 // function has returned before the task is ran - however, we should not |
405 // access the "this" object after posting the task. (Especially, we should | 405 // access the "this" object after posting the task. (Especially, we should |
406 // not be holding the mutex at this point.) | 406 // not be holding the mutex at this point.) |
407 } | 407 } |
408 | 408 |
409 void ScriptStreamer::cancel() | 409 void ScriptStreamer::cancel() |
410 { | 410 { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 640 |
641 // The Resource might go out of scope if the script is no longer | 641 // The Resource might go out of scope if the script is no longer |
642 // needed. This makes PendingScript notify the ScriptStreamer when it is | 642 // needed. This makes PendingScript notify the ScriptStreamer when it is |
643 // destroyed. | 643 // destroyed. |
644 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption)); | 644 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption)); |
645 | 645 |
646 return true; | 646 return true; |
647 } | 647 } |
648 | 648 |
649 } // namespace blink | 649 } // namespace blink |
OLD | NEW |