#include "content/browser/byte_stream.h"
#include <memory>
#include <set>
#include <utility>
#include "base/containers/circular_deque.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
namespace content {
namespace {
ContentVector;
class ByteStreamReaderImpl;
struct LifetimeFlag : public base::RefCountedThreadSafe<LifetimeFlag> { … };
class ByteStreamWriterImpl : public ByteStreamWriter { … };
class ByteStreamReaderImpl : public ByteStreamReader { … };
ByteStreamWriterImpl::ByteStreamWriterImpl(
scoped_refptr<base::SequencedTaskRunner> task_runner,
scoped_refptr<LifetimeFlag> lifetime_flag,
size_t buffer_size)
: … { … }
ByteStreamWriterImpl::~ByteStreamWriterImpl() { … }
void ByteStreamWriterImpl::SetPeer(
ByteStreamReaderImpl* peer,
scoped_refptr<base::SequencedTaskRunner> peer_task_runner,
scoped_refptr<LifetimeFlag> peer_lifetime_flag) { … }
bool ByteStreamWriterImpl::Write(
scoped_refptr<net::IOBuffer> buffer, size_t byte_count) { … }
void ByteStreamWriterImpl::Flush() { … }
void ByteStreamWriterImpl::Close(int status) { … }
void ByteStreamWriterImpl::RegisterCallback(
base::RepeatingClosure source_callback) { … }
size_t ByteStreamWriterImpl::GetTotalBufferedBytes() const { … }
void ByteStreamWriterImpl::UpdateWindow(
scoped_refptr<LifetimeFlag> lifetime_flag, ByteStreamWriterImpl* target,
size_t bytes_consumed) { … }
void ByteStreamWriterImpl::UpdateWindowInternal(size_t bytes_consumed) { … }
void ByteStreamWriterImpl::PostToPeer(bool complete, int status) { … }
ByteStreamReaderImpl::ByteStreamReaderImpl(
scoped_refptr<base::SequencedTaskRunner> task_runner,
scoped_refptr<LifetimeFlag> lifetime_flag,
size_t buffer_size)
: … { … }
ByteStreamReaderImpl::~ByteStreamReaderImpl() { … }
void ByteStreamReaderImpl::SetPeer(
ByteStreamWriterImpl* peer,
scoped_refptr<base::SequencedTaskRunner> peer_task_runner,
scoped_refptr<LifetimeFlag> peer_lifetime_flag) { … }
ByteStreamReaderImpl::StreamState
ByteStreamReaderImpl::Read(scoped_refptr<net::IOBuffer>* data,
size_t* length) { … }
int ByteStreamReaderImpl::GetStatus() const { … }
void ByteStreamReaderImpl::RegisterCallback(
base::RepeatingClosure sink_callback) { … }
void ByteStreamReaderImpl::TransferData(
scoped_refptr<LifetimeFlag> object_lifetime_flag,
ByteStreamReaderImpl* target,
std::unique_ptr<ContentVector> transfer_buffer,
size_t buffer_size,
bool source_complete,
int status) { … }
void ByteStreamReaderImpl::TransferDataInternal(
std::unique_ptr<ContentVector> transfer_buffer,
size_t buffer_size,
bool source_complete,
int status) { … }
void ByteStreamReaderImpl::MaybeUpdateInput() { … }
}
const int ByteStreamWriter::kFractionBufferBeforeSending = …;
const int ByteStreamReader::kFractionReadBeforeWindowUpdate = …;
ByteStreamReader::~ByteStreamReader() { … }
ByteStreamWriter::~ByteStreamWriter() { … }
void CreateByteStream(
scoped_refptr<base::SequencedTaskRunner> input_task_runner,
scoped_refptr<base::SequencedTaskRunner> output_task_runner,
size_t buffer_size,
std::unique_ptr<ByteStreamWriter>* input,
std::unique_ptr<ByteStreamReader>* output) { … }
}