Commit 8068fb06 authored by dpapad's avatar dpapad Committed by Chromium LUCI CQ

PDF Viewer: Use optimize_webui() to speed up initial load time

(CL series step 3/3)
Performance of initial load time is noticeably reduced with this
change. Unfortunately have not been able to get exact measurements,
because DevTools is not available on PDF Viewer's initial load, and
the Performance tab can't be leveraged.

The main PDF Viewer bundle can be split further to a main and lazy
part in a follow up, to reduce initial load time even more. As of
this writing pdf_viewer_wrapper.rollup.js amounts to 263K on Linux
and 291K on CrOS.

Bug: 1163956
Change-Id: Idef64e8c640d81469b643f4c4d231196cbd4d659
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625607Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843717}
parent 8985886d
......@@ -266,8 +266,7 @@ TEST_F(ExtensionUserScriptLoaderTest, ComponentExtensionContentScriptIsLoaded) {
ASSERT_TRUE(base::PathService::Get(chrome::DIR_RESOURCES, &resources_dir));
const base::FilePath extension_path = resources_dir.AppendASCII("pdf");
const base::FilePath resource_path(
FILE_PATH_LITERAL("elements/shared-vars.js"));
const base::FilePath resource_path(FILE_PATH_LITERAL("main.js"));
auto user_script = std::make_unique<UserScript>();
user_script->js_scripts().push_back(std::make_unique<UserScript::File>(
......
......@@ -10,6 +10,7 @@ import("//tools/grit/grit_rule.gni")
import("//tools/grit/preprocess_if_expr.gni")
import("//tools/polymer/html_to_js.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
import("../tools/optimize_webui.gni")
preprocess_folder = "preprocessed"
preprocess_manifest = "preprocessed_manifest.json"
......@@ -23,14 +24,10 @@ preprocess_if_expr("preprocess") {
out_manifest = "$target_gen_dir/$preprocess_manifest"
in_files = [
"bookmark_type.js",
"browser_api.js",
"constants.js",
"controller.js",
"gesture_detector.js",
"index.css",
"index.html",
"local_storage_proxy.js",
"main.js",
"metrics.js",
"navigator.js",
"open_pdf_params_parser.js",
......@@ -45,11 +42,7 @@ preprocess_if_expr("preprocess") {
]
if (is_chromeos) {
in_files += [
"ink_controller.js",
"ink/index.html",
"ink/ink_api.js",
]
in_files += [ "ink_controller.js" ]
}
}
......@@ -91,7 +84,49 @@ preprocess_if_expr("preprocess_generated") {
}
}
if (optimize_webui) {
build_manifest = "build_manifest.json"
optimize_webui("build") {
host = "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"
input = rebase_path("$target_gen_dir/$preprocess_folder", root_build_dir)
js_out_files = [ "pdf_viewer_wrapper.rollup.js" ]
js_module_in_files = [ "pdf_viewer_wrapper.js" ]
out_manifest = "$target_gen_dir/$build_manifest"
deps = [
":preprocess",
":preprocess_generated",
"../../../../ui/webui/resources:preprocess",
]
excludes = [
"browser_api.js",
"chrome://resources/js/cr.m.js",
]
}
}
generate_grd("build_grd") {
input_files = [
"browser_api.js",
"index.css",
"index.html",
"main.js",
]
if (is_chromeos) {
input_files += [
"ink/index.html",
"ink/ink_api.js",
]
}
input_files_base_dir = rebase_path(".", "//")
if (optimize_webui) {
deps = [ ":build" ]
resource_path_rewrites =
[ "pdf_viewer_wrapper.rollup.js|pdf_viewer_wrapper.js" ]
manifest_files = [ "$target_gen_dir/$build_manifest" ]
} else {
deps = [
":preprocess",
":preprocess_generated",
......@@ -100,6 +135,7 @@ generate_grd("build_grd") {
"$target_gen_dir/$preprocess_manifest",
"$target_gen_dir/$preprocess_gen_manifest",
]
}
grd_prefix = "pdf"
out_grd = "$target_gen_dir/resources.grd"
resource_path_prefix = "pdf"
......
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