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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp

Issue 1848443008: Simplify ScriptStreamer lifetime handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
index af05dabaaff46777f7c158cf6c5b33703e86b73f..a41ebe3c3097e633d6540f4a1b9c25633b6c8562 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
@@ -17,6 +17,7 @@
#include "platform/ThreadSafeFunctional.h"
#include "platform/TraceEvent.h"
#include "public/platform/WebScheduler.h"
+#include "wtf/Deque.h"
#include "wtf/text/TextEncodingRegistry.h"
namespace blink {
@@ -156,7 +157,7 @@ private:
}
}
- WTF::Deque<std::pair<const uint8_t*, size_t>> m_data;
+ Deque<std::pair<const uint8_t*, size_t>> m_data;
bool m_finished;
Mutex m_mutex;
ThreadCondition m_haveData;
@@ -529,7 +530,7 @@ void ScriptStreamer::notifyAppendData(ScriptResource* resource)
m_source = adoptPtr(new v8::ScriptCompiler::StreamedSource(m_stream, m_encoding));
ScriptState::Scope scope(m_scriptState.get());
- WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> scriptStreamingTask(adoptPtr(v8::ScriptCompiler::StartStreamingScript(m_scriptState->isolate(), m_source.get(), m_compileOptions)));
+ OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> scriptStreamingTask(adoptPtr(v8::ScriptCompiler::StartStreamingScript(m_scriptState->isolate(), m_source.get(), m_compileOptions)));
if (!scriptStreamingTask) {
// V8 cannot stream the script.
suppressStreaming();
@@ -540,10 +541,6 @@ void ScriptStreamer::notifyAppendData(ScriptResource* resource)
return;
}
- // ScriptStreamer needs to stay alive as long as the background task is
- // running. This is taken care of with a manual ref() & deref() pair;
- // the corresponding deref() is in streamingComplete.
- ref();
ScriptStreamerThread::shared()->postTask(threadSafeBind(&ScriptStreamerThread::runScriptStreamingTask, scriptStreamingTask.release(), AllowCrossThreadAccess(this)));
recordStartedStreamingHistogram(m_scriptType, 1);
}
@@ -615,18 +612,13 @@ void ScriptStreamer::streamingComplete()
// needed. In addition, if the streaming is suppressed, the non-streaming
// code path will resume after the resource has loaded, before the
// background task finishes.
- if (m_detached || m_streamingSuppressed) {
- deref();
+ if (m_detached || m_streamingSuppressed)
return;
- }
// We have now streamed the whole script to V8 and it has parsed the
// script. We're ready for the next step: compiling and executing the
// script.
notifyFinishedToClient();
-
- // The background thread no longer holds an implicit reference.
- deref();
}
void ScriptStreamer::notifyFinishedToClient()

Powered by Google App Engine
This is Rietveld 408576698