https://bugs.webkit.org/show_bug.cgi?id=147342
Reviewed by Darin Adler.
Source/WebCore:
Store "usesAsyncCallbacks" bit in ResourceHandle, because it's not accessible
via client once the client is zeroed out.
Changed ResourceHandle::setClient into ResourceHandle::clearClient, because it's
only ever used to zero out the client pointer, and it doesn't support changing it.
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::releaseResources):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::stopLoading):
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::notifyResponseOnSuccess):
(WebCore::BlobResourceHandle::notifyResponseOnError):
* platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::client):
(WebCore::ResourceHandle::clearClient):
(WebCore::ResourceHandle::setDefersLoading):
(WebCore::ResourceHandle::usesAsyncCallbacks):
(WebCore::ResourceHandle::setClient): Deleted.
* platform/network/ResourceHandle.h:
* platform/network/ResourceHandleInternal.h:
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::ResourceHandle::createCFURLConnection):
(WebCore::ResourceHandle::willSendRequest):
(WebCore::ResourceHandle::shouldUseCredentialStorage):
(WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::makeDelegate):
(WebCore::ResourceHandle::willSendRequest):
(WebCore::ResourceHandle::continueWillSendRequest):
(WebCore::ResourceHandle::continueDidReceiveResponse):
(WebCore::ResourceHandle::shouldUseCredentialStorage):
(WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
(WebCore::ResourceHandle::continueCanAuthenticateAgainstProtectionSpace):
(WebCore::ResourceHandle::continueWillCacheResponse):
Source/WebKit2:
Update for a renaming in WebCore.
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::cleanup):
* Shared/Downloads/soup/DownloadSoup.cpp:
(WebKit::Download::platformInvalidate):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187533
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-07-28 Alexey Proskuryakov <ap@apple.com>
+
+ Clean up usesAsyncCallbacks handling in ResourceHandle
+ https://bugs.webkit.org/show_bug.cgi?id=147342
+
+ Reviewed by Darin Adler.
+
+ Store "usesAsyncCallbacks" bit in ResourceHandle, because it's not accessible
+ via client once the client is zeroed out.
+
+ Changed ResourceHandle::setClient into ResourceHandle::clearClient, because it's
+ only ever used to zero out the client pointer, and it doesn't support changing it.
+
+ * loader/ResourceLoader.cpp:
+ (WebCore::ResourceLoader::releaseResources):
+ * loader/appcache/ApplicationCacheGroup.cpp:
+ (WebCore::ApplicationCacheGroup::stopLoading):
+ * platform/network/BlobResourceHandle.cpp:
+ (WebCore::BlobResourceHandle::notifyResponseOnSuccess):
+ (WebCore::BlobResourceHandle::notifyResponseOnError):
+ * platform/network/ResourceHandle.cpp:
+ (WebCore::ResourceHandle::client):
+ (WebCore::ResourceHandle::clearClient):
+ (WebCore::ResourceHandle::setDefersLoading):
+ (WebCore::ResourceHandle::usesAsyncCallbacks):
+ (WebCore::ResourceHandle::setClient): Deleted.
+ * platform/network/ResourceHandle.h:
+ * platform/network/ResourceHandleInternal.h:
+ (WebCore::ResourceHandleInternal::ResourceHandleInternal):
+ * platform/network/cf/ResourceHandleCFNet.cpp:
+ (WebCore::ResourceHandle::createCFURLConnection):
+ (WebCore::ResourceHandle::willSendRequest):
+ (WebCore::ResourceHandle::shouldUseCredentialStorage):
+ (WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
+ * platform/network/mac/ResourceHandleMac.mm:
+ (WebCore::ResourceHandle::start):
+ (WebCore::ResourceHandle::makeDelegate):
+ (WebCore::ResourceHandle::willSendRequest):
+ (WebCore::ResourceHandle::continueWillSendRequest):
+ (WebCore::ResourceHandle::continueDidReceiveResponse):
+ (WebCore::ResourceHandle::shouldUseCredentialStorage):
+ (WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
+ (WebCore::ResourceHandle::continueCanAuthenticateAgainstProtectionSpace):
+ (WebCore::ResourceHandle::continueWillCacheResponse):
+
2015-07-28 Michael Catanzaro <mcatanzaro@igalia.com>
Minor cleanups in FontCacheFreeType.cpp
// Clear out the ResourceHandle's client so that it doesn't try to call
// us back after we release it, unless it has been replaced by someone else.
if (m_handle->client() == this)
- m_handle->setClient(nullptr);
+ m_handle->clearClient();
m_handle = nullptr;
}
ASSERT(!m_currentHandle);
ASSERT(m_manifestHandle->client() == this);
- m_manifestHandle->setClient(0);
+ m_manifestHandle->clearClient();
m_manifestHandle->cancel();
m_manifestHandle = nullptr;
ASSERT(m_cacheBeingUpdated);
ASSERT(m_currentHandle->client() == this);
- m_currentHandle->setClient(0);
+ m_currentHandle->clearClient();
m_currentHandle->cancel();
m_currentHandle = nullptr;
// BlobResourceHandle cannot be used with downloading, and doesn't even wait for continueDidReceiveResponse.
// It's currently client's responsibility to know that didReceiveResponseAsync cannot be used to convert a
// load into a download or blobs.
- if (client()->usesAsyncCallbacks())
+ if (usesAsyncCallbacks())
client()->didReceiveResponseAsync(this, response);
else
client()->didReceiveResponse(this, response);
// Note that we don't wait for continueDidReceiveResponse when using didReceiveResponseAsync.
// This is not formally correct, but the client has to be a no-op anyway, because blobs can't be downloaded.
- if (client()->usesAsyncCallbacks())
+ if (usesAsyncCallbacks())
client()->didReceiveResponseAsync(this, response);
else
client()->didReceiveResponse(this, response);
return d->m_client;
}
-void ResourceHandle::setClient(ResourceHandleClient* client)
+void ResourceHandle::clearClient()
{
- d->m_client = client;
+ d->m_client = nullptr;
}
#if !PLATFORM(COCOA) && !USE(CFNETWORK) && !USE(SOUP)
platformSetDefersLoading(defers);
}
+bool ResourceHandle::usesAsyncCallbacks() const
+{
+ return d->m_usesAsyncCallbacks;
+}
+
} // namespace WebCore
// The client may be 0, in which case no callbacks will be made.
ResourceHandleClient* client() const;
- WEBCORE_EXPORT void setClient(ResourceHandleClient*);
+ WEBCORE_EXPORT void clearClient();
// Called in response to ResourceHandleClient::willSendRequestAsync().
WEBCORE_EXPORT void continueWillSendRequest(const ResourceRequest&);
protected:
ResourceHandle(NetworkingContext*, const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff);
+ bool usesAsyncCallbacks() const;
+
private:
enum FailureType {
NoFailure,
#include "NetworkingContext.h"
#include "ResourceHandle.h"
+#include "ResourceHandleClient.h"
#include "ResourceRequest.h"
#include "AuthenticationChallenge.h"
#include "Timer.h"
namespace WebCore {
- class ResourceHandleClient;
-
class ResourceHandleInternal {
WTF_MAKE_NONCOPYABLE(ResourceHandleInternal); WTF_MAKE_FAST_ALLOCATED;
public:
, status(0)
, m_defersLoading(defersLoading)
, m_shouldContentSniff(shouldContentSniff)
+ , m_usesAsyncCallbacks(client && client->usesAsyncCallbacks())
#if USE(CFNETWORK)
, m_currentRequest(request)
#endif
bool m_defersLoading;
bool m_shouldContentSniff;
+ bool m_usesAsyncCallbacks;
#if USE(CFNETWORK)
RetainPtr<CFURLConnectionRef> m_connection;
ResourceRequest m_currentRequest;
CFRelease(streamProperties);
#if PLATFORM(COCOA)
- if (client() && client()->usesAsyncCallbacks())
+ if (d->m_usesAsyncCallbacks)
d->m_connectionDelegate = adoptRef(new ResourceHandleCFURLConnectionDelegateWithOperationQueue(this));
else
d->m_connectionDelegate = adoptRef(new SynchronousResourceHandleCFURLConnectionDelegate(this));
}
Ref<ResourceHandle> protect(*this);
- if (client()->usesAsyncCallbacks())
+ if (d->m_usesAsyncCallbacks)
client()->willSendRequestAsync(this, request, redirectResponse);
else {
client()->willSendRequest(this, request, redirectResponse);
{
LOG(Network, "CFNet - shouldUseCredentialStorage()");
if (ResourceHandleClient* client = this->client()) {
- ASSERT(!client->usesAsyncCallbacks());
+ ASSERT(!d->m_usesAsyncCallbacks);
return client->shouldUseCredentialStorage(this);
}
return false;
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
bool ResourceHandle::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
{
- if (ResourceHandleClient* client = this->client()) {
- if (client->usesAsyncCallbacks())
+ ResourceHandleClient* client = this->client();
+ if (d->m_usesAsyncCallbacks) {
+ if (client)
client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
else
- return client->canAuthenticateAgainstProtectionSpace(this, protectionSpace);
+ continueCanAuthenticateAgainstProtectionSpace(false);
+ return false; // Ignored by caller.
}
- return false;
+
+ return client && client->canAuthenticateAgainstProtectionSpace(this, protectionSpace);
}
#endif
}
}
- if (client() && client()->usesAsyncCallbacks()) {
+ if (d->m_usesAsyncCallbacks) {
ASSERT(!scheduled);
[connection() setDelegateQueue:operationQueueForAsyncClients()];
scheduled = true;
ASSERT(!d->m_delegate);
id <NSURLConnectionDelegate> delegate;
- if (client() && client()->usesAsyncCallbacks()) {
+ if (d->m_usesAsyncCallbacks) {
if (shouldUseCredentialStorage)
delegate = [[WebCoreResourceHandleAsOperationQueueDelegate alloc] initWithHandle:this];
else
}
}
- if (client()->usesAsyncCallbacks()) {
+ if (d->m_usesAsyncCallbacks) {
client()->willSendRequestAsync(this, request, redirectResponse);
} else {
Ref<ResourceHandle> protect(*this);
void ResourceHandle::continueWillSendRequest(const ResourceRequest& request)
{
- ASSERT(client());
- ASSERT(client()->usesAsyncCallbacks());
+ ASSERT(d->m_usesAsyncCallbacks);
// Client call may not preserve the session, especially if the request is sent over IPC.
ResourceRequest newRequest = request;
void ResourceHandle::continueDidReceiveResponse()
{
- ASSERT(client());
- ASSERT(client()->usesAsyncCallbacks());
+ ASSERT(d->m_usesAsyncCallbacks);
[delegate() continueDidReceiveResponse];
}
bool ResourceHandle::shouldUseCredentialStorage()
{
- ASSERT(!client()->usesAsyncCallbacks());
+ ASSERT(!d->m_usesAsyncCallbacks);
return client() && client()->shouldUseCredentialStorage(this);
}
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
bool ResourceHandle::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
{
- if (client()->usesAsyncCallbacks()) {
- client()->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
+ ResourceHandleClient* client = this->client();
+ if (d->m_usesAsyncCallbacks) {
+ if (client)
+ client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
+ else
+ continueCanAuthenticateAgainstProtectionSpace(false);
return false; // Ignored by caller.
- } else
- return client() && client()->canAuthenticateAgainstProtectionSpace(this, protectionSpace);
+ }
+
+ return client && client->canAuthenticateAgainstProtectionSpace(this, protectionSpace);
}
void ResourceHandle::continueCanAuthenticateAgainstProtectionSpace(bool result)
{
- ASSERT(client());
- ASSERT(client()->usesAsyncCallbacks());
+ ASSERT(d->m_usesAsyncCallbacks);
[(id)delegate() continueCanAuthenticateAgainstProtectionSpace:result];
}
void ResourceHandle::continueWillCacheResponse(NSCachedURLResponse *response)
{
- ASSERT(client());
- ASSERT(client()->usesAsyncCallbacks());
+ ASSERT(d->m_usesAsyncCallbacks);
[(id)delegate() continueWillCacheResponse:response];
}
+2015-07-28 Alexey Proskuryakov <ap@apple.com>
+
+ Clean up usesAsyncCallbacks handling in ResourceHandle
+ https://bugs.webkit.org/show_bug.cgi?id=147342
+
+ Reviewed by Darin Adler.
+
+ Update for a renaming in WebCore.
+
+ * NetworkProcess/NetworkResourceLoader.cpp:
+ (WebKit::NetworkResourceLoader::cleanup):
+ * Shared/Downloads/soup/DownloadSoup.cpp:
+ (WebKit::Download::platformInvalidate):
+
2015-07-28 Chris Fleizach <cfleizach@apple.com>
AX: iOS: VoiceOver hangs indefinitely when an JS alert appears
invalidateSandboxExtensions();
if (m_handle) {
- m_handle->setClient(nullptr);
+ m_handle->clearClient();
m_handle = nullptr;
}
void Download::platformInvalidate()
{
if (m_resourceHandle) {
- m_resourceHandle->setClient(0);
+ m_resourceHandle->clearClient();
m_resourceHandle->cancel();
m_resourceHandle = nullptr;
}