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

Unified Diff: Source/web/WebLocalFrameImpl.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: Added deprecated label for not suspendable execute methods 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
« no previous file with comments | « Source/web/WebLocalFrameImpl.h ('k') | Source/web/WebScriptSource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebLocalFrameImpl.cpp
diff --git a/Source/web/WebLocalFrameImpl.cpp b/Source/web/WebLocalFrameImpl.cpp
index a4cb06f33aadbbafbb21fbbbf09ce342cc0a2aa1..5bd72639e136fde9f9bd5a8fdec81f0b12fdb691 100644
--- a/Source/web/WebLocalFrameImpl.cpp
+++ b/Source/web/WebLocalFrameImpl.cpp
@@ -201,6 +201,7 @@
#include "web/NotificationPermissionClientImpl.h"
#include "web/PageOverlay.h"
#include "web/SharedWorkerRepositoryClientImpl.h"
+#include "web/SuspendableScriptExecutor.h"
#include "web/TextFinder.h"
#include "web/WebDataSourceImpl.h"
#include "web/WebDevToolsAgentPrivate.h"
@@ -278,6 +279,13 @@ static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu
}
}
+static Vector<ScriptSourceCode> createSourcesVector(const WebScriptSource* sourcesIn, unsigned numSources)
+{
+ Vector<ScriptSourceCode> sources;
+ sources.append(sourcesIn, numSources);
+ return sources;
+}
+
WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame* frame)
{
if (!frame)
@@ -706,12 +714,7 @@ void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
RELEASE_ASSERT(worldID > 0);
RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
- Vector<ScriptSourceCode> sources;
- for (unsigned i = 0; i < numSources; ++i) {
- TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startLine), OrdinalNumber::first());
- sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
- }
-
+ Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources);
v8::HandleScope handleScope(toIsolate(frame()));
frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGroup, 0);
}
@@ -783,18 +786,22 @@ v8::Handle<v8::Value> WebLocalFrameImpl::executeScriptAndReturnValue(const WebSc
return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(source.code, source.url, position));
}
+void WebLocalFrameImpl::requestExecuteScriptAndReturnValue(const WebScriptSource& source, bool userGesture, WebScriptExecutionCallback* callback)
+{
+ ASSERT(frame());
+
+ Vector<ScriptSourceCode> sources = createSourcesVector(&source, 1);
+ SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame(), 0, sources, 0, userGesture, callback);
aandrey 2014/10/23 18:02:58 Should anyone create a OwnPtr<SuspendableScriptExe
+ executor->run();
+}
+
void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::Value> >* results)
{
ASSERT(frame());
RELEASE_ASSERT(worldID > 0);
RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
- Vector<ScriptSourceCode> sources;
-
- for (unsigned i = 0; i < numSources; ++i) {
- TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startLine), OrdinalNumber::first());
- sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
- }
+ Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources);
if (results) {
Vector<v8::Local<v8::Value> > scriptResults;
@@ -809,6 +816,17 @@ void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
}
}
+void WebLocalFrameImpl::requestExecuteScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, bool userGesture, WebScriptExecutionCallback* callback)
+{
+ ASSERT(frame());
+ RELEASE_ASSERT(worldID > 0);
+ RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
+
+ Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources);
+ SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame(), worldID, sources, extensionGroup, userGesture, callback);
+ executor->run();
+}
+
v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> argv[])
{
ASSERT(frame());
« no previous file with comments | « Source/web/WebLocalFrameImpl.h ('k') | Source/web/WebScriptSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698