Commit 1474295c authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Remove WebSocketHandle::Initialize

This is a mere cleanup.

Bug: 721400
Change-Id: I85c5cced89001c5e03020089fc1babb397e19682
Reviewed-on: https://chromium-review.googlesource.com/994914Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548018}
parent a0c4bd61
......@@ -251,8 +251,7 @@ bool DocumentWebSocketChannel::Connect(
return true;
}
handle_->Initialize(std::move(socket_ptr));
handle_->Connect(url, protocols,
handle_->Connect(std::move(socket_ptr), url, protocols,
loading_context_->GetFetchContext()->GetSiteForCookies(),
loading_context_->GetExecutionContext()->UserAgent(), this,
loading_context_->GetExecutionContext()
......
......@@ -82,18 +82,21 @@ class MockWebSocketHandle : public WebSocketHandle {
~MockWebSocketHandle() override = default;
MOCK_METHOD1(DoInitialize, void(network::mojom::blink::WebSocketPtr*));
void Initialize(network::mojom::blink::WebSocketPtr websocket) override {
DoInitialize(&websocket);
void Connect(network::mojom::blink::WebSocketPtr websocket,
const KURL& url,
const Vector<String>& protocols,
const KURL& site_for_cookies,
const String& user_agent_override,
WebSocketHandleClient* client,
base::SingleThreadTaskRunner*) {
Connect(url, protocols, site_for_cookies, user_agent_override, client);
}
MOCK_METHOD6(Connect,
MOCK_METHOD5(Connect,
void(const KURL&,
const Vector<String>&,
const KURL&,
const String&,
WebSocketHandleClient*,
base::SingleThreadTaskRunner*));
WebSocketHandleClient*));
MOCK_METHOD4(Send,
void(bool, WebSocketHandle::MessageType, const char*, size_t));
MOCK_METHOD1(FlowControl, void(int64_t));
......@@ -162,9 +165,8 @@ class DocumentWebSocketChannelTest : public PageTestBase {
void Connect() {
{
InSequence s;
EXPECT_CALL(*Handle(), DoInitialize(_));
EXPECT_CALL(*Handle(),
Connect(KURL("ws://localhost/"), _, _, _, HandleClient(), _));
Connect(KURL("ws://localhost/"), _, _, _, HandleClient()));
EXPECT_CALL(*Handle(), FlowControl(65536));
EXPECT_CALL(*ChannelClient(), DidConnect(String("a"), String("b")));
}
......@@ -210,10 +212,9 @@ TEST_F(DocumentWebSocketChannelTest, connectSuccess) {
Checkpoint checkpoint;
{
InSequence s;
EXPECT_CALL(*Handle(), DoInitialize(_));
EXPECT_CALL(*Handle(),
Connect(KURLEq("ws://localhost/"), _,
KURLEq("http://example.com/"), _, HandleClient(), _))
KURLEq("http://example.com/"), _, HandleClient()))
.WillOnce(SaveArg<1>(&protocols));
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*Handle(), FlowControl(65536));
......@@ -819,8 +820,7 @@ class DocumentWebSocketChannelHandshakeThrottleTest
// Expectations for the normal result of calling Channel()->Connect() with a
// non-null throttle.
void NormalHandshakeExpectations() {
EXPECT_CALL(*Handle(), DoInitialize(_));
EXPECT_CALL(*Handle(), Connect(_, _, _, _, _, _));
EXPECT_CALL(*Handle(), Connect(_, _, _, _, _));
EXPECT_CALL(*handshake_throttle_, ThrottleHandshake(_, _, _));
}
......@@ -828,8 +828,7 @@ class DocumentWebSocketChannelHandshakeThrottleTest
};
TEST_F(DocumentWebSocketChannelHandshakeThrottleTest, ThrottleArguments) {
EXPECT_CALL(*Handle(), DoInitialize(_));
EXPECT_CALL(*Handle(), Connect(_, _, _, _, _, _));
EXPECT_CALL(*Handle(), Connect(_, _, _, _, _));
EXPECT_CALL(*handshake_throttle_,
ThrottleHandshake(WebURL(url()), _, GetWebCallbacks()));
EXPECT_CALL(*handshake_throttle_, Destructor());
......
......@@ -60,8 +60,8 @@ class WebSocketHandle {
virtual ~WebSocketHandle() = default;
virtual void Initialize(network::mojom::blink::WebSocketPtr) = 0;
virtual void Connect(const KURL&,
virtual void Connect(network::mojom::blink::WebSocketPtr,
const KURL&,
const Vector<String>& protocols,
const KURL& site_for_cookies,
const String& user_agent_override,
......
......@@ -34,22 +34,17 @@ WebSocketHandleImpl::~WebSocketHandleImpl() {
websocket_->StartClosingHandshake(kAbnormalShutdownOpCode, g_empty_string);
}
void WebSocketHandleImpl::Initialize(
network::mojom::blink::WebSocketPtr websocket) {
NETWORK_DVLOG(1) << this << " initialize(...)";
DCHECK(!websocket_);
websocket_ = std::move(websocket);
websocket_.set_connection_error_with_reason_handler(WTF::Bind(
&WebSocketHandleImpl::OnConnectionError, WTF::Unretained(this)));
}
void WebSocketHandleImpl::Connect(const KURL& url,
void WebSocketHandleImpl::Connect(network::mojom::blink::WebSocketPtr websocket,
const KURL& url,
const Vector<String>& protocols,
const KURL& site_for_cookies,
const String& user_agent_override,
WebSocketHandleClient* client,
base::SingleThreadTaskRunner* task_runner) {
DCHECK(!websocket_);
websocket_ = std::move(websocket);
websocket_.set_connection_error_with_reason_handler(WTF::Bind(
&WebSocketHandleImpl::OnConnectionError, WTF::Unretained(this)));
DCHECK(websocket_);
NETWORK_DVLOG(1) << this << " connect(" << url.GetString() << ")";
......
......@@ -43,8 +43,8 @@ class WebSocketHandleImpl : public WebSocketHandle,
WebSocketHandleImpl();
~WebSocketHandleImpl() override;
void Initialize(network::mojom::blink::WebSocketPtr) override;
void Connect(const KURL&,
void Connect(network::mojom::blink::WebSocketPtr,
const KURL&,
const Vector<String>& protocols,
const KURL& site_for_cookies,
const String& user_agent_override,
......
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