Skip to content

Commit

Permalink
Introduce WebTransport
Browse files Browse the repository at this point in the history
Expose WebTransport interface so that we can use the interface for
various protocols such as QUIC and HTTP/3. We keep QuicTransport
for some time to make the transition easier.

w3c/webtransport#129

Bug: 1123413
Change-Id: I8a6cc835fa0ae44804b5cb21bf6e5553c371334a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386692
Commit-Queue: Yutaka Hirano <[email protected]>
Reviewed-by: Victor Vasiliev <[email protected]>
Reviewed-by: Adam Rice <[email protected]>
Cr-Commit-Position: refs/heads/master@{#807410}
GitOrigin-RevId: c81edd9d28ec0116464af497c2b202eff5ea61de
  • Loading branch information
yutakahirano authored and copybara-github committed Sep 16, 2020
1 parent c3f9f43 commit af90c7f
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 7 deletions.
19 changes: 12 additions & 7 deletions blink/public/mojom/web_feature/web_feature.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ enum WebFeature {
kApplicationCacheAPISecureOrigin = 1248,
// The above items are available in M50 branch

kCSSAtRuleApply = 1249, // Removed
kCSSAtRuleApply = 1249, // Removed
kCSSSelectorPseudoAny = 1250,
kHTMLLabelElementControlForNonFormAssociatedElement = 1263,
kHTMLMediaElementLoadNetworkEmptyNotPaused = 1265,
Expand Down Expand Up @@ -1943,7 +1943,7 @@ enum WebFeature {
kCSSValueAppearanceMenuListButtonRendered = 2582,
kCSSValueAppearancePushButtonRendered = 2584,
kCSSValueAppearanceSquareButtonRendered = 2586,
kGetComputedStyleForWebkitAppearanceExcludeDevTools = 2588, // M73
kGetComputedStyleForWebkitAppearanceExcludeDevTools = 2588, // M73
kCursorImageLE32x32 = 2589,
kCursorImageGT32x32 = 2590,
kRTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics = 2591,
Expand Down Expand Up @@ -2320,7 +2320,8 @@ enum WebFeature {
kRequestedFileSystemTemporary = 2996,
kRequestedFileSystemPersistent = 2997,
kElementWithLeftwardOrUpwardOverflowDirection_ScrollLeftOrTop = 2998,
kElementWithLeftwardOrUpwardOverflowDirection_ScrollLeftOrTopSetPositive = 2999,
kElementWithLeftwardOrUpwardOverflowDirection_ScrollLeftOrTopSetPositive =
2999,
kXMLHttpRequestSynchronousInMainFrame = 3000,
kXMLHttpRequestSynchronousInCrossOriginSubframe = 3001,
kXMLHttpRequestSynchronousInSameOriginSubframe = 3002,
Expand Down Expand Up @@ -2466,7 +2467,7 @@ enum WebFeature {
kV8Animation_ReplaceState_AttributeGetter = 3140,
kV8Animation_Persist_Method = 3141,
kTaskControllerConstructor = 3142,
kTaskControllerSetPriority= 3143,
kTaskControllerSetPriority = 3143,
kTaskSignalPriority = 3144,
kSchedulerPostTask = 3145,
kV8Animation_Onremove_AttributeGetter = 3146,
Expand Down Expand Up @@ -2757,7 +2758,7 @@ enum WebFeature {
kBluetoothAdvertisingEventName = 3430,
kBluetoothAdvertisingEventAppearance = 3431,
kBluetoothAdvertisingEventTxPower = 3432,
kCrossOriginOpenerPolicyReporting= 3433,
kCrossOriginOpenerPolicyReporting = 3433,
kGamepadId = 3434,
kElementAttachInternals = 3435,
kBluetoothDeviceName = 3436,
Expand All @@ -2783,7 +2784,7 @@ enum WebFeature {
kWebCodecsAudioDecoder = 3456,
kWebCodecsVideoDecoder = 3457,
kWebCodecsVideoEncoder = 3458,
kWebCodecsVideoTrackReader= 3459,
kWebCodecsVideoTrackReader = 3459,
kWebCodecsImageDecoder = 3460,
kBackForwardCacheExperimentHTTPHeader = 3461,
kV8Navigator_OpenTCPSocket_Method = 3462,
Expand All @@ -2796,11 +2797,15 @@ enum WebFeature {
kTimerInstallFromUnload = 3469,
kElementAttachInternalsBeforeConstructor = 3470,
kSMILElementHasRepeatNEventListener = 3471,
// The above items are available in M86 branch.

kWebTransport = 3472,

// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
// Also, run update_use_counter_feature_enum.py in
// chromium/src/tools/metrics/histograms/ to update the UMA mapping.
// TODO(dcheng): Fix https://crbug.com/742517 and use the autogenerated constants.
// TODO(dcheng): Fix https://crbug.com/742517 and use the autogenerated
// constants.
kNumberOfFeatures, // This enum value must be last.
};
2 changes: 2 additions & 0 deletions blink/renderer/bindings/generated_in_modules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,8 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_wake_lock_sentinel.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_wave_shaper_node.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_wave_shaper_node.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_web_transport.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_web_transport.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl2_rendering_context.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl2_rendering_context.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_active_info.cc",
Expand Down
1 change: 1 addition & 0 deletions blink/renderer/bindings/idl_in_modules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/webtransport/receive_stream.idl",
"//third_party/blink/renderer/modules/webtransport/send_stream.idl",
"//third_party/blink/renderer/modules/webtransport/stream_abort_info.idl",
"//third_party/blink/renderer/modules/webtransport/web_transport.idl",
"//third_party/blink/renderer/modules/webtransport/web_transport_close_info.idl",
"//third_party/blink/renderer/modules/webusb/navigator_usb.idl",
"//third_party/blink/renderer/modules/webusb/usb.idl",
Expand Down
2 changes: 2 additions & 0 deletions blink/renderer/modules/webtransport/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ blink_modules_sources("webtransport") {
"receive_stream.h",
"send_stream.cc",
"send_stream.h",
"web_transport.cc",
"web_transport.h",
"web_transport_stream.h",
]
}
Expand Down
1 change: 1 addition & 0 deletions blink/renderer/modules/webtransport/idls.gni
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ modules_idl_files = [
"quic_transport.idl",
"receive_stream.idl",
"send_stream.idl",
"web_transport.idl",
]

modules_dictionary_idl_files = [
Expand Down
27 changes: 27 additions & 0 deletions blink/renderer/modules/webtransport/web_transport.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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/modules/webtransport/web_transport.h"

#include "third_party/blink/renderer/platform/bindings/exception_state.h"

namespace blink {

WebTransport::WebTransport(PassKey, QuicTransport* quic_transport)
: quic_transport_(quic_transport) {}
WebTransport::~WebTransport() = default;

WebTransport* WebTransport::Create(ScriptState* script_state,
const String& url,
QuicTransportOptions* options,
ExceptionState& exception_state) {
QuicTransport* quic_transport =
QuicTransport::Create(script_state, url, options, exception_state);
if (exception_state.HadException()) {
return nullptr;
}
return MakeGarbageCollected<WebTransport>(PassKey(), quic_transport);
}

} // namespace blink
79 changes: 79 additions & 0 deletions blink/renderer/modules/webtransport/web_transport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// 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_MODULES_WEBTRANSPORT_WEB_TRANSPORT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBTRANSPORT_WEB_TRANSPORT_H_

#include "base/util/type_safety/pass_key.h"
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/modules/webtransport/quic_transport.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"

namespace blink {

class ScriptState;

class MODULES_EXPORT WebTransport final
: public ScriptWrappable,
public ActiveScriptWrappable<WebTransport> {
DEFINE_WRAPPERTYPEINFO();

public:
using PassKey = util::PassKey<WebTransport>;
static WebTransport* Create(ScriptState*,
const String& url,
QuicTransportOptions*,
ExceptionState&);

WebTransport(PassKey, QuicTransport*);
~WebTransport() override;

// WebTransport IDL implementation.
ScriptPromise createSendStream(ScriptState* script_state,
ExceptionState& exception_state) {
return quic_transport_->createSendStream(script_state, exception_state);
}
ReadableStream* receiveStreams() { return quic_transport_->receiveStreams(); }

ScriptPromise createBidirectionalStream(ScriptState* script_state,
ExceptionState& exception_state) {
return quic_transport_->createBidirectionalStream(script_state,
exception_state);
}
ReadableStream* receiveBidirectionalStreams() {
return quic_transport_->receiveBidirectionalStreams();
}
WritableStream* sendDatagrams() { return quic_transport_->sendDatagrams(); }
ReadableStream* receiveDatagrams() {
return quic_transport_->receiveDatagrams();
}
void close(const WebTransportCloseInfo* close_info) {
quic_transport_->close(close_info);
}
ScriptPromise ready() { return quic_transport_->ready(); }
ScriptPromise closed() { return quic_transport_->closed(); }

bool HasPendingActivity() const override {
return quic_transport_->HasPendingActivity();
}

void Trace(Visitor* visitor) const override {
visitor->Trace(quic_transport_);
ScriptWrappable::Trace(visitor);
}

ExecutionContext* GetExecutionContext() const {
return quic_transport_->GetExecutionContext();
}

private:
const Member<QuicTransport> quic_transport_;
};

} // namespace blink

#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBTRANSPORT_WEB_TRANSPORT_H_
28 changes: 28 additions & 0 deletions blink/renderer/modules/webtransport/web_transport.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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://wicg.github.io/web-transport/#web-transport
[
ActiveScriptWrappable,
Exposed=(Window,Worker),
RuntimeEnabled=QuicTransport
] interface WebTransport {
[CallWith=ScriptState, RaisesException, MeasureAs=WebTransport] constructor(USVString url, optional QuicTransportOptions options = {});
[CallWith=ScriptState, RaisesException] Promise<SendStream>
createSendStream();
// TODO(ricea): This should probably be changed to an attribute in the
// standard.
ReadableStream receiveStreams();

[CallWith=ScriptState, RaisesException] Promise<BidirectionalStream>
createBidirectionalStream();
ReadableStream receiveBidirectionalStreams();

WritableStream sendDatagrams();
ReadableStream receiveDatagrams();

void close(optional WebTransportCloseInfo closeInfo = {});
readonly attribute Promise<void> ready;
readonly attribute Promise<WebTransportCloseInfo> closed;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3793,6 +3793,18 @@ interface WebSocketStream
getter url
method close
method constructor
interface WebTransport
attribute @@toStringTag
getter closed
getter ready
method close
method constructor
method createBidirectionalStream
method createSendStream
method receiveBidirectionalStreams
method receiveDatagrams
method receiveStreams
method sendDatagrams
interface WindowClient : Client
attribute @@toStringTag
getter focused
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,18 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] getter url
[Worker] method close
[Worker] method constructor
[Worker] interface WebTransport
[Worker] attribute @@toStringTag
[Worker] getter closed
[Worker] getter ready
[Worker] method close
[Worker] method constructor
[Worker] method createBidirectionalStream
[Worker] method createSendStream
[Worker] method receiveBidirectionalStreams
[Worker] method receiveDatagrams
[Worker] method receiveStreams
[Worker] method sendDatagrams
[Worker] interface Worker : EventTarget
[Worker] attribute @@toStringTag
[Worker] getter onerror
Expand Down
12 changes: 12 additions & 0 deletions blink/web_tests/webexposed/global-interface-listing-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11199,6 +11199,18 @@ interface WebSocketStream
getter url
method close
method constructor
interface WebTransport
attribute @@toStringTag
getter closed
getter ready
method close
method constructor
method createBidirectionalStream
method createSendStream
method receiveBidirectionalStreams
method receiveDatagrams
method receiveStreams
method sendDatagrams
interface WheelEvent : MouseEvent
attribute @@toStringTag
attribute DOM_DELTA_LINE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3671,6 +3671,18 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] getter url
[Worker] method close
[Worker] method constructor
[Worker] interface WebTransport
[Worker] attribute @@toStringTag
[Worker] getter closed
[Worker] getter ready
[Worker] method close
[Worker] method constructor
[Worker] method createBidirectionalStream
[Worker] method createSendStream
[Worker] method receiveBidirectionalStreams
[Worker] method receiveDatagrams
[Worker] method receiveStreams
[Worker] method sendDatagrams
[Worker] interface WorkerGlobalScope : EventTarget
[Worker] attribute @@toStringTag
[Worker] getter addressSpace
Expand Down

0 comments on commit af90c7f

Please sign in to comment.