Commit 7402a118 authored by Nidhi Jaju's avatar Nidhi Jaju Committed by Commit Bot

Add WebIDLs for ReadableStreamBYOBRequest and ReadableByteStreamController

This CL adds the WebIDL files and relevant C++ stubs for
the ReadableStreamBYOBRequest and ReadableByteStreamController
classes according the the Streams API Standard[1][2]. This is a follow
on from adding the ReadableStreamBYOBReader WebIDL files in an
effort to add the stubs before implementing readable byte streams.

This feature will be runtime enabled under the flag
"ReadableByteStream".

[1] https://streams.spec.whatwg.org/#rbs-controller-class
[2] https://streams.spec.whatwg.org/#rs-byob-request-class

Bug: 614302
Change-Id: I26b0f91c8ec60e7a0b74581a0d857a2536af27ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517349
Commit-Queue: Nidhi Jaju <nidhijaju@google.com>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824292}
parent 7fb96b4d
......@@ -1025,10 +1025,14 @@ generated_interface_sources_in_core = [
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_radio_node_list.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_range.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_range.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_byte_stream_controller.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_byte_stream_controller.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_byob_reader.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_byob_reader.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_byob_request.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_byob_request.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_default_controller.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_default_controller.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_default_reader.cc",
......
......@@ -483,9 +483,11 @@ static_idl_files_in_core = get_path_info(
"//third_party/blink/renderer/core/streams/byte_length_queuing_strategy.idl",
"//third_party/blink/renderer/core/streams/count_queuing_strategy.idl",
"//third_party/blink/renderer/core/streams/queuing_strategy_init.idl",
"//third_party/blink/renderer/core/streams/readable_byte_stream_controller.idl",
"//third_party/blink/renderer/core/streams/readable_stream.idl",
"//third_party/blink/renderer/core/streams/readable_stream_byob_reader.idl",
"//third_party/blink/renderer/core/streams/readable_stream_byob_read_result.idl",
"//third_party/blink/renderer/core/streams/readable_stream_byob_request.idl",
"//third_party/blink/renderer/core/streams/readable_stream_default_controller.idl",
"//third_party/blink/renderer/core/streams/readable_stream_default_reader.idl",
"//third_party/blink/renderer/core/streams/readable_writable_pair.idl",
......
......@@ -333,8 +333,10 @@ core_interface_idl_files_core_only =
"resize_observer/resize_observer_size.idl",
"streams/byte_length_queuing_strategy.idl",
"streams/count_queuing_strategy.idl",
"streams/readable_byte_stream_controller.idl",
"streams/readable_stream.idl",
"streams/readable_stream_byob_reader.idl",
"streams/readable_stream_byob_request.idl",
"streams/readable_stream_default_controller.idl",
"streams/readable_stream_default_reader.idl",
"streams/transform_stream.idl",
......
......@@ -15,10 +15,14 @@ blink_core_sources_streams = [
"queue_with_sizes.h",
"queuing_strategy_common.cc",
"queuing_strategy_common.h",
"readable_byte_stream_controller.cc",
"readable_byte_stream_controller.h",
"readable_stream.cc",
"readable_stream.h",
"readable_stream_byob_reader.cc",
"readable_stream_byob_reader.h",
"readable_stream_byob_request.cc",
"readable_stream_byob_request.h",
"readable_stream_default_controller.cc",
"readable_stream_default_controller.h",
"readable_stream_default_controller_with_script_scope.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// 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/readable_byte_stream_controller.h"
#include "third_party/blink/renderer/core/streams/readable_stream_byob_request.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.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"
namespace blink {
ReadableStreamBYOBRequest* ReadableByteStreamController::byobRequest(
ExceptionState& exception_state) const {
ThrowUnimplemented(exception_state);
return nullptr;
}
base::Optional<double> ReadableByteStreamController::desiredSize(
ExceptionState& exception_state) const {
ThrowUnimplemented(exception_state);
return base::nullopt;
}
void ReadableByteStreamController::close(ScriptState* script_state,
ExceptionState& exception_state) {
ThrowUnimplemented(exception_state);
return;
}
void ReadableByteStreamController::enqueue(ScriptState* script_state,
NotShared<DOMArrayBufferView> chunk,
ExceptionState& exception_state) {
ThrowUnimplemented(exception_state);
return;
}
void ReadableByteStreamController::error(ScriptState* script_state,
ExceptionState& exception_state) {
ThrowUnimplemented(exception_state);
return;
}
void ReadableByteStreamController::error(ScriptState* script_state,
ScriptValue e,
ExceptionState& exception_state) {
ThrowUnimplemented(exception_state);
return;
}
void ReadableByteStreamController::ThrowUnimplemented(
ExceptionState& exception_state) {
exception_state.ThrowTypeError("unimplemented");
}
} // namespace blink
// Copyright 2020 The Chromium AUthors. All rights reserved.
// 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_CORE_STREAMS_READABLE_BYTE_STREAM_CONTROLLER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READABLE_BYTE_STREAM_CONTROLLER_H_
#include "base/optional.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
namespace blink {
class ExceptionState;
class ScriptState;
class DOMArrayBufferView;
class ReadableStreamBYOBRequest;
class ReadableByteStreamController : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
// https://streams.spec.whatwg.org/#rbs-controller-byob-request
ReadableStreamBYOBRequest* byobRequest(ExceptionState&) const;
// https://streams.spec.whatwg.org/#rbs-controller-desired-size
base::Optional<double> desiredSize(ExceptionState&) const;
// https://streams.spec.whatwg.org/#rbs-controller-close
void close(ScriptState*, ExceptionState&);
// https://streams.spec.whatwg.org/#rbs-controller-enqueue
void enqueue(ScriptState*,
NotShared<DOMArrayBufferView> chunk,
ExceptionState&);
// https://streams.spec.whatwg.org/#rbs-controller-error
void error(ScriptState*, ExceptionState&);
void error(ScriptState*, ScriptValue e, ExceptionState&);
private:
static void ThrowUnimplemented(ExceptionState&);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READABLE_BYTE_STREAM_CONTROLLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://streams.spec.whatwg.org/#rbs-controller-class-definition
[
Exposed=(Window,Worker,Worklet),
RuntimeEnabled=ReadableByteStream
] interface ReadableByteStreamController {
[RaisesException] readonly attribute ReadableStreamBYOBRequest? byobRequest;
[RaisesException] readonly attribute double? desiredSize;
[CallWith=ScriptState, RaisesException] void close();
[CallWith=ScriptState, RaisesException] void enqueue(ArrayBufferView chunk);
[CallWith=ScriptState, RaisesException] void error(optional any e);
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// 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/readable_stream_byob_request.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.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"
namespace blink {
NotShared<DOMArrayBufferView> ReadableStreamBYOBRequest::view(
ExceptionState& exception_state) const {
ThrowUnimplemented(exception_state);
return NotShared<DOMArrayBufferView>();
}
void ReadableStreamBYOBRequest::respond(ScriptState* script_state,
uint64_t bytesWritten,
ExceptionState& exception_state) {
ThrowUnimplemented(exception_state);
return;
}
void ReadableStreamBYOBRequest::respondWithNewView(
ScriptState* script_state,
NotShared<DOMArrayBufferView> view,
ExceptionState& exception_state) {
ThrowUnimplemented(exception_state);
return;
}
void ReadableStreamBYOBRequest::ThrowUnimplemented(
ExceptionState& exception_state) {
exception_state.ThrowTypeError("unimplemented");
}
} // namespace blink
// Copyright 2020 The Chromium AUthors. All rights reserved.
// 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_CORE_STREAMS_READABLE_STREAM_BYOB_REQUEST_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READABLE_STREAM_BYOB_REQUEST_H_
#include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
namespace blink {
class ExceptionState;
class ScriptState;
class DOMArrayBufferView;
class ReadableStreamBYOBRequest : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
// https://streams.spec.whatwg.org/#rs-byob-request-view
NotShared<DOMArrayBufferView> view(ExceptionState&) const;
// https://streams.spec.whatwg.org/#rs-byob-request-respond
void respond(ScriptState*, uint64_t bytesWritten, ExceptionState&);
// https://streams.spec.whatwg.org/#rs-byob-request-respond-with-new-view
void respondWithNewView(ScriptState*,
NotShared<DOMArrayBufferView> view,
ExceptionState&);
private:
static void ThrowUnimplemented(ExceptionState&);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READABLE_STREAM_BYOB_REQUEST_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://streams.spec.whatwg.org/#readablestreambyobrequest
[
Exposed=(Window,Worker,Worklet),
RuntimeEnabled=ReadableByteStream
] interface ReadableStreamBYOBRequest {
[RaisesException] readonly attribute ArrayBufferView? view;
[CallWith=ScriptState, RaisesException] void respond([EnforceRange] unsigned long long bytesWritten);
[CallWith=ScriptState, RaisesException] void respondWithNewView(ArrayBufferView view);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment