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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 while (!isFinished()) { | 405 while (!isFinished()) { |
406 ASSERT(!m_parsingFinished); | 406 ASSERT(!m_parsingFinished); |
407 ASSERT(!m_streamingSuppressed); | 407 ASSERT(!m_streamingSuppressed); |
408 m_mainThreadWaitingForParserThread = true; | 408 m_mainThreadWaitingForParserThread = true; |
409 m_parsingFinishedCondition.wait(m_mutex); | 409 m_parsingFinishedCondition.wait(m_mutex); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 // Calling notifyFinishedToClient can result into the upper layers dropping | 413 // Calling notifyFinishedToClient can result into the upper layers dropping |
414 // references to ScriptStreamer. Keep it alive until this function ends. | 414 // references to ScriptStreamer. Keep it alive until this function ends. |
415 RefPtr<ScriptStreamer> protect(this); | 415 RefPtrWillBeRawPtr<ScriptStreamer> protect(this); |
416 | 416 |
417 notifyFinishedToClient(); | 417 notifyFinishedToClient(); |
418 | 418 |
419 if (m_mainThreadWaitingForParserThread) { | 419 if (m_mainThreadWaitingForParserThread) { |
420 ASSERT(m_parsingFinished); | 420 ASSERT(m_parsingFinished); |
421 ASSERT(!m_streamingSuppressed); | 421 ASSERT(!m_streamingSuppressed); |
422 // streamingComplete won't be called, so do the ramp-down work | 422 // streamingComplete won't be called, so do the ramp-down work |
423 // here. | 423 // here. |
424 deref(); | 424 deref(); |
425 } | 425 } |
(...skipping 10 matching lines...) Expand all Loading... |
436 , m_streamingSuppressed(false) | 436 , m_streamingSuppressed(false) |
437 , m_compileOptions(compileOptions) | 437 , m_compileOptions(compileOptions) |
438 , m_scriptState(scriptState) | 438 , m_scriptState(scriptState) |
439 , m_scriptType(scriptType) | 439 , m_scriptType(scriptType) |
440 , m_scriptStreamingMode(mode) | 440 , m_scriptStreamingMode(mode) |
441 , m_mainThreadWaitingForParserThread(false) | 441 , m_mainThreadWaitingForParserThread(false) |
442 , m_encoding(v8::ScriptCompiler::StreamedSource::TWO_BYTE) // Unfortunately
there's no dummy encoding value in the enum; let's use one we don't stream. | 442 , m_encoding(v8::ScriptCompiler::StreamedSource::TWO_BYTE) // Unfortunately
there's no dummy encoding value in the enum; let's use one we don't stream. |
443 { | 443 { |
444 } | 444 } |
445 | 445 |
| 446 ScriptStreamer::~ScriptStreamer() |
| 447 { |
| 448 } |
| 449 |
| 450 void ScriptStreamer::trace(Visitor* visitor) |
| 451 { |
| 452 visitor->trace(m_resource); |
| 453 } |
| 454 |
446 void ScriptStreamer::streamingComplete() | 455 void ScriptStreamer::streamingComplete() |
447 { | 456 { |
448 // The background task is completed; do the necessary ramp-down in the main | 457 // The background task is completed; do the necessary ramp-down in the main |
449 // thread. | 458 // thread. |
450 ASSERT(isMainThread()); | 459 ASSERT(isMainThread()); |
451 | 460 |
452 // It's possible that the corresponding Resource was deleted before V8 | 461 // It's possible that the corresponding Resource was deleted before V8 |
453 // finished streaming. In that case, the data or the notification is not | 462 // finished streaming. In that case, the data or the notification is not |
454 // needed. In addition, if the streaming is suppressed, the non-streaming | 463 // needed. In addition, if the streaming is suppressed, the non-streaming |
455 // code path will resume after the resource has loaded, before the | 464 // code path will resume after the resource has loaded, before the |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // Decide what kind of cached data we should produce while streaming. By | 546 // Decide what kind of cached data we should produce while streaming. By |
538 // default, we generate the parser cache for streamed scripts, to emulate | 547 // default, we generate the parser cache for streamed scripts, to emulate |
539 // the non-streaming behavior (see V8ScriptRunner::compileScript). | 548 // the non-streaming behavior (see V8ScriptRunner::compileScript). |
540 v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kProd
uceParserCache; | 549 v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kProd
uceParserCache; |
541 if (settings->v8CacheOptions() == V8CacheOptionsCode || settings->v8CacheOpt
ions() == V8CacheOptionsCodeCompressed) | 550 if (settings->v8CacheOptions() == V8CacheOptionsCode || settings->v8CacheOpt
ions() == V8CacheOptionsCodeCompressed) |
542 compileOption = v8::ScriptCompiler::kProduceCodeCache; | 551 compileOption = v8::ScriptCompiler::kProduceCodeCache; |
543 | 552 |
544 // The Resource might go out of scope if the script is no longer | 553 // The Resource might go out of scope if the script is no longer |
545 // needed. This makes PendingScript notify the ScriptStreamer when it is | 554 // needed. This makes PendingScript notify the ScriptStreamer when it is |
546 // destroyed. | 555 // destroyed. |
547 script.setStreamer(adoptRef(new ScriptStreamer(resource, scriptType, setting
s->v8ScriptStreamingMode(), scriptState, compileOption))); | 556 script.setStreamer(ScriptStreamer::create(resource, scriptType, settings->v8
ScriptStreamingMode(), scriptState, compileOption)); |
548 | 557 |
549 return true; | 558 return true; |
550 } | 559 } |
551 | 560 |
552 } // namespace blink | 561 } // namespace blink |
OLD | NEW |