Commit 8d3376a0 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Merge WebSocketHandleImpl into WebSocketChannelImpl

In the past we wanted to separate IPC stuff from other parts and that's
why WebSocketHandle[Impl] was created, but with mojo we don't need the
separation.

Bug: 977912
Change-Id: I35dd04c17ef4df8e0122ac0490696c255b5c1192
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773010
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692150}
parent f34bc8a5
...@@ -21,10 +21,6 @@ blink_modules_sources("websockets") { ...@@ -21,10 +21,6 @@ blink_modules_sources("websockets") {
"websocket_channel_impl.h", "websocket_channel_impl.h",
"websocket_common.cc", "websocket_common.cc",
"websocket_common.h", "websocket_common.h",
"websocket_handle.h",
"websocket_handle_client.h",
"websocket_handle_impl.cc",
"websocket_handle_impl.h",
"websocket_message_chunk_accumulator.cc", "websocket_message_chunk_accumulator.cc",
"websocket_message_chunk_accumulator.h", "websocket_message_chunk_accumulator.h",
"websocket_stream.cc", "websocket_stream.cc",
......
include_rules = [ include_rules = [
"+mojo/public/cpp/bindings", "+mojo/public/cpp/bindings",
"+mojo/public/cpp/system",
"-third_party/blink/renderer/modules", "-third_party/blink/renderer/modules",
"+third_party/blink/renderer/modules/event_modules.h", "+third_party/blink/renderer/modules/event_modules.h",
"+third_party/blink/renderer/modules/event_target_modules.h", "+third_party/blink/renderer/modules/event_target_modules.h",
......
...@@ -36,12 +36,17 @@ ...@@ -36,12 +36,17 @@
#include <utility> #include <utility>
#include "base/containers/span.h" #include "base/containers/span.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/simple_watcher.h"
#include "services/network/public/mojom/websocket.mojom-blink.h" #include "services/network/public/mojom/websocket.mojom-blink.h"
#include "third_party/blink/public/mojom/websockets/websocket_connector.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h" #include "third_party/blink/renderer/bindings/core/v8/source_location.h"
#include "third_party/blink/renderer/core/fileapi/blob.h" #include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/modules/websockets/websocket_channel.h" #include "third_party/blink/renderer/modules/websockets/websocket_channel.h"
#include "third_party/blink/renderer/modules/websockets/websocket_handle.h"
#include "third_party/blink/renderer/modules/websockets/websocket_message_chunk_accumulator.h" #include "third_party/blink/renderer/modules/websockets/websocket_message_chunk_accumulator.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h" #include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h"
...@@ -61,7 +66,12 @@ class WebSocketHandshakeThrottle; ...@@ -61,7 +66,12 @@ class WebSocketHandshakeThrottle;
// This is an implementation of WebSocketChannel. This is created on the main // This is an implementation of WebSocketChannel. This is created on the main
// thread for Document, or on the worker thread for WorkerGlobalScope. All // thread for Document, or on the worker thread for WorkerGlobalScope. All
// functions must be called on the execution context's thread. // functions must be called on the execution context's thread.
class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel { class MODULES_EXPORT WebSocketChannelImpl final
: public WebSocketChannel,
public network::mojom::blink::WebSocketHandshakeClient,
public network::mojom::blink::WebSocketClient {
USING_PRE_FINALIZER(WebSocketChannelImpl, Dispose);
public: public:
// You can specify the source file and the line number information // You can specify the source file and the line number information
// explicitly by passing the last parameter. // explicitly by passing the last parameter.
...@@ -78,8 +88,7 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel { ...@@ -78,8 +88,7 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel {
WebSocketChannelImpl(ExecutionContext*, WebSocketChannelImpl(ExecutionContext*,
WebSocketChannelClient*, WebSocketChannelClient*,
std::unique_ptr<SourceLocation>, std::unique_ptr<SourceLocation>);
std::unique_ptr<WebSocketHandle>);
~WebSocketChannelImpl() override; ~WebSocketChannelImpl() override;
// WebSocketChannel functions. // WebSocketChannel functions.
...@@ -101,59 +110,45 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel { ...@@ -101,59 +110,45 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel {
void ApplyBackpressure() override; void ApplyBackpressure() override;
void RemoveBackpressure() override; void RemoveBackpressure() override;
ExecutionContext* GetExecutionContext(); // network::mojom::blink::WebSocketHandshakeClient methods:
void OnOpeningHandshakeStarted(
network::mojom::blink::WebSocketHandshakeRequestPtr) override;
void OnResponseReceived(
network::mojom::blink::WebSocketHandshakeResponsePtr) override;
void OnConnectionEstablished(
mojo::PendingRemote<network::mojom::blink::WebSocket> websocket,
mojo::PendingReceiver<network::mojom::blink::WebSocketClient>
client_receiver,
const String& selected_protocol,
const String& extensions,
mojo::ScopedDataPipeConsumerHandle readable) override;
// network::mojom::blink::WebSocketClient methods:
void OnDataFrame(bool fin,
network::mojom::blink::WebSocketMessageType,
uint64_t data_length) override;
void AddSendFlowControlQuota(int64_t quota) override;
void OnDropChannel(bool was_clean,
uint16_t code,
const String& reason) override;
void OnClosingHandshake() override;
// Called when the handle is opened. ExecutionContext* GetExecutionContext();
void DidConnect(WebSocketHandle* handle,
const String& selected_protocol,
const String& extensions);
// Called when the browser starts the opening handshake.
// This notification can be omitted when the inspector is not active.
void DidStartOpeningHandshake(
WebSocketHandle*,
network::mojom::blink::WebSocketHandshakeRequestPtr);
// Called when the browser finishes the opening handshake.
// This notification precedes didConnect.
// This notification can be omitted when the inspector is not active.
void DidFinishOpeningHandshake(
WebSocketHandle*,
network::mojom::blink::WebSocketHandshakeResponsePtr);
// Called when the browser is required to fail the connection.
// |message| can be displayed in the inspector, but should not be passed
// to scripts.
// This message also implies that channel is closed with
// (wasClean = false, code = 1006, reason = "") and
// |handle| becomes unavailable.
void DidFail(WebSocketHandle*, const String& message);
// Called when data are received.
void DidReceiveData(WebSocketHandle*,
bool fin,
WebSocketHandle::MessageType,
const char* data,
size_t);
bool HasBackPressureToReceiveData() { return backpressure_; }
// Called when the handle is closed.
// |handle| becomes unavailable once this notification arrives.
void DidClose(WebSocketHandle* handle,
bool was_clean,
uint16_t code,
const String& reason);
void AddSendFlowControlQuota(WebSocketHandle*, int64_t quota);
// Called when the browser receives a Close frame from the remote
// server. Not called when the renderer initiates the closing handshake.
void DidStartClosingHandshake(WebSocketHandle*);
bool IsHandleAlive() const { return handle_.get(); }
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
private: private:
struct DataFrame final {
DataFrame(bool fin,
network::mojom::blink::WebSocketMessageType type,
uint32_t data_length)
: fin(fin), type(type), data_length(data_length) {}
bool fin;
network::mojom::blink::WebSocketMessageType type;
uint32_t data_length;
};
friend class WebSocketChannelImplHandshakeThrottleTest; friend class WebSocketChannelImplHandshakeThrottleTest;
FRIEND_TEST_ALL_PREFIXES(WebSocketChannelImplHandshakeThrottleTest, FRIEND_TEST_ALL_PREFIXES(WebSocketChannelImplHandshakeThrottleTest,
ThrottleSucceedsFirst); ThrottleSucceedsFirst);
...@@ -180,15 +175,31 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel { ...@@ -180,15 +175,31 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel {
Vector<char> data; Vector<char> data;
}; };
void SendInternal(WebSocketHandle::MessageType, // The state is defined to see the conceptual state more clearly than checking
// various members (for DCHECKs for example). This is only used internally.
enum class State {
// The channel is running an opening handshake. This is the initial state.
// It becomes |kOpen| when the connection is established. It becomes
// |kDisconnected| when detecting an error.
kConnecting,
// The channel is ready to send / receive messages. It becomes
// |kDisconnected| when the connection is closed or when an error happens.
kOpen,
// The channel is not ready for communication. The channel stays in this
// state forever.
kDisconnected,
};
State GetState() const;
void SendInternal(network::mojom::blink::WebSocketMessageType,
const char* data, const char* data,
wtf_size_t total_size, wtf_size_t total_size,
uint64_t* consumed_buffered_amount); uint64_t* consumed_buffered_amount);
void SendAndAdjustQuota(bool final, void SendAndAdjustQuota(bool final,
WebSocketHandle::MessageType, network::mojom::blink::WebSocketMessageType,
base::span<const char>, base::span<const char>,
uint64_t* consumed_buffered_amount); uint64_t* consumed_buffered_amount);
bool MaybeSendSynchronously(WebSocketHandle::MessageType, bool MaybeSendSynchronously(network::mojom::blink::WebSocketMessageType,
base::span<const char>); base::span<const char>);
void ProcessSendQueue(); void ProcessSendQueue();
void FailAsError(const String& reason) { void FailAsError(const String& reason) {
...@@ -210,13 +221,19 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel { ...@@ -210,13 +221,19 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel {
BaseFetchContext* GetBaseFetchContext() const; BaseFetchContext* GetBaseFetchContext() const;
// |handle_| is a handle of the connection. // Called when |readable_| becomes readable.
// |handle_| == nullptr means this channel is closed. void OnReadable(MojoResult result, const mojo::HandleSignalsState& state);
std::unique_ptr<WebSocketHandle> handle_; void ConsumePendingDataFrames();
void ConsumeDataFrame(bool fin,
// |client_| can be deleted while this channel is alive, but this class network::mojom::blink::WebSocketMessageType type,
// expects that disconnect() is called before the deletion. const char* data,
Member<WebSocketChannelClient> client_; size_t data_size);
void OnConnectionError(const base::Location& set_from,
uint32_t custom_reason,
const std::string& description);
void Dispose();
const Member<WebSocketChannelClient> client_;
KURL url_; KURL url_;
uint64_t identifier_; uint64_t identifier_;
Member<BlobLoader> blob_loader_; Member<BlobLoader> blob_loader_;
...@@ -227,6 +244,7 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel { ...@@ -227,6 +244,7 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel {
bool backpressure_ = false; bool backpressure_ = false;
bool receiving_message_type_is_text_ = false; bool receiving_message_type_is_text_ = false;
bool throttle_passed_ = false; bool throttle_passed_ = false;
bool has_initiated_opening_handshake_ = false;
uint64_t sending_quota_ = 0; uint64_t sending_quota_ = 0;
wtf_size_t sent_size_of_top_message_ = 0; wtf_size_t sent_size_of_top_message_ = 0;
FrameScheduler::SchedulingAffectingFeatureHandle FrameScheduler::SchedulingAffectingFeatureHandle
...@@ -239,6 +257,15 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel { ...@@ -239,6 +257,15 @@ class MODULES_EXPORT WebSocketChannelImpl final : public WebSocketChannel {
// throttle response when DidConnect is called. // throttle response when DidConnect is called.
std::unique_ptr<ConnectInfo> connect_info_; std::unique_ptr<ConnectInfo> connect_info_;
mojo::Remote<network::mojom::blink::WebSocket> websocket_;
mojo::Receiver<network::mojom::blink::WebSocketHandshakeClient>
handshake_client_receiver_{this};
mojo::Receiver<network::mojom::blink::WebSocketClient> client_receiver_;
mojo::ScopedDataPipeConsumerHandle readable_;
mojo::SimpleWatcher readable_watcher_;
WTF::Deque<DataFrame> pending_data_frames_;
const scoped_refptr<base::SingleThreadTaskRunner> file_reading_task_runner_; const scoped_refptr<base::SingleThreadTaskRunner> file_reading_task_runner_;
}; };
......
...@@ -1354,9 +1354,9 @@ TEST_F(WebSocketChannelImplHandshakeThrottleTest, FailDuringThrottle) { ...@@ -1354,9 +1354,9 @@ TEST_F(WebSocketChannelImplHandshakeThrottleTest, FailDuringThrottle) {
{ {
InSequence s; InSequence s;
EXPECT_CALL(*raw_handshake_throttle_, ThrottleHandshake(_, _)); EXPECT_CALL(*raw_handshake_throttle_, ThrottleHandshake(_, _));
EXPECT_CALL(*raw_handshake_throttle_, Destructor());
EXPECT_CALL(*ChannelClient(), DidError()); EXPECT_CALL(*ChannelClient(), DidError());
EXPECT_CALL(*ChannelClient(), DidClose(_, _, _)); EXPECT_CALL(*ChannelClient(), DidClose(_, _, _));
EXPECT_CALL(*raw_handshake_throttle_, Destructor());
EXPECT_CALL(checkpoint, Call(1)); EXPECT_CALL(checkpoint, Call(1));
} }
...@@ -1375,9 +1375,9 @@ TEST_F(WebSocketChannelImplHandshakeThrottleTest, ...@@ -1375,9 +1375,9 @@ TEST_F(WebSocketChannelImplHandshakeThrottleTest,
{ {
InSequence s; InSequence s;
EXPECT_CALL(*raw_handshake_throttle_, ThrottleHandshake(_, _)); EXPECT_CALL(*raw_handshake_throttle_, ThrottleHandshake(_, _));
EXPECT_CALL(*raw_handshake_throttle_, Destructor());
EXPECT_CALL(*ChannelClient(), DidError()); EXPECT_CALL(*ChannelClient(), DidError());
EXPECT_CALL(*ChannelClient(), DidClose(_, _, _)); EXPECT_CALL(*ChannelClient(), DidClose(_, _, _));
EXPECT_CALL(*raw_handshake_throttle_, Destructor());
EXPECT_CALL(checkpoint, Call(1)); EXPECT_CALL(checkpoint, Call(1));
} }
...@@ -1485,9 +1485,9 @@ TEST_F(WebSocketChannelImplHandshakeThrottleTest, ConnectFailBeforeThrottle) { ...@@ -1485,9 +1485,9 @@ TEST_F(WebSocketChannelImplHandshakeThrottleTest, ConnectFailBeforeThrottle) {
{ {
InSequence s; InSequence s;
EXPECT_CALL(*raw_handshake_throttle_, ThrottleHandshake(_, _)); EXPECT_CALL(*raw_handshake_throttle_, ThrottleHandshake(_, _));
EXPECT_CALL(*raw_handshake_throttle_, Destructor());
EXPECT_CALL(*ChannelClient(), DidError()); EXPECT_CALL(*ChannelClient(), DidError());
EXPECT_CALL(*ChannelClient(), DidClose(_, _, _)); EXPECT_CALL(*ChannelClient(), DidClose(_, _, _));
EXPECT_CALL(*raw_handshake_throttle_, Destructor());
} }
ASSERT_TRUE(Channel()->Connect(url(), "")); ASSERT_TRUE(Channel()->Connect(url(), ""));
......
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBSOCKETS_WEBSOCKET_HANDLE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBSOCKETS_WEBSOCKET_HANDLE_H_
#include <stdint.h>
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/websocket.mojom-blink.h"
#include "third_party/blink/public/mojom/websockets/websocket_connector.mojom-blink.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
namespace blink {
class KURL;
class WebSocketChannelImpl;
// WebSocketHandle is an interface class designed to be a handle of WebSocket
// connection. WebSocketHandle will be used together with
// WebSocketChannelImpl.
//
// Once a WebSocketHandle is deleted there will be no notification to the
// corresponding WebSocketChannelImpl. Once a WebSocketChannelImpl receives
// didClose, any method of the corresponding WebSocketHandle can't be called.
class WebSocketHandle {
public:
enum MessageType {
kMessageTypeContinuation,
kMessageTypeText,
kMessageTypeBinary,
};
virtual ~WebSocketHandle() = default;
virtual void Connect(mojo::Remote<mojom::blink::WebSocketConnector>,
const KURL&,
const Vector<String>& protocols,
const KURL& site_for_cookies,
const String& user_agent_override,
WebSocketChannelImpl*) = 0;
virtual void Send(bool fin, MessageType, const char* data, wtf_size_t) = 0;
virtual void StartReceiving() = 0;
virtual void ConsumePendingDataFrames() = 0;
virtual void Close(uint16_t code, const String& reason) = 0;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBSOCKETS_WEBSOCKET_HANDLE_H_
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBSOCKETS_WEBSOCKET_HANDLE_IMPL_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBSOCKETS_WEBSOCKET_HANDLE_IMPL_H_
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/websocket.mojom-blink.h"
#include "third_party/blink/public/mojom/websockets/websocket_connector.mojom-blink.h"
#include "third_party/blink/renderer/modules/websockets/websocket_handle.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/deque.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
namespace base {
class Location;
class SingleThreadTaskRunner;
} // namespace base
namespace blink {
class WebSocketHandleImpl
: public WebSocketHandle,
public network::mojom::blink::WebSocketHandshakeClient,
public network::mojom::blink::WebSocketClient {
public:
explicit WebSocketHandleImpl(scoped_refptr<base::SingleThreadTaskRunner>);
~WebSocketHandleImpl() override;
void Connect(mojo::Remote<mojom::blink::WebSocketConnector>,
const KURL&,
const Vector<String>& protocols,
const KURL& site_for_cookies,
const String& user_agent_override,
WebSocketChannelImpl*) override;
void Send(bool fin, MessageType, const char* data, wtf_size_t) override;
void StartReceiving() override;
void ConsumePendingDataFrames() override;
void Close(uint16_t code, const String& reason) override;
private:
struct DataFrame final {
DataFrame(bool fin,
network::mojom::blink::WebSocketMessageType type,
uint32_t data_length)
: fin(fin), type(type), data_length(data_length) {}
bool fin;
network::mojom::blink::WebSocketMessageType type;
uint32_t data_length;
};
void Disconnect();
void OnConnectionError(const base::Location& set_from,
uint32_t custom_reason,
const std::string& description);
// network::mojom::blink::WebSocketHandshakeClient methods:
void OnOpeningHandshakeStarted(
network::mojom::blink::WebSocketHandshakeRequestPtr) override;
void OnResponseReceived(
network::mojom::blink::WebSocketHandshakeResponsePtr) override;
void OnConnectionEstablished(
mojo::PendingRemote<network::mojom::blink::WebSocket> websocket,
mojo::PendingReceiver<network::mojom::blink::WebSocketClient>
client_receiver,
const String& selected_protocol,
const String& extensions,
mojo::ScopedDataPipeConsumerHandle readable) override;
// network::mojom::blink::WebSocketClient methods:
void OnDataFrame(bool fin,
network::mojom::blink::WebSocketMessageType,
uint64_t data_length) override;
void AddSendFlowControlQuota(int64_t quota) override;
void OnDropChannel(bool was_clean,
uint16_t code,
const String& reason) override;
void OnClosingHandshake() override;
// Datapipe functions to receive.
void OnReadable(MojoResult result, const mojo::HandleSignalsState& state);
// Returns false if |this| is deleted.
bool ConsumeDataFrame(bool fin,
network::mojom::blink::WebSocketMessageType type,
const void* data,
size_t data_size);
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
WeakPersistent<WebSocketChannelImpl> channel_;
mojo::Remote<network::mojom::blink::WebSocket> websocket_;
mojo::Receiver<network::mojom::blink::WebSocketHandshakeClient>
handshake_client_receiver_{this};
mojo::Receiver<network::mojom::blink::WebSocketClient> client_receiver_{this};
// Datapipe fields to receive.
mojo::ScopedDataPipeConsumerHandle readable_;
mojo::SimpleWatcher readable_watcher_;
WTF::Deque<DataFrame> pending_data_frames_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBSOCKETS_WEBSOCKET_HANDLE_IMPL_H_
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