Commit a2b453d4 authored by loislo@chromium.org's avatar loislo@chromium.org

Revert "[blink-in-js] Migrate resources required for blink-in-js to grd - part 3"

This reverts commit 0ad77c5152a930f08e04a2db05ad5331c711333f.

It breaks compilation on Linux GN (dbg) which is tree closer.
http://build.chromium.org/p/chromium.linux/builders/Linux%20GN%20(dbg)

BUG=312586
TBR= dpranke@chromium.org, haraken@chromium.org, jochen@chromium.org

Review URL: https://codereview.chromium.org/557543004

git-svn-id: svn://svn.chromium.org/blink/trunk@181957 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 17f96580
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "core/PrivateScriptSourcesForTesting.h" #include "core/PrivateScriptSourcesForTesting.h"
#endif #endif
#include "core/dom/ExceptionCode.h" #include "core/dom/ExceptionCode.h"
#include "platform/PlatformResourceLoader.h"
namespace blink { namespace blink {
...@@ -40,10 +39,10 @@ static void dumpV8Message(v8::Handle<v8::Message> message) ...@@ -40,10 +39,10 @@ static void dumpV8Message(v8::Handle<v8::Message> message)
fprintf(stderr, "%s (line %d): %s\n", fileName.utf8().data(), lineNumber, toCoreString(errorMessage).utf8().data()); 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 char* source, size_t size) static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, String scriptClassName, const unsigned char* source, size_t size)
{ {
v8::TryCatch block; v8::TryCatch block;
String sourceString(source, size); String sourceString(reinterpret_cast<const char*>(source), size);
String fileName = scriptClassName + ".js"; String fileName = scriptClassName + ".js";
v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isolate, sourceString), fileName, TextPosition::minimumPosition(), 0, isolate, NotSharableCrossOrigin, V8CacheOptionsOff); v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isolate, sourceString), fileName, TextPosition::minimumPosition(), 0, isolate, NotSharableCrossOrigin, V8CacheOptionsOff);
if (block.HasCaught()) { if (block.HasCaught()) {
...@@ -83,8 +82,7 @@ static void installPrivateScript(v8::Isolate* isolate, String className) ...@@ -83,8 +82,7 @@ static void installPrivateScript(v8::Isolate* isolate, String className)
// by make_private_script_source.py. // by make_private_script_source.py.
for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) { for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) {
if (className == kPrivateScriptSources[index].className) { if (className == kPrivateScriptSources[index].className) {
String resourceData = loadResourceAsASCIIString(kPrivateScriptSources[index].resourceFile); compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].scriptClassName, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size);
compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].scriptClassName, resourceData.utf8().data(), resourceData.length());
compiledScriptCount++; compiledScriptCount++;
} }
} }
...@@ -109,8 +107,7 @@ static v8::Handle<v8::Value> installPrivateScriptRunner(v8::Isolate* isolate) ...@@ -109,8 +107,7 @@ 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()); fprintf(stderr, "Private script error: Target source code was not found. (Class name = %s)\n", className.utf8().data());
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
String resourceData = loadResourceAsASCIIString(kPrivateScriptSources[index].resourceFile); return compileAndRunPrivateScript(isolate, className, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size);
return compileAndRunPrivateScript(isolate, className, resourceData.utf8().data(), resourceData.length());
} }
static v8::Handle<v8::Object> classObjectOfPrivateScript(ScriptState* scriptState, String className) static v8::Handle<v8::Object> classObjectOfPrivateScript(ScriptState* scriptState, String className)
......
...@@ -9,7 +9,6 @@ Usage: ...@@ -9,7 +9,6 @@ Usage:
python make_private_script_source.py DESTINATION_FILE SOURCE_FILES python make_private_script_source.py DESTINATION_FILE SOURCE_FILES
""" """
import optparse
import os import os
import re import re
import sys import sys
...@@ -33,51 +32,34 @@ def extract_partial_interface_name(filename): ...@@ -33,51 +32,34 @@ def extract_partial_interface_name(filename):
def main(): def main():
parser = optparse.OptionParser() output_filename = sys.argv[1]
parser.add_option('--for-testing', action="store_true", default=False) input_filenames = sys.argv[2:]
options, args = parser.parse_args()
output_filename = args[0]
input_filenames = args[1:]
source_name, ext = os.path.splitext(os.path.basename(output_filename)) source_name, ext = os.path.splitext(os.path.basename(output_filename))
contents = [] contents = []
contents.append('#ifndef %s_h\n' % source_name) for input_filename in input_filenames:
contents.append('#define %s_h\n' % source_name) class_name, ext = os.path.splitext(os.path.basename(input_filename))
if options.for_testing: with open(input_filename) as input_file:
for input_filename in input_filenames: input_text = input_file.read()
class_name, ext = os.path.splitext(os.path.basename(input_filename)) hex_values = ['0x{0:02x}'.format(ord(char)) for char in input_text]
with open(input_filename) as input_file: contents.append('const unsigned char kSourceOf%s[] = {\n %s\n};\n\n' % (
input_text = input_file.read() class_name, ', '.join(hex_values)))
hex_values = ['0x{0:02x}'.format(ord(char)) for char in input_text]
contents.append('const char kSourceOf%s[] = {\n %s\n};\n\n' % (
class_name, ', '.join(hex_values)))
contents.append('struct %s {' % source_name) contents.append('struct %s {' % source_name)
contents.append(""" contents.append("""
const char* scriptClassName; const char* scriptClassName;
const char* className; const char* className;
""") const unsigned char* source;
if options.for_testing: size_t size;
contents.append("""
const char* source;
size_t size;""")
else:
contents.append('const char* resourceFile;')
contents.append("""
}; };
""") """)
contents.append('struct %s k%s[] = {\n' % (source_name, source_name)) contents.append('struct %s k%s[] = {\n' % (source_name, source_name))
for input_filename in input_filenames: for input_filename in input_filenames:
script_class_name, ext = os.path.splitext(os.path.basename(input_filename)) script_class_name, ext = os.path.splitext(os.path.basename(input_filename))
class_name = extract_partial_interface_name(input_filename) or script_class_name class_name = extract_partial_interface_name(input_filename) or script_class_name
if options.for_testing: contents.append(' { "%s", "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (script_class_name, class_name, script_class_name, script_class_name))
contents.append(' { "%s", "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (script_class_name, class_name, script_class_name, script_class_name))
else:
contents.append(' { "%s", "%s", "%s.js" },\n' % (script_class_name, class_name, script_class_name))
contents.append('};\n') contents.append('};\n')
contents.append('#endif // %s_h\n' % source_name)
with open(output_filename, 'w') as output_file: with open(output_filename, 'w') as output_file:
output_file.write("".join(contents)) output_file.write("".join(contents))
......
...@@ -183,7 +183,6 @@ ...@@ -183,7 +183,6 @@
'action': [ 'action': [
'python', 'python',
'../build/scripts/make_private_script_source.py', '../build/scripts/make_private_script_source.py',
'--for-testing',
'<@(_outputs)', '<@(_outputs)',
'<@(_private_script_files)' '<@(_private_script_files)'
], ],
......
// 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 "PlatformResourceLoader.h"
#include "public/platform/Platform.h"
#include "public/platform/WebData.h"
namespace blink {
String loadResourceAsASCIIString(const char* resource)
{
const WebData& resourceData = Platform::current()->loadResource(resource);
String dataString(resourceData.data(), resourceData.size());
ASSERT(!dataString.isEmpty() && dataString.containsOnlyASCII());
return dataString;
}
} // namespace blink
// 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.
#ifndef PlatformResourceLoader_h
#define PlatformResourceLoader_h
#include "platform/PlatformExport.h"
#include "wtf/text/WTFString.h"
namespace blink {
PLATFORM_EXPORT String loadResourceAsASCIIString(const char* resource);
} // namespace blink
#endif // PlatformResourceLoader_h
...@@ -91,8 +91,6 @@ ...@@ -91,8 +91,6 @@
'PlatformKeyboardEvent.cpp', 'PlatformKeyboardEvent.cpp',
'PlatformKeyboardEvent.h', 'PlatformKeyboardEvent.h',
'PlatformMouseEvent.h', 'PlatformMouseEvent.h',
'PlatformResourceLoader.cpp',
'PlatformResourceLoader.h',
'PlatformScreen.cpp', 'PlatformScreen.cpp',
'PlatformScreen.h', 'PlatformScreen.h',
'PlatformThreadData.cpp', 'PlatformThreadData.cpp',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment