1 /* -*- Mode: C++; tab-width: 8; 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 mozilla_dom_TemporaryFileBlobImpl_h 8 #define mozilla_dom_TemporaryFileBlobImpl_h 9 10 #include "FileBlobImpl.h" 11 12 namespace mozilla { 13 namespace dom { 14 15 // This class is meant to be used by TemporaryIPCBlobParent only. 16 // Don't use it for anything else, please! 17 // Note that CreateInputStream() _must_ be called, and called just once! 18 19 // This class is a BlobImpl because it needs to be sent via IPC using 20 // IPCBlobUtils. 21 class TemporaryFileBlobImpl final : public FileBlobImpl { 22 #ifdef DEBUG 23 bool mInputStreamCreated; 24 #endif 25 26 public: 27 explicit TemporaryFileBlobImpl(nsIFile* aFile, const nsAString& aContentType); 28 29 // Overrides 30 void CreateInputStream(nsIInputStream** aInputStream, 31 ErrorResult& aRv) override; 32 GetBlobImplType(nsAString & aBlobImplType)33 void GetBlobImplType(nsAString& aBlobImplType) const override { 34 aBlobImplType = NS_LITERAL_STRING("TemporaryFileBlobImpl"); 35 } 36 37 protected: 38 ~TemporaryFileBlobImpl(); 39 40 private: 41 already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, 42 const nsAString& aContentType, 43 ErrorResult& aRv) override; 44 }; 45 46 } // namespace dom 47 } // namespace mozilla 48 49 #endif // mozilla_dom_TemporaryFileBlobImpl_h 50