tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ByteStream.h (1299B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef STREAM_H_
      6 #define STREAM_H_
      7 
      8 #include "DecoderDoctorLogger.h"
      9 #include "nsISupportsImpl.h"
     10 
     11 namespace mozilla {
     12 
     13 DDLoggedTypeDeclName(ByteStream);
     14 
     15 class ByteStream : public DecoderDoctorLifeLogger<ByteStream> {
     16 public:
     17  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ByteStream);
     18 
     19  virtual nsresult ReadAt(int64_t offset, void* data, size_t size,
     20                          size_t* bytes_read) = 0;
     21  virtual nsresult CachedReadAt(int64_t offset, void* data, size_t size,
     22                                size_t* bytes_read) = 0;
     23  virtual bool Length(int64_t* size) = 0;
     24 
     25  virtual void DiscardBefore(int64_t offset) {}
     26 
     27  // If this ByteStream's underlying storage of media is in-memory, this
     28  // function returns a pointer to the in-memory storage of data at offset.
     29  // Note that even if a ByteStream stores data in memory, it may not be
     30  // stored contiguously, in which case this returns nullptr.
     31  virtual const uint8_t* GetContiguousAccess(int64_t aOffset, size_t aSize) {
     32    return nullptr;
     33  }
     34 
     35 protected:
     36  virtual ~ByteStream() = default;
     37 };
     38 
     39 }  // namespace mozilla
     40 
     41 #endif