| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 MutexLocker locker(m_mutex); | 215 MutexLocker locker(m_mutex); |
| 216 m_queueLeadPosition = m_bookmarkPosition; | 216 m_queueLeadPosition = m_bookmarkPosition; |
| 217 // See comments at m_lengthOfBOM declaration below for why | 217 // See comments at m_lengthOfBOM declaration below for why |
| 218 // we need this here. | 218 // we need this here. |
| 219 m_queueTailPosition = m_bookmarkPosition + m_lengthOfBOM; | 219 m_queueTailPosition = m_bookmarkPosition + m_lengthOfBOM; |
| 220 m_dataQueue.clear(); | 220 m_dataQueue.clear(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 // Inform main thread to re-queue the data. | 223 // Inform main thread to re-queue the data. |
| 224 m_loadingTaskRunner->postTask( | 224 m_loadingTaskRunner->postTask( |
| 225 FROM_HERE, bind(&SourceStream::fetchDataFromResourceBuffer, this, 0)
); | 225 BLINK_FROM_HERE, bind(&SourceStream::fetchDataFromResourceBuffer, th
is, 0)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void didFinishLoading() | 228 void didFinishLoading() |
| 229 { | 229 { |
| 230 ASSERT(isMainThread()); | 230 ASSERT(isMainThread()); |
| 231 | 231 |
| 232 // ResetToBookmark may reset the data queue's 'finished' status, | 232 // ResetToBookmark may reset the data queue's 'finished' status, |
| 233 // so we may need to re-finish after a ResetToBookmark happened. | 233 // so we may need to re-finish after a ResetToBookmark happened. |
| 234 // We do this by remembering m_finished, and always checking for it | 234 // We do this by remembering m_finished, and always checking for it |
| 235 // at the end ot fetchDataFromResourceBuffer. | 235 // at the end ot fetchDataFromResourceBuffer. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 void ScriptStreamer::streamingCompleteOnBackgroundThread() | 418 void ScriptStreamer::streamingCompleteOnBackgroundThread() |
| 419 { | 419 { |
| 420 ASSERT(!isMainThread()); | 420 ASSERT(!isMainThread()); |
| 421 { | 421 { |
| 422 MutexLocker locker(m_mutex); | 422 MutexLocker locker(m_mutex); |
| 423 m_parsingFinished = true; | 423 m_parsingFinished = true; |
| 424 } | 424 } |
| 425 | 425 |
| 426 // notifyFinished might already be called, or it might be called in the | 426 // notifyFinished might already be called, or it might be called in the |
| 427 // future (if the parsing finishes earlier because of a parse error). | 427 // future (if the parsing finishes earlier because of a parse error). |
| 428 m_loadingTaskRunner->postTask(FROM_HERE, threadSafeBind(&ScriptStreamer::str
eamingComplete, AllowCrossThreadAccess(this))); | 428 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ScriptStreame
r::streamingComplete, AllowCrossThreadAccess(this))); |
| 429 | 429 |
| 430 // The task might delete ScriptStreamer, so it's not safe to do anything | 430 // The task might delete ScriptStreamer, so it's not safe to do anything |
| 431 // after posting it. Note that there's no way to guarantee that this | 431 // after posting it. Note that there's no way to guarantee that this |
| 432 // function has returned before the task is ran - however, we should not | 432 // function has returned before the task is ran - however, we should not |
| 433 // access the "this" object after posting the task. (Especially, we should | 433 // access the "this" object after posting the task. (Especially, we should |
| 434 // not be holding the mutex at this point.) | 434 // not be holding the mutex at this point.) |
| 435 } | 435 } |
| 436 | 436 |
| 437 void ScriptStreamer::cancel() | 437 void ScriptStreamer::cancel() |
| 438 { | 438 { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 669 |
| 670 // The Resource might go out of scope if the script is no longer | 670 // The Resource might go out of scope if the script is no longer |
| 671 // needed. This makes PendingScript notify the ScriptStreamer when it is | 671 // needed. This makes PendingScript notify the ScriptStreamer when it is |
| 672 // destroyed. | 672 // destroyed. |
| 673 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption, loadingTaskRunner)); | 673 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption, loadingTaskRunner)); |
| 674 | 674 |
| 675 return true; | 675 return true; |
| 676 } | 676 } |
| 677 | 677 |
| 678 } // namespace blink | 678 } // namespace blink |
| OLD | NEW |