Commit 358f2afe authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Compress dino game.

This apparently saves about 90k of size, though it does potentially
make for larger differential updates.

Bug: 958522
Change-Id: Ibcf79739ff6d1cf734aa9649080f5be754d1200e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1597126Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657424}
parent c4358727
......@@ -175,6 +175,7 @@ jumbo_static_library("renderer") {
"//third_party/icu",
"//third_party/re2",
"//third_party/widevine/cdm:buildflags",
"//third_party/zlib/google:compression_utils",
"//ui/surface",
"//v8",
]
......
......@@ -2,5 +2,6 @@ include_rules = [
"+components/error_page/renderer",
"+components/security_interstitials/core",
"+components/security_interstitials/core/common/interfaces",
"+third_party/zlib/google",
"+gin",
]
......@@ -59,6 +59,7 @@
#include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_history_item.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/zlib/google/compression_utils.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "url/gurl.h"
......@@ -381,8 +382,16 @@ LocalizedError::PageState NetErrorHelper::GenerateLocalizedErrorPage(
error_html->clear();
int resource_id = IDR_NET_ERROR_HTML;
const base::StringPiece template_html(
std::string extracted_string;
base::StringPiece template_html(
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
if (ui::ResourceBundle::GetSharedInstance().IsGzipped(resource_id)) {
base::StringPiece compressed_html = template_html;
extracted_string.resize(compression::GetUncompressedSize(compressed_html));
template_html.set(extracted_string.data(), extracted_string.size());
bool success = compression::GzipUncompress(compressed_html, template_html);
DCHECK(success);
}
LocalizedError::PageState page_state = LocalizedError::GetPageState(
error.reason(), error.domain(), error.url(), is_failed_post,
......
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
<include name="IDR_NET_ERROR_HTML" file="../neterror/resources/neterror.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_NET_ERROR_HTML" file="../neterror/resources/neterror.html" flattenhtml="true" type="BINDATA" compress="gzip"/>
</grit-part>
......@@ -46,6 +46,7 @@ source_set("web") {
"//ios/net",
"//ios/web",
"//ios/web/common",
"//third_party/zlib/google:compression_utils",
"//ui/base",
"//url",
]
......
include_rules = [
"+services/identity/public/cpp/manifest.h",
"+third_party/zlib/google",
]
specific_include_rules = {
......
......@@ -17,6 +17,7 @@
#include "ios/chrome/browser/application_context.h"
#import "ios/net/protocol_handler_util.h"
#include "net/base/net_errors.h"
#include "third_party/zlib/google/compression_utils.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/scale_factor.h"
#include "ui/base/webui/jstemplate_builder.h"
......@@ -58,9 +59,17 @@ NSString* GetErrorPage(const GURL& url,
ui::ScaleFactor scale_factor =
ui::ResourceBundle::GetSharedInstance().GetMaxScaleFactor();
const base::StringPiece template_html(
std::string extracted_string;
base::StringPiece template_html(
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
IDR_NET_ERROR_HTML, scale_factor));
if (ui::ResourceBundle::GetSharedInstance().IsGzipped(IDR_NET_ERROR_HTML)) {
base::StringPiece compressed_html = template_html;
extracted_string.resize(compression::GetUncompressedSize(compressed_html));
template_html.set(extracted_string.data(), extracted_string.size());
bool success = compression::GzipUncompress(compressed_html, template_html);
DCHECK(success);
}
if (template_html.empty())
NOTREACHED() << "unable to load template. ID: " << IDR_NET_ERROR_HTML;
return base::SysUTF8ToNSString(webui::GetTemplatesHtml(
......
......@@ -55,6 +55,9 @@ TEST_F(ErrorPageUtilTest, NonPostNonOtrError) {
/*is_post=*/false,
/*is_off_the_record=*/false);
// Make sure gzipped HTML is successfully decompressed.
EXPECT_TRUE([html containsString:@"<head>"]);
EXPECT_TRUE([html containsString:ErrorAsString(ERR_CONNECTION_TIMED_OUT)]);
EXPECT_TRUE([html containsString:kTestUrl]);
EXPECT_TRUE([html containsString:GetNSString(IDS_ERRORPAGES_BUTTON_RELOAD)]);
......@@ -69,6 +72,9 @@ TEST_F(ErrorPageUtilTest, PostNonOtrError) {
/*is_post=*/true,
/*is_off_the_record=*/false);
// Make sure gzipped HTML is successfully decompressed.
EXPECT_TRUE([html containsString:@"<head>"]);
EXPECT_TRUE([html containsString:ErrorAsString(ERR_CONNECTION_TIMED_OUT)]);
EXPECT_TRUE([html containsString:kTestUrl]);
EXPECT_FALSE([html containsString:GetNSString(IDS_ERRORPAGES_BUTTON_RELOAD)]);
......@@ -83,6 +89,9 @@ TEST_F(ErrorPageUtilTest, NonPostOtrError) {
/*is_post=*/false,
/*is_off_the_record=*/true);
// Make sure gzipped HTML is successfully decompressed.
EXPECT_TRUE([html containsString:@"<head>"]);
EXPECT_TRUE([html containsString:ErrorAsString(ERR_CONNECTION_TIMED_OUT)]);
EXPECT_TRUE([html containsString:kTestUrl]);
EXPECT_TRUE([html containsString:GetNSString(IDS_ERRORPAGES_BUTTON_RELOAD)]);
......@@ -97,6 +106,9 @@ TEST_F(ErrorPageUtilTest, PostOtrError) {
/*is_post=*/true,
/*is_off_the_record=*/true);
// Make sure gzipped HTML is successfully decompressed.
EXPECT_TRUE([html containsString:@"<head>"]);
EXPECT_TRUE([html containsString:ErrorAsString(ERR_CONNECTION_TIMED_OUT)]);
EXPECT_TRUE([html containsString:kTestUrl]);
EXPECT_FALSE([html containsString:GetNSString(IDS_ERRORPAGES_BUTTON_RELOAD)]);
......@@ -113,6 +125,9 @@ TEST_F(ErrorPageUtilTest, NoUrlSpec) {
/*is_post=*/false,
/*is_off_the_record=*/false);
// Make sure gzipped HTML is successfully decompressed.
EXPECT_TRUE([html containsString:@"<head>"]);
EXPECT_TRUE([html containsString:ErrorAsString(ERR_CONNECTION_TIMED_OUT)]);
EXPECT_TRUE([html containsString:GetNSString(IDS_ERRORPAGES_BUTTON_RELOAD)]);
}
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