Commit 12409643 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Uncompress terminal system app assets

In order to save space on rootfs, we will store crosh
and terminal assets gzipped.

This CL allows the data source to serve non-compressed or
gzipped files.  E.g. on a request for
chrome://terminal/js/terminal.js, we first search for
/usr/share/chromeos-assets/crosh_builtin/js/terminal.js,
and serve it if it exists, else we search for
/usr/share/chromeos-assets/crosh_builtin/js/terminal.js.gz
and serve the uncompressed contents.

Bug: 1022250
Change-Id: I3060d86d64b43673ad7c75606083fad2dc3b33fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903170Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713700}
parent ed82a4d0
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "third_party/zlib/google/compression_utils.h"
namespace { namespace {
// TODO(crbug.com/846546): Initially set to load crosh, but change to // TODO(crbug.com/846546): Initially set to load crosh, but change to
...@@ -26,7 +27,15 @@ constexpr char kDefaultMime[] = "text/html"; ...@@ -26,7 +27,15 @@ constexpr char kDefaultMime[] = "text/html";
void ReadFile(const base::FilePath& path, void ReadFile(const base::FilePath& path,
const content::URLDataSource::GotDataCallback& callback) { const content::URLDataSource::GotDataCallback& callback) {
std::string content; std::string content;
// First look for uncompressed resource, then try for gzipped file.
bool result = base::ReadFileToString(path, &content); bool result = base::ReadFileToString(path, &content);
if (!result) {
result =
base::ReadFileToString(base::FilePath(path.value() + ".gz"), &content);
std::string uncompressed;
result = compression::GzipUncompress(content, &uncompressed);
content = std::move(uncompressed);
}
// Allow missing files in <root>/_locales only. // Allow missing files in <root>/_locales only.
DCHECK(result || base::FilePath(kTerminalRoot) DCHECK(result || base::FilePath(kTerminalRoot)
.Append("_locales") .Append("_locales")
......
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