Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8757)

Unified Diff: chrome/browser/ui/webui/about_ui.cc

Issue 1951363002: Brotli compression used on about credits html file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Guarded Windows include Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/DEPS ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/about_ui.cc
diff --git a/chrome/browser/ui/webui/about_ui.cc b/chrome/browser/ui/webui/about_ui.cc
index 8985b91ff58f3365d4af76296cd37b23d6756a45..2b3f3e67dfc786ca59b6323610f44c460ee3d6fd 100644
--- a/chrome/browser/ui/webui/about_ui.cc
+++ b/chrome/browser/ui/webui/about_ui.cc
@@ -63,6 +63,7 @@
#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"
+#include "third_party/brotli/dec/decode.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
@@ -760,8 +761,25 @@ void AboutUIHTMLSource::StartDataRequest(
idr = IDR_KEYBOARD_UTILS_JS;
#endif
- response = ResourceBundle::GetSharedInstance().GetRawDataResource(
- idr).as_string();
+ base::StringPiece raw_response =
+ ResourceBundle::GetSharedInstance().GetRawDataResource(idr);
+ if (idr == IDR_ABOUT_UI_CREDITS_HTML) {
+ size_t decoded_size;
+ const uint8_t* encoded_response_buffer =
+ reinterpret_cast<const uint8_t*>(raw_response.data());
+ CHECK(BrotliDecompressedSize(raw_response.size(), encoded_response_buffer,
+ &decoded_size));
+
+ // Resizing the response and using it as the buffer Brotli decompresses
+ // into.
+ response.resize(decoded_size);
+ CHECK(BrotliDecompressBuffer(raw_response.size(), encoded_response_buffer,
+ &decoded_size,
+ reinterpret_cast<uint8_t*>(&response[0])) ==
+ BROTLI_RESULT_SUCCESS);
+ } else {
+ response = raw_response.as_string();
+ }
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
} else if (source_name_ == chrome::kChromeUIDiscardsHost) {
response = AboutDiscards(path);
« no previous file with comments | « chrome/browser/ui/webui/DEPS ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698