chromium/third_party/blink/renderer/core/streams/transform_stream.cc

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

#include "third_party/blink/renderer/core/streams/transform_stream.h"

#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/streams/miscellaneous_operations.h"
#include "third_party/blink/renderer/core/streams/promise_handler.h"
#include "third_party/blink/renderer/core/streams/readable_stream.h"
#include "third_party/blink/renderer/core/streams/readable_stream_default_controller.h"
#include "third_party/blink/renderer/core/streams/stream_algorithms.h"
#include "third_party/blink/renderer/core/streams/stream_promise_resolver.h"
#include "third_party/blink/renderer/core/streams/transform_stream_default_controller.h"
#include "third_party/blink/renderer/core/streams/transform_stream_transformer.h"
#include "third_party/blink/renderer/core/streams/writable_stream.h"
#include "third_party/blink/renderer/core/streams/writable_stream_default_controller.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_binding.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"

namespace blink {

// Implements a flush algorithm that delegates to a TransformStreamTransformer.
// This is used when creating a TransformStream from C++.
class TransformStream::FlushAlgorithm final : public StreamAlgorithm {};

// Implements a transform algorithm that delegates to a
// TransformStreamTransformer.
class TransformStream::TransformAlgorithm final : public StreamAlgorithm {};

TransformStream* TransformStream::Create(ScriptState* script_state,
                                         ExceptionState& exception_state) {}

TransformStream* TransformStream::Create(
    ScriptState* script_state,
    ScriptValue transform_stream_transformer,
    ExceptionState& exception_state) {}

TransformStream* TransformStream::Create(
    ScriptState* script_state,
    ScriptValue transform_stream_transformer,
    ScriptValue writable_strategy,
    ExceptionState& exception_state) {}

TransformStream* TransformStream::Create(ScriptState* script_state,
                                         ScriptValue transformer,
                                         ScriptValue writable_strategy,
                                         ScriptValue readable_strategy,
                                         ExceptionState& exception_state) {}

// static
TransformStream* TransformStream::Create(
    ScriptState* script_state,
    TransformStreamTransformer* transformer,
    ExceptionState& exception_state) {}

TransformStream* TransformStream::Create(
    ScriptState* script_state,
    StreamStartAlgorithm* start_algorithm,
    StreamAlgorithm* transform_algorithm,
    StreamAlgorithm* flush_algorithm,
    double writable_high_water_mark,
    StrategySizeAlgorithm* writable_size_algorithm,
    double readable_high_water_mark,
    StrategySizeAlgorithm* readable_size_algorithm,
    ExceptionState& exception_state) {}

// This constructor is only used internally.
TransformStream::TransformStream() = default;

TransformStream::TransformStream(ReadableStream* readable,
                                 WritableStream* writable)
    :{}

ReadableStreamDefaultController* TransformStream::GetReadableController() {}

void TransformStream::Trace(Visitor* visitor) const {}

// Implements the "an algorithm that returns startPromise" step from
// InitializeTransformStream():
// https://streams.spec.whatwg.org/#initialize-transform-stream.
class TransformStream::ReturnStartPromiseAlgorithm final
    : public StreamStartAlgorithm {};

//
// The following algorithms are described as abstract operations in the
// standard, but need to be implemented as classes in C++ so that the data they
// store can be traced by the garbage collector correctly.
//
class TransformStream::DefaultSinkWriteAlgorithm final
    : public StreamAlgorithm {};

class TransformStream::DefaultSinkAbortAlgorithm final
    : public StreamAlgorithm {};

class TransformStream::DefaultSinkCloseAlgorithm final
    : public StreamAlgorithm {};

class TransformStream::DefaultSourcePullAlgorithm final
    : public StreamAlgorithm {};

// This algorithm isn't explicitly named in the standard, but instead is
// described by a step in InitializeTransformStream.
class TransformStream::DefaultSourceCancelAlgorithm final
    : public StreamAlgorithm {};

// This is split out from the constructor in this implementation as calling
// JavaScript from inside a C++ constructor can cause GC problems.
void TransformStream::InitInternal(ScriptState* script_state,
                                   ScriptValue raw_transformer,
                                   ScriptValue raw_writable_strategy,
                                   ScriptValue raw_readable_strategy,
                                   ExceptionState& exception_state) {}

void TransformStream::Initialize(ScriptState* script_state,
                                 TransformStream* stream,
                                 StreamPromiseResolver* start_promise,
                                 double writable_high_water_mark,
                                 StrategySizeAlgorithm* writable_size_algorithm,
                                 double readable_high_water_mark,
                                 StrategySizeAlgorithm* readable_size_algorithm,
                                 ExceptionState& exception_state) {}

void TransformStream::Error(ScriptState* script_state,
                            TransformStream* stream,
                            v8::Local<v8::Value> e) {}

void TransformStream::ErrorWritableAndUnblockWrite(ScriptState* script_state,
                                                   TransformStream* stream,
                                                   v8::Local<v8::Value> e) {}

void TransformStream::SetBackpressure(ScriptState* script_state,
                                      TransformStream* stream,
                                      bool backpressure) {}

}  // namespace blink