From 80e68b43c3da64848db8edc7d8e8fe095888e42e Mon Sep 17 00:00:00 2001 From: Andrei Popescu Date: Tue, 8 Dec 2009 18:37:43 +0000 Subject: Break the WebCore -> WebKit dependency in ResourceHandleAndroid.cpp. --- WebCore/platform/network/ResourceHandleInternal.h | 6 +-- .../network/android/ResourceHandleAndroid.cpp | 24 ++++------ .../network/android/ResourceLoaderAndroid.h | 53 ++++++++++++++++++++++ 3 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 WebCore/platform/network/android/ResourceLoaderAndroid.h (limited to 'WebCore') diff --git a/WebCore/platform/network/ResourceHandleInternal.h b/WebCore/platform/network/ResourceHandleInternal.h index 31d740a..fa939db 100644 --- a/WebCore/platform/network/ResourceHandleInternal.h +++ b/WebCore/platform/network/ResourceHandleInternal.h @@ -69,9 +69,7 @@ class NSURLConnection; #endif #if PLATFORM(ANDROID) -namespace android { - class WebCoreResourceLoader; -} +#include "ResourceLoaderAndroid.h" #endif // The allocations and releases in ResourceHandleInternal are @@ -229,7 +227,7 @@ namespace WebCore { CFURLAuthChallengeRef m_currentCFChallenge; #endif #if PLATFORM(ANDROID) - android::WebCoreResourceLoader* m_loader; + RefPtr m_loader; #endif AuthenticationChallenge m_currentWebChallenge; diff --git a/WebCore/platform/network/android/ResourceHandleAndroid.cpp b/WebCore/platform/network/android/ResourceHandleAndroid.cpp index 639582c..d5d5e5c 100644 --- a/WebCore/platform/network/android/ResourceHandleAndroid.cpp +++ b/WebCore/platform/network/android/ResourceHandleAndroid.cpp @@ -26,27 +26,23 @@ #define LOG_TAG "WebCore" #include "config.h" + #include "ResourceHandle.h" +#include "CString.h" #include "DocLoader.h" #include "DocumentLoader.h" #include "Frame.h" #include "FrameLoader.h" -#include "FrameLoaderClientAndroid.h" #include "NotImplemented.h" #include "ResourceHandleClient.h" #include "ResourceHandleInternal.h" -#include "WebCoreFrameBridge.h" -#include "WebCoreResourceLoader.h" -#include "CString.h" - -using namespace android; +#include "ResourceLoaderAndroid.h" namespace WebCore { ResourceHandleInternal::~ResourceHandleInternal() { - Release(m_loader); } ResourceHandle::~ResourceHandle() @@ -58,16 +54,15 @@ bool ResourceHandle::start(Frame* frame) DocumentLoader* adl = frame->loader()->activeDocumentLoader(); bool isMainResource = ((void*) client()) == ((void*) adl->mainResourceLoader()); - WebCoreResourceLoader* loader; - FrameLoaderClientAndroid* client = static_cast (frame->loader()->client()); - loader = client->webFrame()->startLoadingResource(this, d->m_request, isMainResource, false); + + PassRefPtr loader = ResourceLoaderAndroid::start(this, d->m_request, frame->loader()->client(), isMainResource, false); if (loader) { - Release(d->m_loader); d->m_loader = loader; + return true; } - return loader != NULL; + return false; } void ResourceHandle::cancel() @@ -104,7 +99,7 @@ bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*) // network/mac/ResourceHandleMac.mm request.setCachePolicy(ReturnCacheDataDontLoad); FormData* formData = request.httpBody(); - return WebCoreResourceLoader::willLoadFromCache(request.url(), formData ? formData->identifier() : 0); + return ResourceLoaderAndroid::willLoadFromCache(request.url(), formData ? formData->identifier() : 0); } bool ResourceHandle::loadsBlocked() @@ -150,8 +145,7 @@ void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, SyncLoader s(error, response, data); ResourceHandle h(request, &s, false, false, false); // This blocks until the load is finished. - FrameLoaderClientAndroid* client = static_cast (frame->loader()->client()); - client->webFrame()->startLoadingResource(&h, request, false, true); + ResourceLoaderAndroid::start(&h, request, frame->loader()->client(), false, true); } } // namespace WebCore diff --git a/WebCore/platform/network/android/ResourceLoaderAndroid.h b/WebCore/platform/network/android/ResourceLoaderAndroid.h new file mode 100644 index 0000000..004675e --- /dev/null +++ b/WebCore/platform/network/android/ResourceLoaderAndroid.h @@ -0,0 +1,53 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ResourceLoaderAndroid_h +#define ResourceLoaderAndroid_h + +#include +#include +#include + +namespace WebCore { + +class FrameLoaderClient; +class ResourceHandle; + +class ResourceLoaderAndroid : public RefCounted { +public: + static PassRefPtr start(ResourceHandle*, const ResourceRequest&, FrameLoaderClient*, bool isMainResource, bool isSync); + virtual ~ResourceLoaderAndroid() { } + + virtual void cancel() = 0; + virtual void downloadFile() = 0; + + // Call to java to find out if this URL is in the cache + static bool willLoadFromCache(const WebCore::KURL&, int64_t identifier); +protected: + ResourceLoaderAndroid() { } +}; + +} +#endif // ResourceLoaderAndroid -- cgit v1.1