Commit 916ba1f1 authored by dpapad's avatar dpapad Committed by Commit Bot

Cleanup: Leverage DecompressDataResource in jstemplate_builder.cc

Bug: 1003433
Change-Id: Ib6f675338ddea2c5239325349ce07f2f97c67d96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1838995
Commit-Queue: Dan Beam <dbeam@chromium.org>
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702662}
parent 9784690f
......@@ -38,10 +38,9 @@ void AppendJsonHtml(const base::DictionaryValue* json, std::string* output) {
// Appends the source for load_time_data.js in a script tag.
void AppendLoadTimeData(std::string* output) {
// fetch and cache the pointer of the jstemplate resource source text.
scoped_refptr<base::RefCountedMemory> bytes =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
std::string load_time_data_src =
ui::ResourceBundle::GetSharedInstance().DecompressDataResource(
IDR_WEBUI_JS_LOAD_TIME_DATA);
base::StringPiece load_time_data_src(bytes->front_as<char>(), bytes->size());
if (load_time_data_src.empty()) {
NOTREACHED() << "Unable to get loadTimeData src";
......@@ -49,17 +48,16 @@ void AppendLoadTimeData(std::string* output) {
}
output->append("<script>");
load_time_data_src.AppendToString(output);
output->append(load_time_data_src);
output->append("</script>");
}
// Appends the source for JsTemplates in a script tag.
void AppendJsTemplateSourceHtml(std::string* output) {
// fetch and cache the pointer of the jstemplate resource source text.
scoped_refptr<base::RefCountedMemory> bytes =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
std::string jstemplate_src =
ui::ResourceBundle::GetSharedInstance().DecompressDataResource(
IDR_WEBUI_JSTEMPLATE_JS);
base::StringPiece jstemplate_src(bytes->front_as<char>(), bytes->size());
if (jstemplate_src.empty()) {
NOTREACHED() << "Unable to get jstemplate src";
......@@ -67,7 +65,7 @@ void AppendJsTemplateSourceHtml(std::string* output) {
}
output->append("<script>");
jstemplate_src.AppendToString(output);
output->append(jstemplate_src);
output->append("</script>");
}
......
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