Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (140835 => 140836)
--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2013-01-25 17:03:57 UTC (rev 140835)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2013-01-25 17:06:17 UTC (rev 140836)
@@ -304,6 +304,14 @@
return session;
}
+bool ResourceHandle::cancelledOrClientless()
+{
+ if (!client())
+ return true;
+
+ return getInternal()->m_cancelled;
+}
+
static bool isAuthenticationFailureStatusCode(int httpStatusCode)
{
return httpStatusCode == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED || httpStatusCode == SOUP_STATUS_UNAUTHORIZED;
@@ -312,11 +320,10 @@
static void gotHeadersCallback(SoupMessage* message, gpointer data)
{
ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- if (!handle)
+ if (!handle || handle->cancelledOrClientless())
return;
+
ResourceHandleInternal* d = handle->getInternal();
- if (d->m_cancelled)
- return;
#if ENABLE(WEB_TIMING)
if (d->m_response.resourceLoadTiming())
@@ -383,11 +390,10 @@
static void restartedCallback(SoupMessage*, gpointer data)
{
ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- if (!handle)
+ if (!handle || handle->cancelledOrClientless())
return;
+
ResourceHandleInternal* d = handle->getInternal();
- if (d->m_cancelled)
- return;
#if ENABLE(WEB_TIMING)
ResourceResponse& redirectResponse = d->m_response;
@@ -494,13 +500,13 @@
static void redirectCloseCallback(GObject*, GAsyncResult* result, gpointer data)
{
RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- if (d->m_cancelled || !handle->client()) {
+ if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}
+ ResourceHandleInternal* d = handle->getInternal();
g_input_stream_close_finish(d->m_inputStream.get(), result, 0);
doRedirect(handle.get());
}
@@ -509,17 +515,16 @@
{
RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- ResourceHandleClient* client = handle->client();
-
- if (d->m_cancelled || !client) {
+ if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}
GOwnPtr<GError> error;
+ ResourceHandleInternal* d = handle->getInternal();
gssize bytesSkipped = g_input_stream_read_finish(d->m_inputStream.get(), asyncResult, &error.outPtr());
if (error) {
+ ResourceHandleClient* client = handle->client();
client->didFail(handle.get(), ResourceError::genericIOError(error.get(), d->m_soupRequest.get()));
cleanupSoupRequestOperation(handle.get());
return;
@@ -541,16 +546,14 @@
return;
ASSERT(buffer);
- ResourceHandleInternal* internal = handle->getInternal();
- internal->m_bodyDataSent += buffer->length;
+ ResourceHandleInternal* d = handle->getInternal();
+ d->m_bodyDataSent += buffer->length;
- if (internal->m_cancelled)
+ if (handle->cancelledOrClientless())
return;
+
ResourceHandleClient* client = handle->client();
- if (!client)
- return;
-
- client->didSendData(handle.get(), internal->m_bodyDataSent, internal->m_bodySize);
+ client->didSendData(handle.get(), d->m_bodyDataSent, d->m_bodySize);
}
static void cleanupSoupRequestOperation(ResourceHandle* handle, bool isDestroying)
@@ -608,18 +611,18 @@
{
RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- ResourceHandleClient* client = handle->client();
-
- if (d->m_cancelled || !client) {
+ if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}
+ ResourceHandleInternal* d = handle->getInternal();
ASSERT(!d->m_inputStream);
GOwnPtr<GError> error;
d->m_inputStream = adoptGRef(soup_multipart_input_stream_next_part_finish(d->m_multipartInputStream.get(), result, &error.outPtr()));
+
+ ResourceHandleClient* client = handle->client();
if (error) {
client->didFail(handle.get(), ResourceError::httpError(d->m_soupMessage.get(), error.get(), d->m_soupRequest.get()));
cleanupSoupRequestOperation(handle.get());
@@ -638,7 +641,7 @@
client->didReceiveResponse(handle.get(), d->m_response);
- if (d->m_cancelled || !client) {
+ if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}
@@ -651,14 +654,15 @@
{
RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
+ if (handle->cancelledOrClientless()) {
+ cleanupSoupRequestOperation(handle.get());
+ return;
+ }
+
ResourceHandleInternal* d = handle->getInternal();
ResourceHandleClient* client = handle->client();
SoupMessage* soupMessage = d->m_soupMessage.get();
- if (d->m_cancelled || !client) {
- cleanupSoupRequestOperation(handle.get());
- return;
- }
if (d->m_defersLoading) {
d->m_deferredResult = result;
@@ -707,7 +711,7 @@
client->didReceiveResponse(handle.get(), d->m_response);
- if (d->m_cancelled) {
+ if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}
@@ -869,10 +873,11 @@
ResourceHandle* handle = static_cast<ResourceHandle*>(data);
if (!handle)
return;
- ResourceHandleInternal* d = handle->getInternal();
- if (d->m_cancelled)
+
+ if (handle->cancelledOrClientless())
return;
+ ResourceHandleInternal* d = handle->getInternal();
int deltaTime = milisecondsSinceRequest(d->m_response.resourceLoadTiming()->requestTime);
switch (event) {
case G_SOCKET_CLIENT_RESOLVING:
@@ -1249,7 +1254,7 @@
void ResourceHandle::platformSetDefersLoading(bool defersLoading)
{
- if (d->m_cancelled)
+ if (cancelledOrClientless())
return;
// Except when canceling a possible timeout timer, we only need to take action here to UN-defer loading.
@@ -1324,14 +1329,12 @@
{
RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- ResourceHandleClient* client = handle->client();
-
- if (d->m_cancelled || !client) {
+ if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}
+ ResourceHandleInternal* d = handle->getInternal();
if (d->m_defersLoading) {
d->m_deferredResult = asyncResult;
return;
@@ -1339,6 +1342,8 @@
GOwnPtr<GError> error;
gssize bytesRead = g_input_stream_read_finish(d->m_inputStream.get(), asyncResult, &error.outPtr());
+
+ ResourceHandleClient* client = handle->client();
if (error) {
client->didFail(handle.get(), ResourceError::genericIOError(error.get(), d->m_soupRequest.get()));
cleanupSoupRequestOperation(handle.get());
@@ -1373,7 +1378,7 @@
client->didReceiveData(handle.get(), d->m_buffer, bytesRead, bytesRead);
// didReceiveData may cancel the load, which may release the last reference.
- if (d->m_cancelled || !client) {
+ if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}