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

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

Issue 847803002: Make ScriptStreamer and dependents Oilpan friendly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nullptr tidying Created 5 years, 11 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
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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
marja 2015/01/22 08:21:57 ... and why is WillBeRawPtr correct? As this is on
haraken 2015/01/22 08:24:50 In oilpan, you don't need to protect it because co
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698