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

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

Issue 2537133002: Update brotli to v1.0.0-snapshot. (Closed)
Patch Set: Fixed typo Created 4 years 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 | « ios/chrome/browser/ui/webui/BUILD.gn ('k') | net/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/webui/about_ui.cc
diff --git a/ios/chrome/browser/ui/webui/about_ui.cc b/ios/chrome/browser/ui/webui/about_ui.cc
index 420139205cfa3812e9755b70b4d5b59667970c06..176f0b10e51acd5b073a03b67b5b474c59343d78 100644
--- a/ios/chrome/browser/ui/webui/about_ui.cc
+++ b/ios/chrome/browser/ui/webui/about_ui.cc
@@ -20,7 +20,7 @@
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/web/public/url_data_source_ios.h"
#include "net/base/escape.h"
-#include "third_party/brotli/dec/decode.h"
+#include "third_party/brotli/include/brotli/decode.h"
#include "ui/base/device_form_factor.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
@@ -131,18 +131,26 @@ void AboutUIHTMLSource::StartDataRequest(
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 =
+ const uint8_t* next_encoded_byte =
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);
+ size_t input_size_remaining = raw_response.size();
+ BrotliDecoderState* decoder =
+ BrotliDecoderCreateInstance(nullptr /* no custom allocator */,
+ nullptr /* no custom deallocator */,
+ nullptr /* no custom memory handle */);
+ CHECK(!!decoder);
+ while (!BrotliDecoderIsFinished(decoder)) {
+ size_t output_size_remaining = 0;
+ CHECK(BrotliDecoderDecompressStream(
+ decoder, &input_size_remaining, &next_encoded_byte,
+ &output_size_remaining, nullptr,
+ nullptr) != BROTLI_DECODER_RESULT_ERROR);
+ const uint8_t* output_buffer =
+ BrotliDecoderTakeOutput(decoder, &output_size_remaining);
+ response.insert(response.end(), output_buffer,
+ output_buffer + output_size_remaining);
+ }
+ BrotliDecoderDestroyInstance(decoder);
} else {
response = raw_response.as_string();
}
« no previous file with comments | « ios/chrome/browser/ui/webui/BUILD.gn ('k') | net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698