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( ...@@ -251,8 +251,7 @@ bool DocumentWebSocketChannel::Connect(
return true; return true;
} }
handle_->Initialize(std::move(socket_ptr)); handle_->Connect(std::move(socket_ptr), url, protocols,
handle_->Connect(url, protocols,
loading_context_->GetFetchContext()->GetSiteForCookies(), loading_context_->GetFetchContext()->GetSiteForCookies(),
loading_context_->GetExecutionContext()->UserAgent(), this, loading_context_->GetExecutionContext()->UserAgent(), this,
loading_context_->GetExecutionContext() loading_context_->GetExecutionContext()
......
...@@ -82,18 +82,21 @@ class MockWebSocketHandle : public WebSocketHandle { ...@@ -82,18 +82,21 @@ class MockWebSocketHandle : public WebSocketHandle {
~MockWebSocketHandle() override = default; ~MockWebSocketHandle() override = default;
MOCK_METHOD1(DoInitialize, void(network::mojom::blink::WebSocketPtr*)); void Connect(network::mojom::blink::WebSocketPtr websocket,
void Initialize(network::mojom::blink::WebSocketPtr websocket) override { const KURL& url,
DoInitialize(&websocket); 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_METHOD5(Connect,
MOCK_METHOD6(Connect,
void(const KURL&, void(const KURL&,
const Vector<String>&, const Vector<String>&,
const KURL&, const KURL&,
const String&, const String&,
WebSocketHandleClient*, WebSocketHandleClient*));
base::SingleThreadTaskRunner*));
MOCK_METHOD4(Send, MOCK_METHOD4(Send,
void(bool, WebSocketHandle::MessageType, const char*, size_t)); void(bool, WebSocketHandle::MessageType, const char*, size_t));
MOCK_METHOD1(FlowControl, void(int64_t)); MOCK_METHOD1(FlowControl, void(int64_t));
...@@ -162,9 +165,8 @@ class DocumentWebSocketChannelTest : public PageTestBase { ...@@ -162,9 +165,8 @@ class DocumentWebSocketChannelTest : public PageTestBase {
void Connect() { void Connect() {
{ {
InSequence s; InSequence s;
EXPECT_CALL(*Handle(), DoInitialize(_));
EXPECT_CALL(*Handle(), EXPECT_CALL(*Handle(),
Connect(KURL("ws://localhost/"), _, _, _, HandleClient(), _)); Connect(KURL("ws://localhost/"), _, _, _, HandleClient()));
EXPECT_CALL(*Handle(), FlowControl(65536)); EXPECT_CALL(*Handle(), FlowControl(65536));
EXPECT_CALL(*ChannelClient(), DidConnect(String("a"), String("b"))); EXPECT_CALL(*ChannelClient(), DidConnect(String("a"), String("b")));
} }
...@@ -210,10 +212,9 @@ TEST_F(DocumentWebSocketChannelTest, connectSuccess) { ...@@ -210,10 +212,9 @@ TEST_F(DocumentWebSocketChannelTest, connectSuccess) {
Checkpoint checkpoint; Checkpoint checkpoint;
{ {
InSequence s; InSequence s;
EXPECT_CALL(*Handle(), DoInitialize(_));
EXPECT_CALL(*Handle(), EXPECT_CALL(*Handle(),
Connect(KURLEq("ws://localhost/"), _, Connect(KURLEq("ws://localhost/"), _,
KURLEq("http://example.com/"), _, HandleClient(), _)) KURLEq("http://example.com/"), _, HandleClient()))
.WillOnce(SaveArg<1>(&protocols)); .WillOnce(SaveArg<1>(&protocols));
EXPECT_CALL(checkpoint, Call(1)); EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*Handle(), FlowControl(65536)); EXPECT_CALL(*Handle(), FlowControl(65536));
...@@ -819,8 +820,7 @@ class DocumentWebSocketChannelHandshakeThrottleTest ...@@ -819,8 +820,7 @@ class DocumentWebSocketChannelHandshakeThrottleTest
// Expectations for the normal result of calling Channel()->Connect() with a // Expectations for the normal result of calling Channel()->Connect() with a
// non-null throttle. // non-null throttle.
void NormalHandshakeExpectations() { void NormalHandshakeExpectations() {
EXPECT_CALL(*Handle(), DoInitialize(_)); EXPECT_CALL(*Handle(), Connect(_, _, _, _, _));
EXPECT_CALL(*Handle(), Connect(_, _, _, _, _, _));
EXPECT_CALL(*handshake_throttle_, ThrottleHandshake(_, _, _)); EXPECT_CALL(*handshake_throttle_, ThrottleHandshake(_, _, _));
} }
...@@ -828,8 +828,7 @@ class DocumentWebSocketChannelHandshakeThrottleTest ...@@ -828,8 +828,7 @@ class DocumentWebSocketChannelHandshakeThrottleTest
}; };
TEST_F(DocumentWebSocketChannelHandshakeThrottleTest, ThrottleArguments) { TEST_F(DocumentWebSocketChannelHandshakeThrottleTest, ThrottleArguments) {
EXPECT_CALL(*Handle(), DoInitialize(_)); EXPECT_CALL(*Handle(), Connect(_, _, _, _, _));
EXPECT_CALL(*Handle(), Connect(_, _, _, _, _, _));
EXPECT_CALL(*handshake_throttle_, EXPECT_CALL(*handshake_throttle_,
ThrottleHandshake(WebURL(url()), _, GetWebCallbacks())); ThrottleHandshake(WebURL(url()), _, GetWebCallbacks()));
EXPECT_CALL(*handshake_throttle_, Destructor()); EXPECT_CALL(*handshake_throttle_, Destructor());
......
...@@ -60,8 +60,8 @@ class WebSocketHandle { ...@@ -60,8 +60,8 @@ class WebSocketHandle {
virtual ~WebSocketHandle() = default; virtual ~WebSocketHandle() = default;
virtual void Initialize(network::mojom::blink::WebSocketPtr) = 0; virtual void Connect(network::mojom::blink::WebSocketPtr,
virtual void Connect(const KURL&, const KURL&,
const Vector<String>& protocols, const Vector<String>& protocols,
const KURL& site_for_cookies, const KURL& site_for_cookies,
const String& user_agent_override, const String& user_agent_override,
......
...@@ -34,22 +34,17 @@ WebSocketHandleImpl::~WebSocketHandleImpl() { ...@@ -34,22 +34,17 @@ WebSocketHandleImpl::~WebSocketHandleImpl() {
websocket_->StartClosingHandshake(kAbnormalShutdownOpCode, g_empty_string); websocket_->StartClosingHandshake(kAbnormalShutdownOpCode, g_empty_string);
} }
void WebSocketHandleImpl::Initialize( void WebSocketHandleImpl::Connect(network::mojom::blink::WebSocketPtr websocket,
network::mojom::blink::WebSocketPtr websocket) { const KURL& url,
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,
const Vector<String>& protocols, const Vector<String>& protocols,
const KURL& site_for_cookies, const KURL& site_for_cookies,
const String& user_agent_override, const String& user_agent_override,
WebSocketHandleClient* client, WebSocketHandleClient* client,
base::SingleThreadTaskRunner* task_runner) { 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_); DCHECK(websocket_);
NETWORK_DVLOG(1) << this << " connect(" << url.GetString() << ")"; NETWORK_DVLOG(1) << this << " connect(" << url.GetString() << ")";
......
...@@ -43,8 +43,8 @@ class WebSocketHandleImpl : public WebSocketHandle, ...@@ -43,8 +43,8 @@ class WebSocketHandleImpl : public WebSocketHandle,
WebSocketHandleImpl(); WebSocketHandleImpl();
~WebSocketHandleImpl() override; ~WebSocketHandleImpl() override;
void Initialize(network::mojom::blink::WebSocketPtr) override; void Connect(network::mojom::blink::WebSocketPtr,
void Connect(const KURL&, const KURL&,
const Vector<String>& protocols, const Vector<String>& protocols,
const KURL& site_for_cookies, const KURL& site_for_cookies,
const String& user_agent_override, 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