Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: Source/bindings/core/v8/ScriptStreamer.cpp

Issue 622333002: Flip the true/false result of ScriptState::contextIsValid (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/core/v8/ScriptState.h ('k') | Source/bindings/core/v8/ScriptValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } else if (strcmp(encodingName, "UTF-8") == 0) { 401 } else if (strcmp(encodingName, "UTF-8") == 0) {
402 encoding = v8::ScriptCompiler::StreamedSource::UTF8; 402 encoding = v8::ScriptCompiler::StreamedSource::UTF8;
403 } else { 403 } else {
404 // We don't stream other encodings; especially we don't stream two byte 404 // We don't stream other encodings; especially we don't stream two byte
405 // scripts to avoid the handling of byte order marks. Most scripts are 405 // scripts to avoid the handling of byte order marks. Most scripts are
406 // Latin1 or UTF-8 anyway, so this should be enough for most real world 406 // Latin1 or UTF-8 anyway, so this should be enough for most real world
407 // purposes. 407 // purposes.
408 return false; 408 return false;
409 } 409 }
410 410
411 if (scriptState->contextIsValid()) 411 if (!scriptState->contextIsValid())
412 return false; 412 return false;
413 ScriptState::Scope scope(scriptState); 413 ScriptState::Scope scope(scriptState);
414 414
415 // The Resource might go out of scope if the script is no longer needed. We 415 // The Resource might go out of scope if the script is no longer needed. We
416 // will soon call PendingScript::setStreamer, which makes the PendingScript 416 // will soon call PendingScript::setStreamer, which makes the PendingScript
417 // notify the ScriptStreamer when it is destroyed. 417 // notify the ScriptStreamer when it is destroyed.
418 RefPtr<ScriptStreamer> streamer = adoptRef(new ScriptStreamer(resource, enco ding, scriptType)); 418 RefPtr<ScriptStreamer> streamer = adoptRef(new ScriptStreamer(resource, enco ding, scriptType));
419 419
420 // Decide what kind of cached data we should produce while streaming. By 420 // Decide what kind of cached data we should produce while streaming. By
421 // default, we generate the parser cache for streamed scripts, to emulate 421 // default, we generate the parser cache for streamed scripts, to emulate
422 // the non-streaming behavior (see V8ScriptRunner::compileScript). 422 // the non-streaming behavior (see V8ScriptRunner::compileScript).
423 v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kProd uceParserCache; 423 v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kProd uceParserCache;
424 if (settings->v8CacheOptions() == V8CacheOptionsCode) 424 if (settings->v8CacheOptions() == V8CacheOptionsCode)
425 compileOption = v8::ScriptCompiler::kProduceCodeCache; 425 compileOption = v8::ScriptCompiler::kProduceCodeCache;
426 v8::ScriptCompiler::ScriptStreamingTask* scriptStreamingTask = v8::ScriptCom piler::StartStreamingScript(scriptState->isolate(), &(streamer->m_source), compi leOption); 426 v8::ScriptCompiler::ScriptStreamingTask* scriptStreamingTask = v8::ScriptCom piler::StartStreamingScript(scriptState->isolate(), &(streamer->m_source), compi leOption);
427 if (scriptStreamingTask) { 427 if (scriptStreamingTask) {
428 streamer->m_task = adoptPtr(scriptStreamingTask); 428 streamer->m_task = adoptPtr(scriptStreamingTask);
429 script.setStreamer(streamer.release()); 429 script.setStreamer(streamer.release());
430 return true; 430 return true;
431 } 431 }
432 // Otherwise, V8 cannot stream the script. 432 // Otherwise, V8 cannot stream the script.
433 return false; 433 return false;
434 } 434 }
435 435
436 } // namespace blink 436 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptState.h ('k') | Source/bindings/core/v8/ScriptValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698