Modified: trunk/Source/WebCore/ChangeLog (100465 => 100466)
--- trunk/Source/WebCore/ChangeLog 2011-11-16 18:16:04 UTC (rev 100465)
+++ trunk/Source/WebCore/ChangeLog 2011-11-16 18:20:49 UTC (rev 100466)
@@ -1,3 +1,23 @@
+2011-11-16 Dan Winship <d...@gnome.org>
+
+ [GTK] Fix platformDefersLoading to handle non-http requests, and
+ to not use broken-ish libsoup APIs.
+ https://bugs.webkit.org/show_bug.cgi?id=72227
+
+ Reviewed by Martin Robinson.
+
+ * platform/network/ResourceHandleInternal.h:
+ * platform/network/soup/ResourceHandleSoup.cpp:
+ (WebCore::sendRequestCallback):
+ (WebCore::startHTTPRequest):
+ (WebCore::hasBeenSent):
+ (WebCore::ResourceHandle::platformSetDefersLoading):
+ (WebCore::readCallback): rather than deferring by using
+ soup_session_pause_message(), let the read complete, but just don't
+ process the result until we're no longer deferred.
+ (WebCore::startNonHTTPRequest): Don't start the request if
+ it's deferred.
+
2011-11-16 Vsevolod Vlasov <vse...@chromium.org>
Web Inspector: Application cache status should be updated after swapCache().
Modified: trunk/Source/WebCore/platform/network/ResourceHandleInternal.h (100465 => 100466)
--- trunk/Source/WebCore/platform/network/ResourceHandleInternal.h 2011-11-16 18:16:04 UTC (rev 100465)
+++ trunk/Source/WebCore/platform/network/ResourceHandleInternal.h 2011-11-16 18:20:49 UTC (rev 100466)
@@ -194,6 +194,7 @@
GRefPtr<SoupRequest> m_soupRequest;
GRefPtr<GInputStream> m_inputStream;
GRefPtr<GCancellable> m_cancellable;
+ GRefPtr<GAsyncResult> m_deferredResult;
char* m_buffer;
unsigned long m_bodySize;
unsigned long m_bodyDataSent;
Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (100465 => 100466)
--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2011-11-16 18:16:04 UTC (rev 100465)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2011-11-16 18:20:49 UTC (rev 100466)
@@ -502,9 +502,6 @@
}
}
- if (d->m_defersLoading)
- soup_session_pause_message(handle->defaultSession(), d->m_soupMessage.get());
-
g_input_stream_read_async(d->m_inputStream.get(), d->m_buffer, READ_BUFFER_SIZE,
G_PRIORITY_DEFAULT, d->m_cancellable.get(), readCallback, handle.get());
}
@@ -678,7 +675,7 @@
if (!soup_message_headers_get_one(soupMessage->request_headers, "Accept"))
soup_message_headers_append(soupMessage->request_headers, "Accept", "*/*");
- // Send the request only if it's not been explicitely deferred.
+ // Send the request only if it's not been explicitly deferred.
if (!d->m_defersLoading) {
d->m_cancellable = adoptGRef(g_cancellable_new());
soup_request_send_async(d->m_soupRequest.get(), d->m_cancellable.get(), sendRequestCallback, handle);
@@ -738,34 +735,33 @@
g_cancellable_cancel(d->m_cancellable.get());
}
+static bool hasBeenSent(ResourceHandle* handle)
+{
+ ResourceHandleInternal* d = handle->getInternal();
+
+ return d->m_cancellable;
+}
+
void ResourceHandle::platformSetDefersLoading(bool defersLoading)
{
- // Initial implementation of this method was required for bug #44157.
-
if (d->m_cancelled)
return;
- if (!defersLoading && !d->m_cancellable && d->m_soupRequest.get()) {
+ // We only need to take action here to UN-defer loading.
+ if (defersLoading)
+ return;
+
+ if (!hasBeenSent(this)) {
+ ASSERT(d->m_soupRequest);
d->m_cancellable = adoptGRef(g_cancellable_new());
soup_request_send_async(d->m_soupRequest.get(), d->m_cancellable.get(), sendRequestCallback, this);
return;
}
- // Only supported for http(s) transfers. Something similar would
- // probably be needed for data transfers done with GIO.
- if (!d->m_soupMessage)
- return;
-
- // Do not pause or unpause operations that are completed or have not reached
- // sendRequestCallback yet. If m_defersLoading is true at that point, we'll pause.
- SoupMessage* soupMessage = d->m_soupMessage.get();
- if (d->m_finished || !d->m_inputStream)
- return;
-
- if (defersLoading)
- soup_session_pause_message(defaultSession(), soupMessage);
- else
- soup_session_unpause_message(defaultSession(), soupMessage);
+ if (d->m_deferredResult) {
+ GRefPtr<GAsyncResult> asyncResult = adoptGRef(d->m_deferredResult.leakRef());
+ readCallback(G_OBJECT(d->m_inputStream.get()), asyncResult.get(), this);
+ }
}
bool ResourceHandle::loadsBlocked()
@@ -823,6 +819,11 @@
return;
}
+ if (d->m_defersLoading) {
+ d->m_deferredResult = asyncResult;
+ return;
+ }
+
GOwnPtr<GError> error;
gssize bytesRead = g_input_stream_read_finish(d->m_inputStream.get(), asyncResult, &error.outPtr());
if (error) {
@@ -878,8 +879,11 @@
// balanced by a deref() in cleanupSoupRequestOperation, which should always run
handle->ref();
- d->m_cancellable = adoptGRef(g_cancellable_new());
- soup_request_send_async(d->m_soupRequest.get(), d->m_cancellable.get(), sendRequestCallback, handle);
+ // Send the request only if it's not been explicitly deferred.
+ if (!d->m_defersLoading) {
+ d->m_cancellable = adoptGRef(g_cancellable_new());
+ soup_request_send_async(d->m_soupRequest.get(), d->m_cancellable.get(), sendRequestCallback, handle);
+ }
return true;
}