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

Unified Diff: Source/bindings/core/v8/ScheduledActionWithCallback.cpp

Issue 660863002: [DevTools] Added public method for async execution of scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: platform/WebExecuteScriptCallback -> web/WebScriptCallback 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/bindings/core/v8/ScheduledActionWithCallback.cpp
diff --git a/Source/bindings/core/v8/ScheduledActionWithCallback.cpp b/Source/bindings/core/v8/ScheduledActionWithCallback.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..377c23e63bd9152dbef3a1dde010acb3255e8596
--- /dev/null
+++ b/Source/bindings/core/v8/ScheduledActionWithCallback.cpp
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "bindings/core/v8/ScheduledActionWithCallback.h"
+
+#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/ScriptSourceCode.h"
+#include "bindings/core/v8/V8PersistentValueVector.h"
+#include "core/frame/LocalFrame.h"
+#include "platform/Logging.h"
+#include "platform/TraceEvent.h"
+#include "public/platform/WebVector.h"
+#include "public/web/WebScriptCallback.h"
kozyatinskiy1 2014/10/17 08:44:21 For this line presubmit said: You added one or mor
+
+namespace blink {
+
+ScheduledActionWithCallback::ScheduledActionWithCallback(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, WebScriptCallback* callback)
+ : m_worldID(worldID)
+ , m_sources(sources)
+ , m_extensionGroup(extensionGroup)
+ , m_callback(callback)
+{
+}
+
+ScheduledActionWithCallback::~ScheduledActionWithCallback()
+{
+}
+
+void ScheduledActionWithCallback::execute(LocalFrame* frame)
+{
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ Vector<v8::Local<v8::Value> > results;
+ WTF_LOG(Timers, "ScheduledAction::execute %p: executing from sources with callback", this);
+ if (m_worldID) {
+ frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, m_extensionGroup, &results);
+ } else {
+ v8::Local<v8::Value> scriptValue = frame->script().executeScriptInMainWorldAndReturnValue(m_sources.first());
+ results.append(scriptValue);
+ }
+ m_callback->finished(results);
+
+ // The frame might be invalid at this point because JavaScript could have released it.
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698