Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | if (typeof Components != "undefined") { |
michael@0 | 8 | throw new Error("This file is meant to be loaded in a worker"); |
michael@0 | 9 | } |
michael@0 | 10 | if (!module || !exports) { |
michael@0 | 11 | throw new Error("Please load this module with require()"); |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | let SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm"); |
michael@0 | 15 | let libxul = new SharedAll.Library("libxul", SharedAll.Constants.Path.libxul); |
michael@0 | 16 | let Type = SharedAll.Type; |
michael@0 | 17 | |
michael@0 | 18 | let Primitives = {}; |
michael@0 | 19 | |
michael@0 | 20 | libxul.declareLazyFFI(Primitives, "compress", |
michael@0 | 21 | "workerlz4_compress", |
michael@0 | 22 | null, |
michael@0 | 23 | /*return*/ Type.size_t, |
michael@0 | 24 | /*const source*/ Type.void_t.in_ptr, |
michael@0 | 25 | /*inputSize*/ Type.size_t, |
michael@0 | 26 | /*dest*/ Type.void_t.out_ptr |
michael@0 | 27 | ); |
michael@0 | 28 | |
michael@0 | 29 | libxul.declareLazyFFI(Primitives, "decompress", |
michael@0 | 30 | "workerlz4_decompress", |
michael@0 | 31 | null, |
michael@0 | 32 | /*return*/ Type.int, |
michael@0 | 33 | /*const source*/ Type.void_t.in_ptr, |
michael@0 | 34 | /*inputSize*/ Type.size_t, |
michael@0 | 35 | /*dest*/ Type.void_t.out_ptr, |
michael@0 | 36 | /*maxOutputSize*/ Type.size_t, |
michael@0 | 37 | /*actualOutputSize*/ Type.size_t.out_ptr |
michael@0 | 38 | ); |
michael@0 | 39 | |
michael@0 | 40 | libxul.declareLazyFFI(Primitives, "maxCompressedSize", |
michael@0 | 41 | "workerlz4_maxCompressedSize", |
michael@0 | 42 | null, |
michael@0 | 43 | /*return*/ Type.size_t, |
michael@0 | 44 | /*inputSize*/ Type.size_t |
michael@0 | 45 | ); |
michael@0 | 46 | |
michael@0 | 47 | module.exports = { |
michael@0 | 48 | get compress() { |
michael@0 | 49 | return Primitives.compress; |
michael@0 | 50 | }, |
michael@0 | 51 | get decompress() { |
michael@0 | 52 | return Primitives.decompress; |
michael@0 | 53 | }, |
michael@0 | 54 | get maxCompressedSize() { |
michael@0 | 55 | return Primitives.maxCompressedSize; |
michael@0 | 56 | } |
michael@0 | 57 | }; |