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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 ASSERT(scriptState->contextIsValid()); | 616 ASSERT(scriptState->contextIsValid()); |
617 ScriptResource* resource = script.resource(); | 617 ScriptResource* resource = script.resource(); |
618 if (resource->isLoaded()) { | 618 if (resource->isLoaded()) { |
619 Platform::current()->histogramEnumeration(notStreamingReasonHistogramNam
e(scriptType), AlreadyLoaded, NotStreamingReasonEnd); | 619 Platform::current()->histogramEnumeration(notStreamingReasonHistogramNam
e(scriptType), AlreadyLoaded, NotStreamingReasonEnd); |
620 return false; | 620 return false; |
621 } | 621 } |
622 if (!resource->url().protocolIsInHTTPFamily()) { | 622 if (!resource->url().protocolIsInHTTPFamily()) { |
623 Platform::current()->histogramEnumeration(notStreamingReasonHistogramNam
e(scriptType), NotHTTP, NotStreamingReasonEnd); | 623 Platform::current()->histogramEnumeration(notStreamingReasonHistogramNam
e(scriptType), NotHTTP, NotStreamingReasonEnd); |
624 return false; | 624 return false; |
625 } | 625 } |
626 if (resource->resourceToRevalidate()) { | 626 if (resource->isCacheValidator()) { |
627 Platform::current()->histogramEnumeration(notStreamingReasonHistogramNam
e(scriptType), Reload, NotStreamingReasonEnd); | 627 Platform::current()->histogramEnumeration(notStreamingReasonHistogramNam
e(scriptType), Reload, NotStreamingReasonEnd); |
628 // This happens e.g., during reloads. We're actually not going to load | 628 // This happens e.g., during reloads. We're actually not going to load |
629 // the current Resource of the PendingScript but switch to another | 629 // the current Resource of the PendingScript but switch to another |
630 // Resource -> don't stream. | 630 // Resource -> don't stream. |
631 return false; | 631 return false; |
632 } | 632 } |
633 // We cannot filter out short scripts, even if we wait for the HTTP headers | 633 // We cannot filter out short scripts, even if we wait for the HTTP headers |
634 // to arrive: the Content-Length HTTP header is not sent for chunked | 634 // to arrive: the Content-Length HTTP header is not sent for chunked |
635 // downloads. | 635 // downloads. |
636 | 636 |
637 // Decide what kind of cached data we should produce while streaming. Only | 637 // Decide what kind of cached data we should produce while streaming. Only |
638 // produce parser cache if the non-streaming compile takes advantage of it. | 638 // produce parser cache if the non-streaming compile takes advantage of it. |
639 v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kNoCo
mpileOptions; | 639 v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kNoCo
mpileOptions; |
640 if (settings->v8CacheOptions() == V8CacheOptionsParse) | 640 if (settings->v8CacheOptions() == V8CacheOptionsParse) |
641 compileOption = v8::ScriptCompiler::kProduceParserCache; | 641 compileOption = v8::ScriptCompiler::kProduceParserCache; |
642 | 642 |
643 // The Resource might go out of scope if the script is no longer | 643 // The Resource might go out of scope if the script is no longer |
644 // needed. This makes PendingScript notify the ScriptStreamer when it is | 644 // needed. This makes PendingScript notify the ScriptStreamer when it is |
645 // destroyed. | 645 // destroyed. |
646 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption)); | 646 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption)); |
647 | 647 |
648 return true; | 648 return true; |
649 } | 649 } |
650 | 650 |
651 } // namespace blink | 651 } // namespace blink |
OLD | NEW |