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

Unified Diff: Source/web/SuspendableScriptExecutor.cpp

Issue 649183010: Added SuspendableScriptExecutor::createAndRun to replace ctor+run (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@a
Patch Set: Created 6 years, 2 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: Source/web/SuspendableScriptExecutor.cpp
diff --git a/Source/web/SuspendableScriptExecutor.cpp b/Source/web/SuspendableScriptExecutor.cpp
index d59c9aa630be5b66a2688a95e47cd8bde1a4e9a9..84af91a263f08e2d7561dfe9bfc219cbf965779d 100644
--- a/Source/web/SuspendableScriptExecutor.cpp
+++ b/Source/web/SuspendableScriptExecutor.cpp
@@ -14,6 +14,26 @@
namespace blink {
+void SuspendableScriptExecutor::createAndRun(LocalFrame* frame, int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCallback* callback)
+{
+ SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame, worldID, sources, extensionGroup, userGesture, callback);
+ 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();
+ m_callback->completed(Vector<v8::Local<v8::Value> >());
+ delete this;
+}
+
SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCallback* callback)
: ActiveDOMObject(frame->document())
, m_frame(frame)
@@ -38,20 +58,6 @@ void SuspendableScriptExecutor::run()
executeAndDestroySelf();
}
-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();
- m_callback->completed(Vector<v8::Local<v8::Value> >());
- delete this;
-}
-
void SuspendableScriptExecutor::executeAndDestroySelf()
{
// after calling the destructor of object - object will be unsubscribed from

Powered by Google App Engine
This is Rietveld 408576698