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

Unified Diff: Source/web/SuspendableScriptExecutor.cpp

Issue 869513004: SuspendableScriptExecutor executes code once (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/web/SuspendableScriptExecutor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/SuspendableScriptExecutor.cpp
diff --git a/Source/web/SuspendableScriptExecutor.cpp b/Source/web/SuspendableScriptExecutor.cpp
index 13118aac8071be0c0ce566063326d75baf742a6c..30c23dbaba64d810a433ede10826dbf7d4f3b1de 100644
--- a/Source/web/SuspendableScriptExecutor.cpp
+++ b/Source/web/SuspendableScriptExecutor.cpp
@@ -22,22 +22,17 @@ void SuspendableScriptExecutor::createAndRun(LocalFrame* frame, int worldID, con
executor->run();
}
-void SuspendableScriptExecutor::resume()
-{
- executeAndDestroySelf();
-}
-
void SuspendableScriptExecutor::contextDestroyed()
{
// this method can only be called if the script was not called in run()
// and context remained suspend (method resume has never called)
- ActiveDOMObject::contextDestroyed();
+ SuspendableTimer::contextDestroyed();
m_callback->completed(Vector<v8::Local<v8::Value>>());
deref();
}
SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worldID, const WillBeHeapVector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCallback* callback)
- : ActiveDOMObject(frame->document())
+ : SuspendableTimer(frame->document())
, m_frame(frame)
, m_worldID(worldID)
, m_sources(sources)
@@ -51,13 +46,22 @@ SuspendableScriptExecutor::~SuspendableScriptExecutor()
{
}
+void SuspendableScriptExecutor::fired()
+{
+ executeAndDestroySelf();
+}
+
void SuspendableScriptExecutor::run()
{
- suspendIfNeeded();
ExecutionContext* context = executionContext();
ASSERT(context);
- if (context && !context->activeDOMObjectsAreSuspended())
+ if (!context->activeDOMObjectsAreSuspended()) {
+ suspendIfNeeded();
pfeldman 2015/02/05 13:49:42 Why do you make this call?
kozy 2015/02/05 14:58:26 We can remove it. Removed.
executeAndDestroySelf();
+ } else {
+ startOneShot(0, FROM_HERE);
+ suspendIfNeeded();
+ }
}
void SuspendableScriptExecutor::executeAndDestroySelf()
@@ -86,7 +90,7 @@ void SuspendableScriptExecutor::trace(Visitor* visitor)
visitor->trace(m_frame);
visitor->trace(m_sources);
#endif
- ActiveDOMObject::trace(visitor);
+ SuspendableTimer::trace(visitor);
}
} // namespace blink
« no previous file with comments | « Source/web/SuspendableScriptExecutor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698