1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef MODULES_WOFF2_RLBOX_WOFF2_SANDBOX_H_ 8 #define MODULES_WOFF2_RLBOX_WOFF2_SANDBOX_H_ 9 10 #include <brotli/decode.h> 11 12 extern "C" { 13 14 // Because RLBox doesn't (yet) cleanly support {size,uint8}_t types on Windows, 15 // we're using unsigned long instead of size_t and char instead of uint8_t. 16 17 // Since RLBox doesn't support C++ APIs, we expose C wrappers for the WOFF2. 18 bool RLBoxConvertWOFF2ToTTF(const char* aData, unsigned long aLength, 19 unsigned long aDecompressedSize, 20 unsigned long* aResultSize, void** aResultOwningStr, 21 char** aResultData); 22 // RLBoxDeleteWOFF2String is used to delete the C++ string allocated by 23 // RLBoxConvertWOFF2ToTTF. 24 void RLBoxDeleteWOFF2String(void** aStr); 25 26 typedef BrotliDecoderResult(BrotliDecompressCallback)( 27 unsigned long aEncodedSize, const char* aEncodedBuffer, 28 unsigned long* aDecodedSize, char* aDecodedBuffer); 29 30 // Callback to the unsandboxed Brotli. 31 32 extern BrotliDecompressCallback* sRLBoxBrotliDecompressCallback; 33 34 void RegisterWOFF2Callback(BrotliDecompressCallback* aCallback); 35 BrotliDecoderResult RLBoxBrotliDecoderDecompress(size_t aEncodedSize, 36 const uint8_t* aEncodedBuffer, 37 size_t* aDecodedSize, 38 uint8_t* aDecodedBuffer); 39 }; 40 41 #endif 42