本文整理汇总了C++中PendingScript::setStreamer方法的典型用法代码示例。如果您正苦于以下问题:C++ PendingScript::setStreamer方法的具体用法?C++ PendingScript::setStreamer怎么用?C++ PendingScript::setStreamer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PendingScript
的用法示例。
在下文中一共展示了PendingScript::setStreamer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startStreamingInternal
bool ScriptStreamer::startStreamingInternal(PendingScript& script, Settings* settings, ScriptState* scriptState, PendingScript::Type scriptType)
{
ASSERT(isMainThread());
if (!settings || !settings->v8ScriptStreamingEnabled())
return false;
if (settings->v8ScriptStreamingMode() == ScriptStreamingModeOnlyAsyncAndDefer
&& scriptType == PendingScript::ParsingBlocking)
return false;
ScriptResource* resource = script.resource();
if (resource->isLoaded())
return false;
if (!resource->url().protocolIsInHTTPFamily())
return false;
if (resource->resourceToRevalidate()) {
// This happens e.g., during reloads. We're actually not going to load
// the current Resource of the PendingScript but switch to another
// Resource -> don't stream.
return false;
}
// We cannot filter out short scripts, even if we wait for the HTTP headers
// to arrive. In general, the web servers don't seem to send the
// Content-Length HTTP header for scripts.
if (!scriptState->contextIsValid())
return false;
// Decide what kind of cached data we should produce while streaming. By
// default, we generate the parser cache for streamed scripts, to emulate
// the non-streaming behavior (see V8ScriptRunner::compileScript).
v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kProduceParserCache;
if (settings->v8CacheOptions() == V8CacheOptionsCode)
compileOption = v8::ScriptCompiler::kProduceCodeCache;
// The Resource might go out of scope if the script is no longer
// needed. This makes PendingScript notify the ScriptStreamer when it is
// destroyed.
script.setStreamer(adoptRef(new ScriptStreamer(resource, scriptType, settings->v8ScriptStreamingMode(), scriptState, compileOption)));
return true;
}