-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
c3f9f43
commit af90c7f
Showing
12 changed files
with
200 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters