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

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

Issue 569063002: Reland [blink-in-js] Migrate resources required for blink-in-js to grd - part 3 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased patch Created 6 years, 3 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 | « no previous file | Source/build/scripts/make_private_script_source.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/PrivateScriptRunner.cpp
diff --git a/Source/bindings/core/v8/PrivateScriptRunner.cpp b/Source/bindings/core/v8/PrivateScriptRunner.cpp
index 1295dbfe00062bb7261278c57f5d951d27ad9c57..e81bf5b25ae0274a0cd1d28f602222d48f06aba9 100644
--- a/Source/bindings/core/v8/PrivateScriptRunner.cpp
+++ b/Source/bindings/core/v8/PrivateScriptRunner.cpp
@@ -15,6 +15,7 @@
#include "core/PrivateScriptSourcesForTesting.h"
#endif
#include "core/dom/ExceptionCode.h"
+#include "platform/PlatformResourceLoader.h"
namespace blink {
@@ -39,10 +40,10 @@ static void dumpV8Message(v8::Handle<v8::Message> message)
fprintf(stderr, "%s (line %d): %s\n", fileName.utf8().data(), lineNumber, toCoreString(errorMessage).utf8().data());
}
-static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, String scriptClassName, const unsigned char* source, size_t size)
+static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, String scriptClassName, const char* source, size_t size)
{
v8::TryCatch block;
- String sourceString(reinterpret_cast<const char*>(source), size);
+ String sourceString(source, size);
String fileName = scriptClassName + ".js";
v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isolate, sourceString), fileName, TextPosition::minimumPosition(), 0, isolate, NotSharableCrossOrigin, V8CacheOptionsOff);
if (block.HasCaught()) {
@@ -82,7 +83,8 @@ static void installPrivateScript(v8::Isolate* isolate, String className)
// by make_private_script_source.py.
for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) {
if (className == kPrivateScriptSources[index].className) {
- compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].scriptClassName, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size);
+ String resourceData = loadResourceAsASCIIString(kPrivateScriptSources[index].resourceFile);
+ compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].scriptClassName, resourceData.utf8().data(), resourceData.length());
compiledScriptCount++;
}
}
@@ -107,7 +109,8 @@ static v8::Handle<v8::Value> installPrivateScriptRunner(v8::Isolate* isolate)
fprintf(stderr, "Private script error: Target source code was not found. (Class name = %s)\n", className.utf8().data());
RELEASE_ASSERT_NOT_REACHED();
}
- return compileAndRunPrivateScript(isolate, className, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size);
+ String resourceData = loadResourceAsASCIIString(kPrivateScriptSources[index].resourceFile);
+ return compileAndRunPrivateScript(isolate, className, resourceData.utf8().data(), resourceData.length());
}
static v8::Handle<v8::Object> classObjectOfPrivateScript(ScriptState* scriptState, String className)
« no previous file with comments | « no previous file | Source/build/scripts/make_private_script_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698