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..d87be5e26a3acb5513ef3ca970c19048dafc3d34 100644 |
--- a/ios/chrome/browser/ui/webui/about_ui.cc |
+++ b/ios/chrome/browser/ui/webui/about_ui.cc |
@@ -5,6 +5,7 @@ |
#include "ios/chrome/browser/ui/webui/about_ui.h" |
#include <algorithm> |
+#include <brotli/decode.h> |
marq (ping after 24h)
2016/11/30 09:17:41
I have the same concerns about changing the includ
eustas
2016/12/02 11:49:41
Done.
|
#include <string> |
#include <utility> |
#include <vector> |
@@ -20,7 +21,6 @@ |
#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 "ui/base/device_form_factor.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "url/gurl.h" |
@@ -131,18 +131,19 @@ 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 = |
- 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); |
+ const uint8_t* in = reinterpret_cast<const uint8_t*>(raw_response.data()); |
marq (ping after 24h)
2016/11/30 09:17:41
|in| isn't a suitable variable name, since it does
eustas
2016/12/02 11:49:41
Semantics has changed - now decompression is strea
|
+ size_t available_in = raw_response.size(); |
marq (ping after 24h)
2016/11/30 09:17:41
Likewise, |available_in| isn't a good name here. |
eustas
2016/12/02 11:49:41
Done.
|
+ BrotliDecoderState* decoder = BrotliDecoderCreateInstance(0, 0, 0); |
marq (ping after 24h)
2016/11/30 09:17:41
I find 'BrotliDecoderState' a very counterintuitiv
marq (ping after 24h)
2016/11/30 09:17:41
Please insert inline comments to document the 0 pa
eustas
2016/12/02 11:49:41
Good point. I'll consider renaming this structure
|
+ CHECK(!!decoder); |
+ while (!BrotliDecoderIsFinished(decoder)) { |
+ size_t available_out = 0; |
marq (ping after 24h)
2016/11/30 09:17:41
Is |available_out| really something like |output_b
eustas
2016/12/02 11:49:41
Yup. Fixed.
|
+ CHECK(BrotliDecoderDecompressStream(decoder, &available_in, &in, |
+ &available_out, 0, |
marq (ping after 24h)
2016/11/30 09:17:41
Don't use 0 for null pointers here, either.
eustas
2016/12/02 11:49:41
Done.
|
+ 0) != BROTLI_DECODER_RESULT_ERROR); |
+ const uint8_t* out = BrotliDecoderTakeOutput(decoder, &available_out); |
+ response.insert(response.end(), out, out + available_out); |
+ } |
+ BrotliDecoderDestroyInstance(decoder); |
} else { |
response = raw_response.as_string(); |
} |