void MainThreadWebSocketChannel::close(int code, const String& reason) { WTF_LOG(Network, "MainThreadWebSocketChannel %p close() code=%d reason='%s'", this, code, reason.utf8().data()); ASSERT(!m_suspended); if (!m_handle) return; startClosingHandshake(code, reason); if (!m_closingTimer.isActive()) m_closingTimer.startOneShot(2 * TCPMaximumSegmentLifetime, FROM_HERE); }
void WebSocketChannel::close(int code, const String& reason) { LOG(Network, "WebSocketChannel %p close() code=%d reason='%s'", this, code, reason.utf8().data()); ASSERT(!m_suspended); if (!m_handle) return; Ref<WebSocketChannel> protectedThis(*this); // An attempt to send closing handshake may fail, which will get the channel closed and dereferenced. startClosingHandshake(code, reason); if (m_closing && !m_closingTimer.isActive()) m_closingTimer.startOneShot(2 * TCPMaximumSegmentLifetime); }