chromium/third_party/blink/renderer/platform/image-decoders/rw_buffer.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_IMAGE_DECODERS_RW_BUFFER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_IMAGE_DECODERS_RW_BUFFER_H_

#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"

namespace blink {

class ROBuffer;

/**
 * Accumulates bytes of memory that are "appended" to it, growing internal
 * storage as needed. The growth is done such that at any time in the writer's
 * thread, an ROBuffer or StreamAsset can be snapped off (and safely passed to
 * another thread). The ROBuffer/StreamAsset snapshot can see the previously
 * stored bytes, but will be unaware of any future writes.
 */
class PLATFORM_EXPORT RWBuffer {};

/**
 * Contains a read-only, thread-sharable block of memory. To access the memory,
 * the caller must instantiate a local iterator, as the memory is stored in 1 or
 * more contiguous blocks.
 */
class PLATFORM_EXPORT ROBuffer : public WTF::ThreadSafeRefCounted<ROBuffer> {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_IMAGE_DECODERS_RW_BUFFER_H_