Modified: trunk/Source/WebCore/ChangeLog (203812 => 203813)
--- trunk/Source/WebCore/ChangeLog 2016-07-28 05:59:33 UTC (rev 203812)
+++ trunk/Source/WebCore/ChangeLog 2016-07-28 06:28:11 UTC (rev 203813)
@@ -1,3 +1,29 @@
+2016-07-27 Fujii Hironori <hironori.fu...@sony.com>
+
+ [soup] Incorrect usage of relaxAdoptionRequirement in the constructor of SocketStreamHandle
+ https://bugs.webkit.org/show_bug.cgi?id=160281
+
+ Reviewed by Carlos Garcia Campos.
+
+ No new tests (No behavior change).
+
+ Incrementing refcount in a constructor causes an assertion failure
+ that it's not adopted yet. So, relaxAdoptionRequirement() was
+ used to avoid the problem in the constructors of
+ SocketStreamHandle. This is a incorrect solution. The correct
+ solution is to make SocketStreamHandle::create() increment the
+ refcount after calling the constructor.
+
+ * platform/network/soup/SocketStreamHandle.h: Removed the second
+ constructor of SocketStreamHandle which is not used anymore.
+ Uninlined create() because this is not trivial anymore.
+ * platform/network/soup/SocketStreamHandleSoup.cpp:
+ (WebCore::SocketStreamHandle::create): Do the rest of jobs which
+ was done by the constructors.
+ (WebCore::SocketStreamHandle::SocketStreamHandle): Move the jobs
+ after initialization to create().
+ Removed the second constructor.
+
2016-07-27 Chris Dumez <cdu...@apple.com>
First parameter to HTMLMediaElement.canPlayType() should be mandatory
Modified: trunk/Source/WebCore/platform/network/soup/SocketStreamHandle.h (203812 => 203813)
--- trunk/Source/WebCore/platform/network/soup/SocketStreamHandle.h 2016-07-28 05:59:33 UTC (rev 203812)
+++ trunk/Source/WebCore/platform/network/soup/SocketStreamHandle.h 2016-07-28 06:28:11 UTC (rev 203813)
@@ -49,14 +49,13 @@
class SocketStreamHandle final : public RefCounted<SocketStreamHandle>, public SocketStreamHandleBase {
public:
- static Ref<SocketStreamHandle> create(const URL& url, SocketStreamHandleClient& client, NetworkingContext&, SessionID) { return adoptRef(*new SocketStreamHandle(url, client)); }
- static Ref<SocketStreamHandle> create(GSocketConnection* socketConnection, SocketStreamHandleClient& client) { return adoptRef(*new SocketStreamHandle(socketConnection, client)); }
+ static Ref<SocketStreamHandle> create(const URL&, SocketStreamHandleClient&, NetworkingContext&, SessionID);
+ static Ref<SocketStreamHandle> create(GSocketConnection*, SocketStreamHandleClient&);
virtual ~SocketStreamHandle();
private:
SocketStreamHandle(const URL&, SocketStreamHandleClient&);
- SocketStreamHandle(GSocketConnection*, SocketStreamHandleClient&);
int platformSend(const char* data, int length) override;
void platformClose() override;
Modified: trunk/Source/WebCore/platform/network/soup/SocketStreamHandleSoup.cpp (203812 => 203813)
--- trunk/Source/WebCore/platform/network/soup/SocketStreamHandleSoup.cpp 2016-07-28 05:59:33 UTC (rev 203812)
+++ trunk/Source/WebCore/platform/network/soup/SocketStreamHandleSoup.cpp 2016-07-28 06:28:11 UTC (rev 203813)
@@ -48,30 +48,34 @@
namespace WebCore {
-SocketStreamHandle::SocketStreamHandle(const URL& url, SocketStreamHandleClient& client)
- : SocketStreamHandleBase(url, client)
- , m_cancellable(adoptGRef(g_cancellable_new()))
+Ref<SocketStreamHandle> SocketStreamHandle::create(const URL& url, SocketStreamHandleClient& client, NetworkingContext&, SessionID)
{
- LOG(Network, "SocketStreamHandle %p new client %p", this, &m_client);
+ Ref<SocketStreamHandle> socket = adoptRef(*new SocketStreamHandle(url, client));
+
unsigned port = url.hasPort() ? url.port() : (url.protocolIs("wss") ? 443 : 80);
-
GRefPtr<GSocketClient> socketClient = adoptGRef(g_socket_client_new());
if (url.protocolIs("wss"))
g_socket_client_set_tls(socketClient.get(), TRUE);
- relaxAdoptionRequirement();
- RefPtr<SocketStreamHandle> protectedThis(this);
- g_socket_client_connect_to_host_async(socketClient.get(), url.host().utf8().data(), port, m_cancellable.get(),
- reinterpret_cast<GAsyncReadyCallback>(connectedCallback), protectedThis.leakRef());
+ Ref<SocketStreamHandle> protectedSocketStreamHandle = socket.copyRef();
+ g_socket_client_connect_to_host_async(socketClient.get(), url.host().utf8().data(), port, socket->m_cancellable.get(),
+ reinterpret_cast<GAsyncReadyCallback>(connectedCallback), &protectedSocketStreamHandle.leakRef());
+ return socket;
}
-SocketStreamHandle::SocketStreamHandle(GSocketConnection* socketConnection, SocketStreamHandleClient& client)
- : SocketStreamHandleBase(URL(), client)
+Ref<SocketStreamHandle> SocketStreamHandle::create(GSocketConnection* socketConnection, SocketStreamHandleClient& client)
+{
+ Ref<SocketStreamHandle> socket = adoptRef(*new SocketStreamHandle(URL(), client));
+
+ GRefPtr<GSocketConnection> connection = socketConnection;
+ socket->connected(WTFMove(connection));
+ return socket;
+}
+
+SocketStreamHandle::SocketStreamHandle(const URL& url, SocketStreamHandleClient& client)
+ : SocketStreamHandleBase(url, client)
, m_cancellable(adoptGRef(g_cancellable_new()))
{
LOG(Network, "SocketStreamHandle %p new client %p", this, &m_client);
- GRefPtr<GSocketConnection> connection = socketConnection;
- relaxAdoptionRequirement();
- connected(WTFMove(connection));
}
SocketStreamHandle::~SocketStreamHandle()