| Index: third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
|
| diff --git a/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp b/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
|
| index fca9bb007f8dcc9ad6a88c7f2f897186584fee1d..3e285770791ffd526f62721ba751bd3af11b29ec 100644
|
| --- a/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
|
| +++ b/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
|
| @@ -130,7 +130,7 @@ Vector<v8::Local<v8::Value>> V8FunctionExecutor::execute(LocalFrame* frame) {
|
|
|
| } // namespace
|
|
|
| -void SuspendableScriptExecutor::createAndRun(
|
| +SuspendableScriptExecutor* SuspendableScriptExecutor::create(
|
| LocalFrame* frame,
|
| int worldID,
|
| const HeapVector<ScriptSourceCode>& sources,
|
| @@ -140,10 +140,9 @@ void SuspendableScriptExecutor::createAndRun(
|
| // toIsolate() here.
|
| ScriptState* scriptState = ScriptState::forWorld(
|
| frame, *DOMWrapperWorld::fromWorldId(toIsolate(frame), worldID));
|
| - SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(
|
| + return new SuspendableScriptExecutor(
|
| frame, scriptState, callback,
|
| new WebScriptExecutor(sources, worldID, userGesture));
|
| - executor->run();
|
| }
|
|
|
| void SuspendableScriptExecutor::createAndRun(
|
| @@ -183,6 +182,7 @@ SuspendableScriptExecutor::SuspendableScriptExecutor(
|
| : SuspendableTimer(frame->document(), TaskType::Timer),
|
| m_scriptState(scriptState),
|
| m_callback(callback),
|
| + m_blockingOption(NonBlocking),
|
| m_keepAlive(this),
|
| m_executor(executor) {}
|
|
|
| @@ -204,9 +204,23 @@ void SuspendableScriptExecutor::run() {
|
| suspendIfNeeded();
|
| }
|
|
|
| +void SuspendableScriptExecutor::runAsync(BlockingOption blocking) {
|
| + ExecutionContext* context = getExecutionContext();
|
| + DCHECK(context);
|
| + m_blockingOption = blocking;
|
| + if (m_blockingOption == OnloadBlocking)
|
| + toDocument(getExecutionContext())->incrementLoadEventDelayCount();
|
| +
|
| + startOneShot(0, BLINK_FROM_HERE);
|
| + suspendIfNeeded();
|
| +}
|
| +
|
| void SuspendableScriptExecutor::executeAndDestroySelf() {
|
| CHECK(m_scriptState->contextIsValid());
|
|
|
| + if (m_callback)
|
| + m_callback->willExecute();
|
| +
|
| ScriptState::Scope scriptScope(m_scriptState.get());
|
| Vector<v8::Local<v8::Value>> results =
|
| m_executor->execute(toDocument(getExecutionContext())->frame());
|
| @@ -216,6 +230,9 @@ void SuspendableScriptExecutor::executeAndDestroySelf() {
|
| if (!m_scriptState->contextIsValid())
|
| return;
|
|
|
| + if (m_blockingOption == OnloadBlocking)
|
| + toDocument(getExecutionContext())->decrementLoadEventDelayCount();
|
| +
|
| if (m_callback)
|
| m_callback->completed(results);
|
|
|
|
|