1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/base/src/ArrayBufferInputStream.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef ArrayBufferInputStream_h 1.10 +#define ArrayBufferInputStream_h 1.11 + 1.12 +#include "nsIArrayBufferInputStream.h" 1.13 +#include "js/Value.h" 1.14 +#include "mozilla/Maybe.h" 1.15 + 1.16 +#define NS_ARRAYBUFFERINPUTSTREAM_CONTRACTID "@mozilla.org/io/arraybuffer-input-stream;1" 1.17 +#define NS_ARRAYBUFFERINPUTSTREAM_CID \ 1.18 +{ /* 3014dde6-aa1c-41db-87d0-48764a3710f6 */ \ 1.19 + 0x3014dde6, \ 1.20 + 0xaa1c, \ 1.21 + 0x41db, \ 1.22 + {0x87, 0xd0, 0x48, 0x76, 0x4a, 0x37, 0x10, 0xf6} \ 1.23 +} 1.24 + 1.25 +class ArrayBufferInputStream : public nsIArrayBufferInputStream { 1.26 +public: 1.27 + ArrayBufferInputStream(); 1.28 + virtual ~ArrayBufferInputStream() {} 1.29 + NS_DECL_ISUPPORTS 1.30 + NS_DECL_NSIARRAYBUFFERINPUTSTREAM 1.31 + NS_DECL_NSIINPUTSTREAM 1.32 + 1.33 +private: 1.34 + mozilla::Maybe<JS::PersistentRooted<JS::Value> > mArrayBuffer; 1.35 + uint8_t* mBuffer; // start of actual buffer 1.36 + uint32_t mBufferLength; // length of slice 1.37 + uint32_t mOffset; // permanent offset from start of actual buffer 1.38 + uint32_t mPos; // offset from start of slice 1.39 + bool mClosed; 1.40 +}; 1.41 + 1.42 +#endif // ArrayBufferInputStream_h