| 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 e82bc7444530affda32e9db61b3824a6da4bb777..7b09c1df319d8524aec79bc86e792df21365e396 100644
|
| --- a/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
|
| +++ b/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
|
| @@ -129,7 +129,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,
|
| @@ -139,10 +139,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(
|
| @@ -182,6 +181,7 @@ SuspendableScriptExecutor::SuspendableScriptExecutor(
|
| : SuspendableTimer(frame->document(), TaskType::Timer),
|
| m_scriptState(scriptState),
|
| m_callback(callback),
|
| + m_blockingOnload(false),
|
| m_keepAlive(this),
|
| m_executor(executor) {}
|
|
|
| @@ -203,9 +203,23 @@ void SuspendableScriptExecutor::run() {
|
| suspendIfNeeded();
|
| }
|
|
|
| +void SuspendableScriptExecutor::runAsync(bool blockOnload) {
|
| + ExecutionContext* context = getExecutionContext();
|
| + DCHECK(context);
|
| + if (blockOnload) {
|
| + toDocument(getExecutionContext())->incrementLoadEventDelayCount();
|
| + m_blockingOnload = true;
|
| + }
|
| + 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());
|
| @@ -215,6 +229,9 @@ void SuspendableScriptExecutor::executeAndDestroySelf() {
|
| if (!m_scriptState->contextIsValid())
|
| return;
|
|
|
| + if (m_blockingOnload)
|
| + toDocument(getExecutionContext())->decrementLoadEventDelayCount();
|
| +
|
| if (m_callback)
|
| m_callback->completed(results);
|
|
|
|
|